简体   繁体   English

在matplotlibrc中设置破折号样式

[英]Set dash style in matplotlibrc

Can I define the dash style, ie length and separation, in the matplotlibrc file? 我可以在matplotlibrc文件中定义破折号样式,即长度和间隔吗?

Right now, I have to do something like this: 现在,我必须执行以下操作:

plt.plot(x, y, '--', dashes=(3,1))

I want to put the option "dashes=(3,1)" into the matplotlibrc, but could not find anything about it. 我想将选项“破折号=(3,1)”放入matplotlibrc中,但找不到任何相关信息。

Thanks 谢谢

EDIT: For clarification: I don't want to set this globally, but for a stylesheet ( http://matplotlib.org/users/style_sheets.html ), where the default dash style is too coarse, because the style is for small images for a publication. 编辑:为澄清起见:我不想在全局范围内进行设置,而是为样式表( http://matplotlib.org/users/style_sheets.html )设置,其中的默认破折号样式太粗糙了,因为样式太小出版物的图像。

If you really need to reuse this particular style a lot, you can simply create a partial function that sets a default for dashes= parameter. 如果确实需要大量重复使用此特定样式,则可以简单地创建一个为dashes=参数设置默认值的部分函数。

import functools
dashed_plot = functools.partial(plt.plot, dashes=(3, 1))

(It's not necessary to specify linestyle= when using the dashes keyword parameter). (使用dashes关键字参数时不必指定linestyle= )。

The rcfile is for other things such as what rendering backend to use, that should be set globally. rcfile用于其他事情,例如应使用的呈现后端,应全局设置。 I wonder why you want to enforce a dash style for everything as an rc option. 我想知道为什么要对所有内容强制使用破折号样式作为rc选项。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM