如何在 matplotlib.pyplot 饼状图中删除左侧标签?
若要删除 matplotlib 饼状图中左侧的标签,可以执行以下步骤:
创建小时、活动和颜色的列表。
使用 pie() 方法绘制饼状图。
若要隐藏 matplotlib 中左侧的标签,我们可以使用带有空白字符串的 plt.ylabel("")。
示例
import matplotlib.pyplot as plt
plt.rcParams["figure.figsize"] = [7.00, 3.50]
plt.rcParams["figure.autolayout"] = True
hours = [8, 1, 11, 4]
activities = ['sleeping', 'exercise', 'studying', 'working']
colors = ["grey", "green", "orange", "blue"]
plt.pie(hours, labels=activities, colors=colors, autopct="%.2f")
plt.ylabel("")
plt.show()输出

广告
数据结构
网络
RDBMS
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP