默认的颜色是这样的
增加一个color的配置项即可。
mycolors = ["black",
"hotpink",
"b",
"#4CAF50"
]
plt.pie(y, labels = mylabels,
startangle = 90,
explode = myexplode
,colors = mycolors
)
plt.pie(y, labels = mylabels,
startangle = 90,
explode = myexplode
,colors = mycolors
)
plt.legend()
'''
Created on 2023年1月14日
@author: admin
'''
import matplotlib.pyplot as plt
import numpy as np
from pandas._libs.reshape import explode
from openpyxl.utils.cell import col
y = np.array([35, 25, 25, 15])
import matplotlib.pyplot as plt
import numpy as np
mylabels = ["Apples",
"Bananas",
"Cherries",
"Dates"]
myexplode = [0.2, 0, 0, 0]
mycolors = ["black",
"hotpink",
"b",
"#4CAF50"]
plt.pie(y, labels = mylabels,
startangle = 90,
explode = myexplode
,colors = mycolors
)
plt.legend(title = "Four Fruits :")
plt.show()
最后的问题,如果加了中文标题会有什么效果?大家可以云尝试一下。
页面更新:2024-02-19
本站资料均由网友自行发布提供,仅用于学习交流。如有版权问题,请与我联系,QQ:4156828
© CopyRight 2008-2024 All Rights Reserved. Powered By bs178.com 闽ICP备11008920号-3
闽公网安备35020302034844号