简体   繁体   English

matplotlib的绘图样式

[英]Plot-style of matplotlib

I'd like to know why matplotlib outputs plots in different styles depending on which system I run the file. 我想知道为什么matplotlib根据运行文件的系统以不同的样式输出绘图。 For example, I let the same code run twice, once on a Windows machine and once on Ubuntu system, and got the following two plots 例如,我让相同的代码运行两次,一次在Windows机器上,一次在Ubuntu系统上,得到以下两个图

Windows版本 Ubuntu版本 The information in the plots is obviously the same, but is there a special command to let matplotlib know that I'd, for example, would like all my plots to be produced in the "Ubuntu style" (lower of the two) version? 地块中的信息显然是相同的,但是是否有一个特殊的命令让matplotlib知道我希望例如以“ Ubuntu风格”(两个版本中的较低版本)生产所有地块?

The upper plot is produced with a version of matplotlib >= 2.0. 上图是使用matplotlib> = 2.0版本生成的。 The lower plot is produced with a version < 2.0. 下图是使用版本<2.0生成的。 The style changes are documented in the Changes to the default style . 样式更改记录在“ 更改为默认样式”中

It's hardly possible to make a matplotlib version < 2.0 produce the exact output you'd get with matplotlib >= 2.0, although you might copy the style sheet from a newer version to the old one and set the parameters accordingly. 尽管您可以将样式表从较新版本复制到旧版本并相应地设置参数,但是几乎不可能使matplotlib版本<2.0产生与matplotlib> = 2.0完全相同的输出。

The inverse is however possible. 然而,相反是可能的。 To get the old (classic) style in a new version of matplotlib should be possible via 要通过新版本的matplotlib获得旧(经典)样式,应该可以通过

import matplotlib.pyplot as plt
plt.style.use("classic") 

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

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