将图形导出为 eps、pdf 时 Matlab 中的奇怪行为
当我在 Matlab 中制作一个图形时,带有图例和一个接触 y 轴的矩形 (很奇怪,我知道)在将图形导出到 eps (或 pdf)时,我注意到矩形获得最后绘制的线条的线条样式(而不是绘制矩形的线条样式)
对于在接触轴的矩形之后绘制的矩形也会发生这种情况...
如果矩形是在创建图例之前绘制的......
不用说,我花了半天时间来创建一个最小的示例:
clf
L=plot(X,sin(X),'--');
legend(L,'sin(x)')
rectangle('position',[0.001,.1,.7,.7])
rectangle('position',[0,.5,.6,.7])
rectangle('position',[0.001,.3,.5,.7])
%legend(L,'sin(x)')
在屏幕上,3 个矩形有实线,正如它们应该的那样。但导出后,结果中的最后两条带有虚线(如 sin(x)
)。如果稍后完成图例命令(如注释掉的行中所示),一切都会按预期工作......
这是一个功能还是一个错误?
When I make a figure in Matlab, with a legend and a rectangle that touches the y axis (strange, I know) upon exporting the figure to eps (or pdf) I've noticed that the rectangle obtains the line-style of the last line drawn (rather than what the rectangle was drawn with)
This behaviour also occurs for rectangles drawn after the one that touches the axis...
This doesn't happen if the rectangle is drawn before the legend is created....
Needless to say, it took me half a day to create a minimal example:
clf
L=plot(X,sin(X),'--');
legend(L,'sin(x)')
rectangle('position',[0.001,.1,.7,.7])
rectangle('position',[0,.5,.6,.7])
rectangle('position',[0.001,.3,.5,.7])
%legend(L,'sin(x)')
On the screen the 3 rectangle have solid lines, as they should. but once they are exported, the result has the last two with dashed lines (like the sin(x)
). If the legend command is done later (as in the commented out line), everything works as it should....
Is this a feature or a bug?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这不是一个功能。我正在将其提交给开发。
您找到了一种只需最少代码练习的解决方法。我会将其记录在您的代码中,以便有人不会在不知不觉中更改它并继续前进。
如果您愿意接受其他输出格式,请注意这对于使用 MATLAB 输出过滤器的格式来说不是问题。
http://www.mathworks.com/access/helpdesk/ help/techdoc/ref/print.html
(图形格式文件部分,表格右列)
-Doug,MathWorks 处理图形问题的高级支持。
This is not a feature. I am submitting this to development.
You found a workaround that works with minimal code gymnastics. I would document it in your code so someone does not change it unknowingly and move on.
If you are open to other output formats, notice this is not an issue with formats that use an output filter of MATLAB.
http://www.mathworks.com/access/helpdesk/help/techdoc/ref/print.html
(Graphic Format Files section, right column in table)
-Doug, Advanced Support at MathWorks dealing with graphical issues.