将饼图保存为pdf时出现未知的白线 [英] unknown white lines when saving pie chart as pdf

查看:377
本文介绍了将饼图保存为pdf时出现未知的白线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我将饼形图另存为pdf时,pdf带有未知的白线.为了简化问题,我将代码修改为以下最通用的形式.

clc;
h=pie(1);
%set the pie chart color to black
h(1).FaceColor = 'k';

我选择使用黑色的原因是白线与黑色背景的对比度最大.请参阅随附的pdf图.

在此链接上,我还找到了具有相同问题的类似线程:将饼形图另存为pdf 时会产生怪异的伪影.目前没有提供解决方案.

我的系统配置:macOS Sierra版本10.12. Matlab R2016b.

欢迎任何输入.谢谢.

解决方案

在您致电pie等后,我发现添加了其中的任何一个可以解决问题:

  • set(gcf,'renderermode','manual');
  • set(gcf,'renderer','opengl');
  • set(gcf,'renderer','opengl','renderermode','manual');

这很奇怪,因为如果您尝试使用get(gcf,'renderer'),它将显示它是opengl(至少在我的机器上),但是直到渲染模式切换为手动之前,它都会被解释为绘画算法.如果将渲染器设置为opengl,或者将渲染模式设置为手动,然后它(MATLAB)实际查看了renderer属性,则会自动发生这种情况.

这里是概念证明

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.pdf'); 

我必须将其转换为图像才能在此处显示,但是.pdf看起来一样(即没有白线).

When I save a pie chart as pdf, the pdf has unknown white lines. To simplify the question, I modify the code to its most generic form as the following.

clc;
h=pie(1);
%set the pie chart color to black
h(1).FaceColor = 'k';

The reason I choose to use black color is the white lines contrast most with a black background. Please see the attached pdf figure.

I also find a similar thread having the same issue at this link: weird artifacts when saving pie chart as pdf. No solution is provided at this point.

My system configuration: macOS Sierra version 10.12. Matlab R2016b.

Any input is welcome. Thank you.

解决方案

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 strange because if you try get(gcf,'renderer') it will show it is opengl (at least on my machine), however it is interpreted as a painters algorithm until the render mode is switch to manual. This happens automatically if you 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.pdf'); 

I had to convert this to an image to have it show up here, but the .pdf looks the same (i.e. no white lines).

这篇关于将饼图保存为pdf时出现未知的白线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆