用点划线绘制问题:如何修改默认线型以更好地与矢量渲染器"painters"配合使用? [英] Plotting issues with dash-dot and dotted lines: How to modify default linestyles for better use with vector renderer 'painters'?

查看:126
本文介绍了用点划线绘制问题:如何修改默认线型以更好地与矢量渲染器"painters"配合使用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Matlab提供以下默认 线型 :

'-'     Solid line (default)
'--'    Dashed line
':'     Dotted line
'-.'    Dash-dot line

前两个没问题,第三个:绝对不是我的品味,并且渲染效果很差,最后一个-.仅可用于像素渲染器(openGLzbuffer),否则外观相同如--.但是出于许多原因,我想使用painters渲染图形.这样,点划线就变得无用了:

点划线(蓝色,亮红色)实际上看起来与虚线(深红色)相同.这是我基于矢量图形的PDF的3000%缩放.

这基本上是我生成图形的代码:

set(fig_handle, 'Units','centimeters','PaperUnits','centimeters')
set(fig_handle,'Position',[1 1 width height],...
       'PaperPosition',[0 0 width+margin height+margin],...
       'PaperSize',[width+margin height+margin],...
       'PaperPositionMode','auto',...
       'InvertHardcopy', 'on',...
       'Renderer','painters'...     
   );

saveas(fig_handle,name,'pdf')

我需要第三种线型,您知道创建自定义线型或修改现有线型的可能性吗? 增加点和点之间的间距应该已经解决了这个问题.

标记和像素渲染器的使用是不可能的!

另外,一些自定义"行也不意味着舍弃"值.

感谢您的任何建议.

解决方案

MATLAB的绘图例程曾经是一流的.它们比竞争对手的要好得多,因此是许多人购买MATLAB的原因.

但是,这已经改变了.与来自Mathematica,SciLab和其他地方的地块相比,它们看起来像是过去的爆炸.它们看起来不太漂亮,它们使用标准的渲染引擎时存在很多问题,可定制性相当差,甚至简单的更改也很难实现,等等.

不要误会我的意思,它们仍然很不错,但是现在不再是购买该产品的理由.我什至听说有些潜在的新用户在决定其竞争对手之一,部分原因是基于图形外观.

MathWorks当然比这更重要.他们的响应速度很慢(我想他们有一些困难),但是我知道他们已经对图形算法和实用程序进行了大修四年了.

它称为hg2,是 handle graphics v.2 的缩写.自2010年以来,它已经在MATLAB中可用,但是后来完全没有文档记载,有错误,难以使用等.

然而,多年来,这种情况一直在稳步改善,现在实际上已经可以使用了(尽管官方仍未提供支持). Yair Altman(来自UndocumentedMatlab.com)写了关于该主题的不错的深入文章.

它具有您需要的功能,然后是一些 :)

我刚收到来自MATLAB Central的当前管理员John Kelly的电子邮件.前几行:

R2014b预发行版现已可供下载.这个版本的 MATLAB包含许多新功能,包括新的图形系统. R2014b图形系统中的更改可能会影响 现有代码的操作.作为流行文件交换的作者 提交,我们鼓励您下载R2014b 预发布,以便您有机会进行更改 提交以准备发布R2014b.

因此R2014b 最终附带了官方hg2 :)

Matlab offers the following default linestyles:

'-'     Solid line (default)
'--'    Dashed line
':'     Dotted line
'-.'    Dash-dot line

The first two are alright, the third : is absolutely not my taste and rendered badly and the last one -. is just usable with pixel renderers (openGL, zbuffer), otherwise it looks the same as --. But I'd like to render my graphs with painters for countless reasons. This way the dash-dot line becomes useless:

The dash-dot lines (blue, bright red) practically look the same like the dashed line (dark red). This is a 3000% zoom of my vector-graphic based PDF.

This is basically my code to generate the graphicss:

set(fig_handle, 'Units','centimeters','PaperUnits','centimeters')
set(fig_handle,'Position',[1 1 width height],...
       'PaperPosition',[0 0 width+margin height+margin],...
       'PaperSize',[width+margin height+margin],...
       'PaperPositionMode','auto',...
       'InvertHardcopy', 'on',...
       'Renderer','painters'...     
   );

saveas(fig_handle,name,'pdf')

Well I need a third linestyle, do you know any possibility to create a custom linestyle or to modify the existing ones? Increasing of the gaps between dashes and dots should already solve the problem.

Markers and the use of the pixel-renderers are no option!

Also some "custom" lines in means of "leaving out" values shouldn't be an option.

I'm thankful for any advice.

解决方案

MATLAB's plotting routines used to be top-notch. They were so much better than those of the competition that they were a reason to buy MATLAB for many people.

This has changed however. They seem rather like a blast from the past now, when compared to plots from Mathematica, SciLab, and others. They don't look very pretty, they have lots of issues with different-then-standard rendering engines, customizability is rather poor, even simple changes can be quite complicated to effect, etc.

Don't get me wrong, they're still pretty good, but they are no longer a reason to buy the product anymore. I've even heard some potential new users deciding for one of its competitors, in part based on how graphics look.

MathWorks is of course more than aware of this. They are rather slow to respond (I assume they have some difficulties), but I know they have been working on a major overhaul of the graphics algorithms and utilities for over 4 years now.

It's called called hg2, short for handle graphics v. 2. It's already been available in MATLAB since 2010, but then it was completely undocumented, buggy, hard to use, etc.

This has however improved steadily over the years, and now it's actually quite usable (although still unsupported, officially). Yair Altman (from UndocumentedMatlab.com) wrote a nice in-depth article on the subject.

This has the functionality you need, and then some :)

EDIT: I just got an e-mail from John Kelly, the current administrator from MATLAB central. The first few lines:

The R2014b prerelease is now available for download. This version of MATLAB contains many new features including a new graphics system. There are changes in the R2014b graphics system that may affect the operation of existing code. As an author of a popular File Exchange submission, we would like to encourage you to download the R2014b prerelease so that you have an opportunity to make changes to your submission in preparation for the release of R2014b.

So R2014b finally ships with an official hg2 :)

这篇关于用点划线绘制问题:如何修改默认线型以更好地与矢量渲染器"painters"配合使用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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