Getting transparency in a vector plot
13 次查看(过去 30 天)
显示 更早的评论
Hi,
The following creates a plot that uses transparency to render otherwise obscured data visible ...
tval = 1980:1:2009;
figure(1); clf;
hold on;
h1 = area(x, y1); set(h1, 'FaceColor', [0.9 0.8 0.8], 'EdgeColor', [0.9 0.8 0.8]); h1b = get(h1, 'Children'); set(h1b, 'FaceAlpha', 0.5);
h2 = area(x, y2); set(h2, 'FaceColor', [0.8 0.8 0.9], 'EdgeColor', [0.8 0.8 0.9]); h2b = get(h2, 'Children'); set(h2b, 'FaceAlpha', 0.5); plot (tval, ann_data_sst, 'r-', tval, ann_nemo_sst, 'b-'); axis ([1980 2009 17.8 19.4]); axis square; xlabel ('Time [year]'); ylabel ('SST [{\circ}C]'); title ('Sea surface temperature');
paper; orient portrait;
print -depsc2 -painters future_1980_2009_phys
... And I'm quite pleased with the result, at least as it appears on the screen. However, when I try to print it to an EPS file, all I get is a flat plot with no transparency. Obscured data remains annoyingly obscured.
From poking around the MathWorks website, it looks like this loss of transparency may be a fundamental limitation of printing to EPS in vector format. If I drop the -painters option or use OpenGL instead (while still writing to an EPS file), I get the transparency but with hideous bitmap fonts, etc. A colleague suggested switching to PDF, but I find I get the same results with this - so long as I'm printing in vector format, transparency seems a no-go.
Has anyone here ever done anything like this successfully (or better) before? Alternatively, does anyone have any tips for how I could plot such a set of data to achieve something like the transparency effect that I'm aiming for?
Apologies for having such a woolly question.
Best regards,
Andrew.
P.S. I can try to post up images of what I mean if it's not obvious.
P.P.S. For reference ...
-------------------------------------------------------------------------------------
MATLAB Version 7.8.0.347 (R2009a)
MATLAB License Number: ••••••
Operating System: Linux 2.6.32.12-0.7-default #1 SMP 2010-05-20 11:14:20 +0200 x86_64
Java VM Version: Java 1.6.0_04-b12 with Sun Microsystems Inc. Java HotSpot(TM) 64-Bit Server VM mixed mode
-------------------------------------------------------------------------------------
MATLAB Version 7.8 (R2009a)
Image Processing Toolbox Version 6.3 (R2009a)
MATLAB Compiler Version 4.10 (R2009a)
M_Map - mapping toolbox (Author: rich@eos.ubc.ca) Version 1.4c 9
Mapping Toolbox Version 2.7.2 (R2009a)
Neural Network Toolbox Version 6.0.2 (R2009a)
Optimization Toolbox Version 4.2 (R2009a)
Partial Differential Equation Toolbox Version 1.0.14 (R2009a)
Signal Processing Toolbox Version 6.11 (R2009a)
Simulink 3D Animation Version 5.0 (R2009a)
Spline Toolbox Version 3.3.6 (R2009a)
Statistics Toolbox Version 7.1 (R2009a)
Symbolic Math Toolbox Version 5.2 (R2009a)
Wavelet Toolbox Version 4.4 (R2009a)
0 个评论
采纳的回答
Jan
2012-12-3
编辑:Jan
2012-12-3
Transparency requires the OpenGL renderer. The OpenGL renderer can export bitmap images only. This is a fundamental limitation.
FEX: ExportSVG might be a workaround.
3 个评论
Petr Dohnalik
2022-2-19
编辑:Petr Dohnalik
2022-2-19
Yes, transparency is a fundamental limitation of .eps format also in 2022.
If you use other software, you can run into similar problem, see this thread on Wolfram Mathematica, R, or Adobe Ilustrator. However, you can print .svg formats from Matlab by now, see "formattype" in print help.
更多回答(1 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Labels and Annotations 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!