R2014b tesselates contour plots when saving to eps
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
When saving a contour plot to a vector format, the eps vector plot is "tesselated", i.e. it has dense triangular divisions along the fill of the contour.
This problem can be reproduced by
Z=peaks(50);
contourf(Z);
print(gcf,'-depsc','-painters','contours.eps');
Most viewers will show a white grid cut into many triangles on the figure. The file size is also very large (i.e. 532 KB vs 27 KB on previous versions). This makes a vector export of filled regions nearly useless in R2014b.
Running the same commands on previous versions results in a figure without tesselation. My operating system is OSX Yosemite 10.10.1.
1 Kommentar
Petar Lambrev
am 27 Mai 2016
In my work I rely heavily on contour map plots. Since version 2014b I cannot create publication quality vector figures anymore. The filled contours will have visible dividing lines on screen and on paper. So I use MATLAB 2014a, as it is the last version of MATLAB that works for me. What a pity!
Antworten (5)
Moises Jezzini
am 13 Jan. 2017
As today, the problem persist. This is one more workaround option.
The idea is to save all vectorial elements in an svg, and the colormap in a bitmap (in this case png). Then use Inkscape to fit the svg with the png.
Z = peaks(20);
hold on;
[~, hcf] = contourf(Z, 100, 'LineColor', 'none');
shading interp;
[~, hc] = contour(Z, 'ShowText','on', 'LineColor', 'black');
title('An example');
hold off;
set(hcf, 'Fill', 'off'); % Removes the contourf
print('Vector', '-dsvg'); % Saves the svg
set(hcf, 'Fill', 'on'); % Shows again the coutourf
set(hc, 'Visible', 'off'); % Hides the coutour lines
% When turning off the axis, the dimensions of the plot will change
% We will save the dimensions to perserve them
OriginalPosition = get(gca, 'Position'); % Save dimensions
axis off;
% Next lines to remove title
h_ch = get(gcf,'Children');
h_str = get(h_ch, 'Title');
set(h_str, 'String',''); % Remove title
set(gca, 'Position', OriginalPosition); % Now reset the plot dimensions
print('Bitmap', '-dpng');
Now, you need to open the svg file in Inkscape (free and open source). Select all (Ctrl-A), ungroup (Ctrl-U) and remove the backgrounds. Then import the png (File->Import), send it to the back (End), then you will need to fit the sizes and align. In this way the background is a bitmap and the numbers, axis and lines are vectors.
0 Kommentare
Dene Farrell
am 21 Dez. 2016
Bearbeitet: Dene Farrell
am 22 Dez. 2016
[Basically it says: Another work around is to use illustrator programatically fix_matlab_vector_graphics]
Mathworks have been answering these inquiries with excuses that it's an 'antialiasing algorithm' bug in the viewer and that the new export is better because it's simpler to break up these vector graphics into subcomponents. I'm really confused as to how they can convince themselves that this is true and how they convince others.
It's not acceptable for paid, proprietary software to make huge mistakes like this and then falsely blame it on an anti aliasing algorithm. Mathworks, you need to treat your paying customers with more respect! We are almost 6 versions past the original problem and they still haven't fixed it (2014b - 2017a).
2 Kommentare
Mike Garrity
am 6 Jan. 2015
It was done to avoid problems we were seeing with downstream apps choking on very complex polygons. We've probably dialed it too far in that direction. We'll probably move it back towards less subdivision than R2014b, but not as far as earlier releases.
4 Kommentare
Ben Ward
am 15 Apr. 2015
I really hope you can bring in an option to get rid of the subdivisions, because the way it is now creates a problem for people using software such as Illustrator. I am seeing a 25-fold increase in my .eps file sizes, to the point that they are completely intractable in Illustrator.
Dividing a vector patch into a discrete number of uniform triangles completely defeats the point of saving a vector image, as it is now essentially a (very poor and inefficient) bitmap.
Michael S
am 21 Mai 2015
Bearbeitet: Michael S
am 21 Mai 2015
One (slightly complicated) workaround:
- use contour (not contourf)
- save as eps / pdf (the latter is even better for me since the objects are grouped better than in the eps case - at least in Illustrator)
- now you have your contour-lines as hundreds of small line segments (i guess also one effect of the mentioned tesselation problem, in older Matlab versions this worked better)
- but you can select all the lines from one contour and join them. Now you can nicely change their appearance and also fill them to get something like a contourf plot (of course this is very complicated if you have a complex contour-landscape ... but in my case it was feasible)
I discovered that these contour lines have various export appearances for different OS and Matlab/Illustrator versions. I use pdf export and have R2014b + Illustrator CS5 on Windows7. On our Mac with R2012b we use eps export.
2 Kommentare
Mike Garrity
am 21 Mai 2015
Good suggestion!
I think that you'll find that it joins the line segments if you set the contour's LineStyle to something other than solid. The reason is that there's a performance cost to joining them, we skip that when we don't think it's going to matter.
So try creating your contour with a different LineStyle, then after you export it, set it back to solid in Illustrator.
Siehe auch
Kategorien
Mehr zu Discrete Data Plots finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!