MATLAB Answers

weird artefacts when saving piechart as pdf

7 views (last 30 days)
Jaap
Jaap on 15 Feb 2015
Answered: Informaton on 4 Aug 2017
Hi everybody,
I'm currently trying to get a pdf-image of a piechart, but i'm running into some trouble. The problem is that the first slice seems regular, but then the rest of them have these weird artefacts. It happens with the saveas function, but the print function has the samen issues. Exporting to EPS format gives the same results. I have no clue where this effect comes from, so I'm hoping any of you guys can help me.
I have attached an image with the artefacts.
I'm using Matlab R2014b on Mac OSX 10.9. Thanks!
  1 Comment
Shikicat
Shikicat on 29 Jul 2015
I have the same exact problem! Have you figured it out by any chance? I'm using MATLAB R2015a, Mac OSX 10.10.2. Thanks.

Sign in to comment.

Answers (1)

Informaton
Informaton on 4 Aug 2017
Someone had the same issue on stack overflow
I found adding any one of these, after your call to pie and such, took care of the problem:
  • set(gcf,'renderermode','manual');
  • set(gcf,'renderer','opengl');
  • set(gcf,'renderer','opengl','renderermode','manual');
It is a bit strange because get(gcf,'renderer') shows opengl as the renderer (at least on my machine), however it is interpreted as a painters algorithm until the render mode is switch to manual. The render mode is switched to manual automatically if you manually set the renderer to opengl. Or you can just set render mode to manual and then it (MATLAB) actually takes a look at the renderer property.
Here's proof of concept:
clc;
h=pie(1);
%set the pie chart color to black
h(1).FaceColor = 'k';
% set(gcf,'rendererMode','manual');
set(gcf,'renderer','opengl','renderermode','manual')
saveas(gcf,'pie.df');

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!