python - Prevent matplotlib to sort axis -
consider following test case:
import numpy np import matplotlib.pyplot plt x1 = np.arange(10) x2 = np.hstack((np.linspace(0.12312, 3.94, 5), np.linspace(-10.0121, -9.333411, 5))) y = 2.0 * x1 fig = plt.figure(1) ax = fig.gca() ax.plot(x1, y) fig = plt.figure(2) ax = fig.gca() ax.plot(x2, y) fig = plt.figure(3) ax = fig.gca() ax.plot(x1, y) ax.set_xticklabels(x2[ax.get_xticks().astype(int)]) plt.show()
i'd plot figure(2)
x2
original ordering. when use pyplot.plot
it's automatically sorted , messes axis.
i can manually set ticklabels in figure(3)
don't automatic axis scaling, formatting , on. hack myself formatters, locators etc, first i'd ask: there proper way achieve i'd like?
i don't think it's possible kind of plot. can manage somehow, did figure(3) it's totally against intuition or practice. if looking on 2d plot assume each axis continuous scale (ascending or descending). can logarithmic or other scale.
Comments
Post a Comment