This is a test version of Biostars. For the public version, visit https://www.biostars.org.
How to change values on X-axis in matplotlib ?

How to change values on X-axis in matplotlib?

I plotted a chart but the values on the x-axis on the graph needed to be modified, how can I change the values on the x-axis by matplotlib, I want to make it 0, 0.1, 0.2, 0.3, 0.4, 0.5 instead of 0,10, 20 etc?

matplotlib plot

fig, ax = plt.subplots()
fig.set_size_inches(12,7)

lo_sig = -1 *np.log2(df_significance['p.adjustMANOVA'])
lo_eff = -1 *np.log2(df_effect['p.adjustMANOVA'])
lo_sd = -1 *np.log2(df_sd['p.adjustMANOVA'])

df = pd.DataFrame({'Significance':lo_sig,'Effect_size':lo_eff,'Standard_deviation':lo_sd})

ax.grid()
ax.set_ylabel(r'$p.adjustMANOVA$')
ax.set_xlabel(r'$s.dist$')
ax.set

plt.plot(df['Significance'], label='Significance', color='green')
plt.plot(df['Effect_size'], label='Effect_size', color='steelblue')
plt.plot(df['Standard_deviation'], label='Standard_deviation', color='purple')
plt.show()
matplotlib python pandas

1 answer

perhaps you can use

yourplot= df.plot()
yourplot.set_xticklabels([0, 0.1, 0.2, 0.3, 0.4, 0.5])

Thanks it worked !!

Log in to answer this question.