MATLAB Answers

Poor resolution on EPS caused by fill function

5 ビュー (過去 30 日間)
Rudolf 2021 年 5 月 19 日
コメント済み: Bjorn Gustavsson 2021 年 5 月 20 日
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];
axis([1 6 2 8])
hold on;
% 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.)

回答 (1 件)

Bjorn Gustavsson
Bjorn Gustavsson 2021 年 5 月 19 日
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):
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...).
  2 件のコメント
Bjorn Gustavsson
Bjorn Gustavsson 2021 年 5 月 20 日
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...


Community Treasure Hunt

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

Start Hunting!

Translated by