作者热门文章
- mongodb - 在 MongoDB mapreduce 中,如何展平值对象?
- javascript - 对象传播与 Object.assign
- html - 输入类型 ="submit"Vs 按钮标签它们可以互换吗?
- sql - 使用 MongoDB 而不是 MS SQL Server 的优缺点
我想在 python 的饼图中使用小尺寸的标签以提高可见性这是代码
import matplotlib.pyplot as plt
frac=[1.40 , 10.86 , 19.31 , 4.02 , 1.43 , 2.66 , 4.70 , 0.70 , 0.13 , 1.48, 32.96 , 1.11 , 13.30 , 5.86]
labels=['HO0900344', 'HO0900331', 'HO0900332', 'HO0900354',
'HO0900358', 'HO0900374', 'HO0900372', 'HO0900373',
'HO0900371', 'HO0900370', 'HO0900369', 'HO0900356',
'HO0900353', 'HO0900343']
fig = plt.figure(1, figsize=(6,6))
ax = fig.add_subplot(111)
ax.axis('equal')
colors=('b', 'g', 'r', 'c', 'm', 'y', 'burlywood', 'w')
ax.pie(frac,colors=colors ,labels=labels, autopct='%1.1f%%')
plt.show()
最佳答案
更改饼图字体大小的最简单方法是直接通过 textprops
argument在 pie()
函数中。使用上面的代码添加它:
ax.pie(frac, colors=colors ,labels=labels,
autopct='%1.1f%%', textprops={'fontsize': 14})
这样您就可以传入具有所需字体大小(例如 14)的字典。不用弄乱 rcParams
或从函数调用返回值。
关于python - 如何在python中的饼图上设置标签大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7082345/
有人可以帮我理解为什么我的饼图百分比计算不正确吗?看截图: 根据我的计算,如 RHS 上所示,支出百分比应为 24.73%。传递给 Highcharts 的值如下:- 花费:204827099.36-
我正在制作圆环饼图。 我设置数据的颜色并获取钻取(它是保存外部切片的数据和配置的对象)切片的颜色为同一组颜色。我想设置要在向下钻取对象中使用的不同颜色数组。请参阅附图(外层切片有两种颜色:橙色和透明)
我是一名优秀的程序员,十分优秀!