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,linestyleslinestyle_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分叉项目并提交一个请求。

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
Java中ArrayList的超简单问题   Java 8在一段时间后过期   java如何创建具有用户定义维度的矩阵,并使用从上到下、从左到右的递增值填充它?   java从JDBC重启mysql   带有sqlite的java LiveData未更新UI   带有JDialog的java小程序在Mac OSX中未正确隐藏   java ActionListener无法从公共类引用数组?   java Apache Digester:NoSuchMethodException:没有这样的可访问方法   安卓中数据库中的java数据没有以正确的格式检索   java快速排序实现:使用random pivot时几乎排序   安卓 Java:高效的ArrayList过滤?   java如何在单独的文件中制作GUI程序   jasper报告如何从JSP或Java代码在JasperReport中传递参数值?