Unexpected line colors when saving simple plot

1 次查看(过去 30 天)
I am trying to plot some lines with various shades of gray and find some unexpected results.
Matlab plot window expected: gray figure background y1 gray (invisible against background) y2 gray (barely visible against background) y3 white y4 white
Saved plot expected: same line colors, but against white background instead
Matlab plot observed: same as expected
Saved plot observed: white background - OK y1 not visible - WHY? y2 light gray - OK y3 white on white = not visible - OK y4 black - WHY?
clear all
x = linspace(0,1,100);
y1 = sin(20*x);
y2 = sin(20*x) + 0.5*x;
y3 = x;
y4 = x.^2;
figure
hold on
plot(x, 0*x, 'k');
plot(x, y1, 'color', [0.8, 0.8, 0.8]);
plot(x, y2, 'color', [0.83, 0.83, 0.83]);
plot(x, y3, 'color', [0.999, 0.999, 0.999]);
plot(x, y4, '-w');
axis off
print('-dpng', 'test')
Thanks for your input! - John
Matlab 8.0.0.783 (R2012b) Mac OS 10.8.5

回答(1 个)

Star Strider
Star Strider 2014-7-30
See if specifying a different renderer makes a difference:
print('-dpng', '-painters', 'test')
There are also other options you can experiment with.

类别

Help CenterFile Exchange 中查找有关 Legend 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by