Why is the "print" changing the colors of my plot?
4 views (last 30 days)
Show older comments
I have created an axis and I am trying to save the plot as a .jpg automatically. I first tried "saveas" but it was having the same problem. I've tried everything I can think of and this is the latest attempt. The only thing wrong at this point is the .jpg that is saved has different colors. The Blue comes out purple and the red is maroon. Does anyone know how to fix this? Thanks.
set(fig2,'PaperPositionMode', 'auto');
print(fig2, '-djpeg', '-r0', savename);
0 Comments
Answers (2)
Patrick Kalita
on 1 Jul 2011
I think that's just an artifact of the JPEG compression process. JPEG is usually best suited for photographic data where a slight shift in colors isn't as noticeable. You will get more accurate colors if you use a different bitmap format, like PNG:
print(fig2, '-dpng', '-r0', savename);
0 Comments
Jan
on 1 Jul 2011
Changing a color completely from blue to purple is not a compression artifact. I assume the JPEG is written correctly, but the re-import fails, because it is not written as true-color image and you omit the colormap when using IMREAD. But this is a guess only. Please post an example code, which reproduces the problem including the part of reading the image again.
1 Comment
Patrick Kalita
on 1 Jul 2011
I'm not sure the original question has anything to do with re-importing. If you just do a simple 'plot(magic(5))' and then follow the poster's 'set' and 'print' statements (changing the figure handles as needed) you can see the color changes by opening the resulting JPEG-file in any image viewer.
See Also
Categories
Find more on Purple 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!