1、普通的饼状图
from matplotlib import pyplot as plt # 显示饼状图 # label = ["test1","test2","test3","test4"] # # fracs = [20,30,40,10] # # plt.axes(aspect=2) # plt.pie(labels=label,x=fracs) # plt.show()
效果图如下
2、显示每个label的比例
# 在图例中显示每个label的比例 # label = ["test1","test2","test3","test4"] # # fracs = [20,30,40,10] # # plt.axes(aspect=2) # plt.pie(labels=label,x=fracs,autopct="%.0f%%") # plt.show()
效果图如下
3、可以让某个/某几个label离开圆柱体,可以设置距离,如果不离开,距离设置为0即可
# # 可以让某个标签离开圆柱体 # label = ["test1","test2","test3","test4"] # fracs = [20,30,40,10] # # # 这里的0.1和0.2就是离开的距离 # explode = [0,0.1,0,0.2] # plt.axes(aspect=2) # plt.pie(labels=label,x=fracs,autopct="%.0f%%",explode=explode) # plt.show()
效果图如下
4、设置阴影效果
# 可以让某个标签离开圆柱体 # label = ["test1","test2","test3","test4"] # fracs = [20,30,40,10] # # # 这里的0.1和0.2就是离开的距离 # explode = [0,0.1,0,0.2] # plt.axes(aspect=2) # # shadow设置阴影效果 # plt.pie(labels=label,x=fracs,autopct="%.0f%%",explode=explode,shadow=True) # plt.show()
效果图如下
原创文章,作者:奋斗,如若转载,请注明出处:https://blog.ytso.com/20761.html