Unexpected line colors when saving simple plot
1 view (last 30 days)
Show older comments
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
0 Comments
Answers (1)
Star Strider
on 30 Jul 2014
See if specifying a different renderer makes a difference:
print('-dpng', '-painters', 'test')
There are also other options you can experiment with.
0 Comments
See Also
Categories
Find more on Legend in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!