mpltex是一个python包,用于使用matplotlib创建发布质量图。
mpltex的Python项目详细描述
mpltex是一个python包,用于使用matplotlib生成发布质量的图像。 灵感来自Olga Botvinnik的python包prettyplotlib。
内部的matplotlib颜色循环被Tableau经典的10色方案所取代,该方案看起来不太饱和,更讨人喜欢。 多线图的其他可用颜色方案是ColorBrewer集1和Tableau Classic 20。 有关这些配色方案的详细信息,请参见documentation of palettable。
mpltex还提供了一种生成具有颜色、线型和线型标记的高度可配置线型的方法。 支持空心标记。
快速启动
一。安装
$ pip install mpltex
必需的包
- matplotlib。可通过 pip install matplotlib。
- palettable。可以是 通过pip install palettable安装。
2.使用量
可以找到示例和示例图here。
要使用mpltex
,只需在plot函数之前添加一个mpltexdecorators。
importmpltex@mpltex.acs_decoratordefmyplot():# plot images by matplotlib ...# Save the image. Give a file name without extension.# You can also save figure outside your_plot if you like.fig.save_fig('/path/to/save/fig/figname')# Then use your_plot in a normal way.myplot()
它将为美国化学学会(acs)出版的期刊创造一个情节。
可用的装饰器
- mpltex.acs_decorator:输出EPS图像以在ACS(美国化学学会)中发布。
- mpltex.aps_decorator:输出EPS图像以在APS(美国物理学会)中发布。
- mpltex.rsc_decorator:输出EPS图像以在RSC(皇家化学学会)中发布。
- mpltex.presentation_decorator:为演示文稿幻灯片(注释记号)输出PDF图像。
- mpltex.web_decorator:输出网页的png图像。
mpltex还提供了几个帮助函数,以方便生成特定类型的图像。 下面的代码将在mpltex.linestyle_generator函数的帮助下生成一组具有循环线样式的线艺术。 注意,由于版本0.5,linestyles是linestyle_generator的简写。
importmatplotlib.pyplotaspltimportmpltex@mpltex.acs_decoratordefmyplot():# ... # generate data x and yfig,ax=plt.subplots(111)# The default line style is iterating over# color, line, and marker with hollow types.linestyles=mpltex.linestyles()# equivalently# linestyles = mpltex.linestyle_generator()foriinrange(number_of_lines):ax.plot(x[i],y[i],label=str(i),**next(linestyles)ax.locator_params(nbins=5)# limit the number of major ticksax.legend(loc='best')# show legend in a best locationfig.tight_layout(pad=0.1)# make layout as tight as possiblefig.savefig('/path/to/save/fig/figname')
贡献
在github.com分叉项目并提交一个请求。