Unexpected line colors when saving simple plot

조회 수: 4 (최근 30일)
John Mahoney
John Mahoney 2014년 7월 30일
답변: Star Strider 2014년 7월 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에서 Graphics에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by