我想从pd.DataFrame绘制条形图。不幸的是,matplotlib不断排列我的小节,显示N = 100,N = 150,N = 50而不是50,100,150
df1 = pd.DataFrame({"N": ["N=50","N=100","N=150","N=50","N=100","N=150","N=50","N=100","N=150"],\
"clm2": profit[0:len(profit)],\
"User": ["2x2x2","2x2x2","2x2x2","3x3x3","3x3x3","3x3x3","4x4x4","4x4x4","4x4x4"]})
with PdfPages('profit.pdf') as pdf:
ax1= df1.pivot(index = "User", columns = "N", values = "clm2")
plt.x_range = FactorRange(factors=df1["N"].tolist())
ax1.plot.bar(figsize=(7,7),edgecolor = "white",rot=0).set_ylabel("Profits")
pdf.savefig()