Getting transparency in a vector plot
24 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Andrew Yool
am 3 Dez. 2012
Bearbeitet: Petr Dohnalik
am 19 Feb. 2022
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 Kommentare
Akzeptierte Antwort
Jan
am 3 Dez. 2012
Bearbeitet: Jan
am 3 Dez. 2012
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 Kommentare
Petr Dohnalik
am 19 Feb. 2022
Bearbeitet: Petr Dohnalik
am 19 Feb. 2022
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.
Weitere Antworten (1)
Siehe auch
Kategorien
Mehr zu Lighting, Transparency, and Shading finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!