仅限 Matplotlib(加上 numpy.arange)。
如果您考虑一下,很容易正确放置条形组。
import matplotlib.pyplot as plt
from numpy import arange
places = ["Nujiang Lisu","Chuxiong Yi","Liangshan Yi","Dehong Dai & Jingpo"]
animals = ['Pandas', 'Snow Leopards']
n_places = len(places)
n_animals = len(animals)
animals_in_place = [[5,7,5,6],[7,4,8,5]]
### prepare for grouping the bars
total_width = 0.5 # 0 ≤ total_width ≤ 1
d = 0.1 # gap between bars, as a fraction of the bar width, 0 ≤ d ≤ ∞
width = total_width/(n_animals+(n_animals-1)*d)
offset = -total_width/2
### plot
x = arange(n_places)
fig, ax = plt.subplots()
for animal, data in zip(animals, animals_in_place):
ax.bar(x+offset, data, width, align='edge', label=animal)
offset += (1+d)*width
ax.set_xticks(x) ; ax.set_xticklabels(places)
fig.legend()