R2014b tesselates contour plots when saving to eps
9 visualizzazioni (ultimi 30 giorni)
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
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.
Moises Jezzini il 13 Gen 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);
[~, hcf] = contourf(Z, 100, 'LineColor', 'none');
[~, hc] = contour(Z, 'ShowText','on', 'LineColor', 'black');
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
% 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
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.
Dene Farrell il 21 Dic 2016
Modificato: Dene Farrell il 22 Dic 2016
Previously Answered Here.
[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).
Mike Garrity il 6 Gen 2015
We've been discussing that change in the comments section of this question .
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.
Michael S il 21 Mag 2015
Modificato: Michael S il 21 Mag 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.