2024-06-15 00:42:38 发布
网友
我想做类似的事情(使用matplotlib):
(来自Colorfill boxplot in R-cran with lines, dots, or similar)
我看到一些关于舱口的信息了吗?但我真的不知道怎么用这个。
此外,我还想知道如何更改参数,比如boxprop dict的可能属性——在plt.boxplot(…,boxprops=boxpropsdict)中使用。是否可以列出所有可能的属性?
重要的方面是在调用boxplot时设置patch_artist=True。
boxplot
patch_artist=True
import numpy as np import matplotlib.pyplot as plt # fake up some data spread= np.random.rand(50) * 100 center = np.ones(25) * 50 flier_high = np.random.rand(10) * 100 + 100 flier_low = np.random.rand(10) * -100 data = np.concatenate((spread, center, flier_high, flier_low), 0) # basic plot bp = plt.boxplot(data, patch_artist=True) for box in bp['boxes']: # change outline color box.set(color='red', linewidth=2) # change fill color box.set(facecolor = 'green' ) # change hatch box.set(hatch = '/') plt.show()
基本绘图示例取自boxplot demo。但是,这些示例都没有设置patch_artist=True。如果省略该语句,您将得到以下错误:
AttributeError: 'Line2D' object has no attribute 'set_facecolor'
boxplot demo 2非常详细地展示了如何将矩形拟合到箱线图以获得着色。This blog指向patch_artist选项。 有关舱口的更多信息,请参阅hatch demo。上面的示例生成此图:
patch_artist
重要的方面是在调用
boxplot
时设置patch_artist=True
。基本绘图示例取自boxplot demo。但是,这些示例都没有设置
patch_artist=True
。如果省略该语句,您将得到以下错误:boxplot demo 2非常详细地展示了如何将矩形拟合到箱线图以获得着色。This blog指向
patch_artist
选项。有关舱口的更多信息,请参阅hatch demo。上面的示例生成此图:
相关问题 更多 >
编程相关推荐