我正在尝试在每个x轴点上获得一个标签。使用当前代码,标签在较长的x轴标题上被切断,并且只有每隔这么多的x轴点都有标签。
如何使图像画布更大而不切断x轴标签?
如何强制在x轴上标记每个点?
import pandas as pd
import matplotlib.pyplot as plt
import sys
def plotcsv(csvpath):
pdata = pd.read_csv(csvpath)
pdata = pdata.set_index('Build') #Adds build column for names of x axis points
try: # sometimes there's an extra column if there were extra commas in the csv
pdata = pdata.drop(pdata.columns[4], axis = 1)
except:
pass
p = pdata.plot(title="Power vs Build", rot=-10)
p.set_ylabel("W")
# print(pdata.index)
# print(pdata['Build'])
# plt.xticks(pdata.index, rotation=90) # Doesn't work
plt.savefig(csvpath + '.png')