Plot colors showing incorrectly with gradient
Mostrar comentarios más antiguos
Hi all,
Somehow lately Matlab doesn't plot the correct colors in a plot anymore. I don't remember changing anything but this suddenly happened. When i try to plot a figure with the lines in a specific color, matlab actually plots the lines with some sort of color gradient. When I run the exact same plot code on a different computer, the plot is generated correctly. Could anyone tell me what I have to change to get it back to normal again. I have included a figure in which you can see what I mean. I use Matlab R2016a (student edition). The code that generates this figure is (with the plotted data just simple arrays):
figure(2)
plot(Range_NoNoise(:,1),Range_NoNoise(:,2),'b')
hold on
plot(Range_noise(:,1),Range_noise(:,2),'r')
legend('Sensed distance','Sensed distance with noise')
xlabel('Time [s]')
ylabel('Distance [m]')
title('Radar sensed distance with and without noise')

5 comentarios
Chad Greene
el 17 de Jun. de 2016
This is very strange. I'd like to try to replicate the problem on my computer, but you've provided no data! Does it happen when you try to plot other data values?
Rick Willems
el 18 de Jun. de 2016
Dominik Florian
el 6 de Oct. de 2017
Editada: Dominik Florian
el 6 de Oct. de 2017
Did you figure out what was the reason for this color gradient bug? For me, it works fine with the function "plot", however, with the function "errorbar", I have a similar issue as you (already for some time). The top and bottom horizontal lines of the errorbars actually do have the desired color, but the rest is in this weird gradient. I tried in version, R2016a, R2016b, and R2017a - no difference. example data:
x = 1:0.5:6
y = 20*sin(x);
y_err(1:11) = 1;
errorbar(y,y_err,'r')

Dominik Florian
el 6 de Oct. de 2017
Update: I uninstalled and afterwards reinstalled R2016b and the issue is still the same. However, I realised that when saving the figure using
print('testsave','-dpng');
the figure is plotted erroneously in Matlab, but the .png file shows the correct colors. Very weird.
Dominik Florian
el 6 de Oct. de 2017
Update#2: When adding a the line specification 'LineWidth', everything is plotted normally.
errorbar(y,y_err,'r','LineWidth',1)

Respuestas (1)
Cam Salzberger
el 6 de Oct. de 2017
Editada: Cam Salzberger
el 6 de Oct. de 2017
Hello Rick and Dominik,
I've seen this done deliberately by setting the CData property of a scatter plot, but not with a standard line or errorbar plot. Could you check and see if you have any default properties set that might impact this? Simply enter this in the Command Window:
get(groot, 'default')
These would be stored in the preferences directory, which is not overwritten when reinstalling MATLAB. Additionally, preferences will carry over from one version to the next when installing a new version, so that would explain the persistence across multiple releases, but not between computers.
If that doesn't help, can you save and attach a FIG file so we can examine the properties ourselves?
-Cam
4 comentarios
Dominik Florian
el 6 de Oct. de 2017
Editada: Dominik Florian
el 6 de Oct. de 2017
Hi Cam, Thank you very much for your answer. I tried what you suggested (resetting my preferences as described in the instructions), however, this didn't affect the weird color plotting behavior. Here you go with the corresponding .fig file. D
Cam Salzberger
el 6 de Oct. de 2017
Editada: Cam Salzberger
el 6 de Oct. de 2017
Hmm, it shows up normally on my system, so it's clearly not a figure property. Maybe something in your graphics? Couple more pieces of information to ask you:
- Which release of MATLAB are you using?
- Which OS are you using?
- What did you get for the output of get(groot, 'default')?
- What is the output of opengl('info')?
- If the output of opengl('info') shows a line like "Software: 'false'", and you're on Windows, try doing opengl('software') and then try it again.
Dominik Florian
el 6 de Oct. de 2017
Hi Cam, Did you see my two updates? (printing figure results in correct .png file and adding 'linewidth' results in normal plotting behavior in matlab)
1) R2016b
2) Edition: Windows 10 Education
Version: 1511
System Type: 64-Bit
3) defaultFigurePosition: [403 246 560 420] defaultFigurePaperPositionMode: 'auto' defaultFigureColor: [1 1 1] defaultAxesFontUnits: 'points' defaultAxesFontName: 'Arial' defaultAxesXColor: [0 0 0] defaultAxesYColor: [0 0 0] defaultAxesZColor: [0 0 0] defaultAxesColorOrder: [0 0 0] defaultTextFontUnits: 'points' defaultTextFontName: 'Arial' defaultTextColor: [0 0 0] defaultUicontrolFontName: 'Arial'
(as specified in my startup.m file)
4) Version: '4.3.0 - Build 10.18.15.4268' Vendor: 'Intel' Renderer: 'Intel® HD Graphics 4400' RendererDriverVersion: '10.18.15.4268' RendererDriverReleaseDate: '05-Aug-2015' MaxTextureSize: 16384 Visual: 'Visual 0x07, (RGBA 32 bits (8 8 8 8), Z depth 16 bits, Hardware acceleration, Double buffer, Antialias 8 samples)' Software: 'false' HardwareSupportLevel: 'full' SupportsGraphicsSmoothing: 1 SupportsDepthPeelTransparency: 1 SupportsAlignVertexCenters: 1 Extensions: {215×1 cell} MaxFrameBufferSize: 16384
5) after this command, the errorbar figure has the correct color, with low resolution.
Thank you for your help! Dominik
Cam Salzberger
el 6 de Oct. de 2017
Odd, I really didn't expect it to be an issue with the graphics card/driver, but figured I'd try it on an outside chance. Guess I really shouldn't underestimate the odd errors that can come from that.
It looks like your driver is a bit out of date. I'd recommend updating it to the latest by Intel. I think this one is the right driver, but check that it is right for your system. This may resolve the issue while using hardware OpenGL.
If the driver update doesn't fix it, and you'd rather just use software OpenGL all the time, you can run this command:
opengl('save', 'software')
I'm glad it's resolved now though!
-Cam
Categorías
Más información sobre 2-D and 3-D Plots en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!