Saving plot in coloful png format
1 次查看(过去 30 天)
显示 更早的评论
__Hi dear MathWorks staff and other matlab users. I made calculation using MATLAB and got figure with contourf plot. In figure i see filled colorful plot. But when i try to save (file-save as) it in png format, i get plot in black and white. Can you explain me, what is my error? I attached matlab figure ive got. Thanks in advance.
__P.S. Thank you Stephen Cobeldick. You are right - i confused two companies. Now i corrected my post...
5 个评论
采纳的回答
Walter Roberson
2015-10-16
I was testing in R2014a, which is important because graphics changed in R2014b in ways that matter to this situation.
In R2014a (and earlier) when you select save as for PNG, the renderer gets switched to OpenGL from Painters. There is then a conflict in the layering between the rectangle with 'facecolor', 'w', and the contour plot: both of them are in the plane z = 0, so the renderer has to decide which has priority. In Painters the rule is "whichever one was drawn last", but in OpenGL the rules are more complicated. The OpenGL rules tend to prioritize lines over surfaces, which is why the lines show up. But with coplanar surfaces, I do not recall what the rule is.
For R2014a or earlier, you are going to have to push the rectangle into negative Z or pull the contour plot into positive Z. You can use a hgtransform to parent the object, with makehgtform with a Z translation as the Matrix. Or you could replace the rectangle with a patch that had a negative Z. (The purpose of the rectangle() being essentially to provide the white background and the circular edge drawing.)
For R2014b or later, you have another option: you can also use the new SortMethod property, which is discussed in Mike's blog . Watch out for the limitation discussed at the bottom about "some graphics cards" and about PDF.
The more robust method is to ensure that the contours are "above" the rectangle, even if only a tiny bit.
0 个评论
更多回答(1 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Lighting, Transparency, and Shading 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!