gpt4 book ai didi

python - 自定义 matplotlib 的配色方案

转载 作者:太空宇宙 更新时间:2023-11-04 05:39:40 25 4
gpt4 key购买 nike

我正在关注 Sane color scheme for Matplotlib ,却发现我的着色是still the same作为the default color scheme .有什么问题吗?

我正在关注 Customizing plots with style sheets ,并在我的代码顶部使用这些:

import matplotlib.pyplot as plt
plt.style.use('ggplot')

是这个原因吗?或者是其他东西?

披露,

The default color scheme in matplotlib is pretty ugly. Die-hard matlab/matplotlib fans may stand by their color scheme to the end, but it’s undeniable that Tableau’s default color scheme is orders of magnitude better than matplotlib’s.

更新: 显示我将有效的 matplotlibrc 文件放在正确的位置(已解释 here ):

D:\>python
Python 3.5.0 |Anaconda 2.4.0 (64-bit)| (default, Dec 1 2015, 11:46:22) [MSC v.1
900 64 bit (AMD64)] on win32
>>> import matplotlib
>>> matplotlib.matplotlib_fname()
'D:\\Programs\\Anaconda3\\lib\\site-packages\\matplotlib\\mpl-data\\matplotlibrc
'
D:\>dir D:\Programs\Anaconda3\libs\site-packages\matplotlib\mpl-data\matplotlibrc
Volume in drive D is New Volume

Directory of D:\Programs\Anaconda3\libs\site-packages\matplotlib\mpl-data

12/18/2015 05:34 PM 25,738 matplotlibrc
1 File(s) 25,738 bytes

最佳答案

从 matplotlib 1.5 开始,您可以在一组预定义样式(包括 ggplot)中进行选择。

如果你想创建your own stylesheet你只需要放置一个有效的 matplotlibrc 在某处归档并使用

import matplotlib.pyplot as plt
plt.style.set("/path/to/your/file.mplstyle")

然后您可以使用自己的风格。

关于python - 自定义 matplotlib 的配色方案,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34365183/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com