我正在 matplotlib 中绘制一些饼图,并且我的一些图表上的百分比标签相互重叠并且看起来很乱。有没有办法改变文本的位置,使其全部可读?我得到的示例如下 - 类别“其他”和“ALD2_OH”重叠且不可读。

我的绘图代码在这里:
matplotlib.rcParams.update({'font.size': 18})
plt.figure(figsize=(11,11))
labels = ['ALD2 + OH','PAN + $therm$','ALD2 + NO$_3$','ATOOH + $hv$',
'Others',]
colours = ['BlueViolet','DarkMagenta','DarkOrchid','DarkViolet','Purple'
]
patches, texts,autotexts = plt.pie(main_producers, labels=labels, colors = colours,
autopct='%1.1f%%', startangle = 90)
plt.title('Contribution to MCO$_3$ yeild')
Run Code Online (Sandbox Code Playgroud)
希望有人能帮忙!
谢谢
我numpy.loadtxt用来从文本文件中提取大量数据,然后使用循环将不同的列放入不同的字典键,如下所示:
f = numpy.loadtxt(datafile, skiprows=5) # Open and read in the file, skipping to the data
d = {} # Create empty dictionary
for x in range(0, f.shape[1]):
d[x] = f[:,x] # Loop through the columns of the datafile, putting each one into
#a dictionary index
Run Code Online (Sandbox Code Playgroud)
文本文件中数组上方的行包含数组中变量的所有标题,有没有办法获取每个变量名称并将其作为相关字典的键名?(即第一栏=数据,d [日期] = {14/11/12,15/11/12 ......等)