我有一个 pandas 数据框,我在图中绘制了该数据框,但由于某种原因,我无法让我的图有 xtick 标签。我尝试过使用 matplotlib,但它似乎不起作用。这是我的情节。
wsdf = pd.DataFrame(list(wshots.items()),columns = ['Coordinates', 'Occurences (S, G)'])
wsdf[['S','G']] = pd.DataFrame(wsdf['Occurences (S, G)'].tolist(), index=wsdf.index)
wsdf[['X-','Y']] = pd.DataFrame(wsdf['Coordinates'].tolist(), index=wsdf.index)
wsdf['wShot Percentage'] = wsdf['G'] / wsdf['S']
wsdf = wsdf.drop(['Coordinates', 'Occurences (S, G)'], axis = 1)
wsdf['X'] = abs(wsdf['X-'])
wsdf = wsdf.drop(['X-'], axis = 1)
wsdf = wsdf[["X", "Y", "S", "G", "wShot Percentage"]]
#makes it so there aren't any coordinates that dont have more than x shots
print(wsdf)
wsdf = wsdf.loc[wsdf['S'] >=1]
# scatter plot
wshot_plot = wsdf.plot.scatter(
x='X',
y='Y',
c='wShot Percentage',
colormap='RdYlGn',
alpha = 1/3)
这就是我试图得到的 xticks
xtick = [50, 60, 70, 80, 90, 100]
plt.plot(x, y)
plt.xlabel('xtick')
plt.show()
任何事情都会有所帮助!谢谢!