Plot colors showing incorrectly with gradient

8 Ansichten (letzte 30 Tage)
Rick Willems
Rick Willems am 17 Jun. 2016
Kommentiert: Cam Salzberger am 6 Okt. 2017
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 Kommentare
Dominik Florian
Dominik Florian am 6 Okt. 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
Dominik Florian am 6 Okt. 2017
Update#2: When adding a the line specification 'LineWidth', everything is plotted normally.
errorbar(y,y_err,'r','LineWidth',1)

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Cam Salzberger
Cam Salzberger am 6 Okt. 2017
Bearbeitet: Cam Salzberger am 6 Okt. 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 you'd like, you could try resetting all your preferences with these instructions.
If that doesn't help, can you save and attach a FIG file so we can examine the properties ourselves?
-Cam
  4 Kommentare
Dominik Florian
Dominik Florian am 6 Okt. 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
Cam Salzberger am 6 Okt. 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

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu 2-D and 3-D Plots finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by