我有两张单子。第一个是字符串列表a
['Agriculture/Forestry/Fisheries/Veterinary Medicine',
'Architectural and Town Planning',
'Business Administration and Related', ...]
第二个是浮动列表b
[66667.0,
22283.0,
670091.5, ...]
当我使用下面的代码来绘制它时
import matplotlib.pyplot as plt
%matplotlib inline
a = ['Agriculture/Forestry/Fisheries/Veterinary Medicine',
'Architectural and Town Planning',
'Business Administration and Related', ...]
b = [66667.0,
22283.0,
670091.5, ...]
fig = plt.figure()
ax = fig.add_subplot(111)
ax.bar(a,b)
plt.xticks(rotation=90)
根据列表a
中的字符串按字母顺序排列条形图。
我应该如何绘制它,使条形图按照列表b
的降序排列
这就是你想要做的:
使用numpy
list(zip(list_name, list_count))
将两个列表压缩为元组列表dtypes
的^{[::-1]
反转数组matplotlib
很容易接受数组,并且numpy
列可以与其名称一起传递李>一种简单的数据重新排列方法:
相关问题 更多 >
编程相关推荐