MATLAB Answers

David
13

Problem with 'Patch' graphics in 2014b - Splits in two along diagonal

Asked by David
on 11 Nov 2014
Latest activity Commented on by Nathan GREINER on 14 Oct 2018
I'm using 'Patch' to replace the boxes in box plots to change the colour etc. Code is:
h = findobj(gca,'Tag','Box');
for x=1:length(h)
boxShade=patch(get(h(x),'XData'),get(h(x),'YData'), colours(x,:), 'linestyle', 'none');
uistack(boxShade,'bottom');
end
delete(h);
This worked fine until I updated to 2014b where now the Patches appear to split in two along the diagonal, with the median in front of one half and behind the other. Example cut from exported pdf:
I am using the painters renderer as I'm outputting vector pdfs. Any ideas? I've seen some other talk that it's a bug from intersecting lines in a patch but there are no intersections here I believe as it's just a simple rectangle?
Any help greatly appreciated! David

  1 Comment

Experiencing the exactly the same problem with MATLAB R2015b. Any suugestions?

Sign in to comment.

21 Answers

Answer by Mike Garrity
on 12 Nov 2014
 Accepted Answer

The warning about DrawMode is trying to point you at the issue I described here:
I'm not sure why you're getting that message when you call the axes function. Is it possible that you have something in your startup like this?
set(0,'DefaultAxesDrawMode','normal')
If you read that blog post, you'll see that choosing the wrong value for SortMethod can result in artifacts that are similar to what you're seeing, so it would probably be a good idea to track down where that warning is coming from.

  8 Comments

Has there been any progress on this? It is absolutely insane that you have broken the ability to export patch objects to .eps and .pdf, without providing a fix...
It's November 24, 2015, I'm using R2015a, and the problem of the broken polygons and HUGE file size for vector graphics (e.g. eps with -painters renderer) seems unfixed. Has there been any progress on this front? For my purposes, the increased file size is a deal-breaker when trying to produce publication-quality graphics with (e.g.) multiple panels with different colorbars.
This remains a big problem - just updated from 2014a to 2016a and the vector graphics look terrible! "contourf" plots are no longer nice patch objects, or even patches broken into a small number of smaller objects, but many many abutting rectangles in a brickwork pattern with the dreaded antialiased white borders (see screenshots below, same code, same antialias options in preview, or the attached pdfs). I have come across this before using other visualization and analysis software and in my experience, "downstream tools" like Inkscape have a much harder time handling the vastly increased number of simple objects, than a small number of complex objects. Please, please provide an option to produce single patches in vector output!
2016a:
2014a:
PS - one thing that is fixed is the colorbar now looks the same in the figure window and the output, although they are still embedded raster objects and, bizarrely, the 2016a version also has a dividing white border that runs from bottom left to top right!

Sign in to comment.


Answer by Steve Hansen on 13 Feb 2016

Just checked R2015b an this significant problem remains.
For me and my research, you guys have broken one of the best parts about Matlab, quality vectorized figures. What is the point of having vectorized graphics if you are just going to chop up polygons into a large number of tessellated triangles?
I use contourf regularly to produce publication quality figures and the new graphics engine has made Matlab completely unusable for this purpose. Thus, this 'upgrade' represents a large step backwards for me.
My suggestion to anyone who needs a 'workaround' is to downgrade to Matlab R2014a until they fix this issue.
Here is a simple illustration of the problem:
load('penny.mat')
figure
contourf(P)
colorbar
colormap copper
set(gca,'Ydir','reverse')
print(gcf,'penny.pdf','-dpdf')
I have attached the results from R2014a, R2015b and R2015b using the 'opengl' print option.
The individual pdf files sizes are, R2014a : 23 KB, R2015b : 245 KB, R2015b openGL : 77 KB
The R2015b version is an order of magnitude larger in file size due to the tessellation and looks terrible. The R2015b openGL version is better but is a raster image which defeats the utility of vectorized graphics. Only the R2014a result is usable.

  3 Comments

I think this has been fixed in 17b, can you please check and confirm?