Poor resolution on EPS caused by fill function
10 views (last 30 days)
Show older comments
I have a problem with the resolution from matlab figures saved as EPS and used in a latex document.
Figures on pdf have poor resolution. It happens when function fill is added. Example code:
a = [7 7 7 3 3 3];
b = [5 6 7 5 4 3];
x = [1:1:6];
xticks(1:1:6)
axis([1 6 2 8])
hold on;
stairs(x,b,'--r')
plot(x,a,'m')
% When using fill the resolution goes from good to poor
fill([2 2 4 4],[2 8 8 2],'r','FaceAlpha',.1,'EdgeAlpha',0)
This code will make a eps figure look like this on the pdf:
I need transparency on the fill color, but setting FaceAlpha to 1 makes no difference:
Without fill - resolution is good:
What can I do to get good resolution? (I need to have color with adjustable transparency, or at least see the lines on top of a color which is not so intense.)
0 Comments
Answers (1)
Bjorn Gustavsson
on 19 May 2021
As far as I understand post-script does not really support transparency. Therefore when writing figures with transparent objects the printing will be done as a bit-mapped image and not in neatly vectorized format. You might get good enough output if you print to a .png-image with high enough resolution (image might become impolitely big):
print('-dpng','-r600','yourfilename.png')
You might also get some neater lables and such using ps-tricks (if this is still a tool in use in latex, I've been fortunate enough to never need to use it...).
HTH
2 Comments
Bjorn Gustavsson
on 20 May 2021
For this objective the "simplest" solution is just to crank up the resolution (or wait till the post-script format starts to handle transparency). I know this is a terribly unsatisfactory suggestion. Maybe you can somehow fudge things by printing the transparency object into an image-file (without labels and tick-marks, just the transparent surfaces) then load that image and display it using imagesc/imshow and manually set tick-marks and labels (and possibly add lines) and write that to an eps-file. That ought to give you the line-objects and text in vectorized format - admittedly this requires lots of manual editing and fidgeting...
See Also
Categories
Find more on Lighting, Transparency, and Shading 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!