Subplot function lines are black even though a color is specified

4 visualizzazioni (ultimi 30 giorni)
Hello. I am new to MatLab. I have a much more involved bit of code but I made it much simpler just to show the problem I am having.
x = (0:0.1:5);
y1 = x+1;
y2 = x+5;
y3 = x.^2;
subplot (2,2,1)
plot (x,y1,'r')
hold on
subplot (2,2,2)
plot (x,y2,'b')
subplot (2,2,3)
plot (x,y3,'y')
Sorry I have not commented any of this but I do get the three subplots as I want but not the line color that I have specified. The first subplot is a black line, the next is black but becomes a little red near the top of the y axis and the third has some green to it. None of this matches what I wanted and I have worked with this for a while.
All I want is a simple solid color other than black for the function on each subplot. Is there not a default somewhere (not in code) for a basic plot to be a solid color as in the matlab examples? I do not want to have to type a bunch of code for something that should be simple for a simple x,y graph. I would appreciate any help in this as a student first learning how to use this program.
Kind regards.
  2 Commenti
dpb
dpb il 26 Giu 2016
That works as expected here and should do as you expect. What release are you using? If don't know, to find out type
ver % on command line
Might also tell us what OS/version you're running under and what does
get(gcf,'renderer')
say after running the above code...
This looks like a combination of hardware/OS/installation/version that's not rendering the colors correctly.
Have you tried
clear all
close all
before trying again? If that doesn't do it, try closing the Matlab session entirely and then restarting Matlab and see if makes any difference.
If not, it may be time to contact TMW support...
kim webb
kim webb il 26 Giu 2016
Hello all and never mind the problem I was having. It was not code related or something I needed to set. I found a similar problem looking through the answers. I am a victim of the "new model year" of software, it would appear and I needed to run "opengl software" in the command line to fix this and now it works fine (as does my more involved code). I hope this helps someone else.
Kind regards.

Accedi per commentare.

Risposte (1)

Image Analyst
Image Analyst il 26 Giu 2016
I can't reproduce it. I'm not sure why. Mine looks fine, as I'd expect. Perhaps it has to do with what specific display adapters or display drivers we're using. But with display oddities like this, the usual fix is to do put the line of code
opengl software
into your software, as you said. This has been noted many times before but I don't blame you for not knowing it since you're new and, granted, it's pretty obscure.

Categorie

Scopri di più su Graphics Performance in Help Center e File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by