Reputation: 192
This is not a huge problem but I've got some subplots with a lot of important information to show in print later so I'd like it as clean as possible. I've got values between 0 and 1 in both axes and I'd like to ommit the 0 and show them as ".34", for example. Is it possible to do that without hardcode altering the labels?
Upvotes: 0
Views: 620
Reputation: 36604
import numpy as np
import matplotlib.pyplot as plt
fig, ax = plt.subplots()
ax.plot(np.linspace(0, .2, 10), np.linspace(0, .2, 10))
ax.set_yticklabels([str(x)[1:] for x in np.round(ax.get_yticks(), 3)])
plt.show()
Upvotes: 1