X axis was inverted automatically and unexpectedly when plotting a series of data against another series of data using pandas. Please look at my code below. How can I ensure x axis is always pointing to the right? Is this automatic inversion of x axis an intended behavior of pandas? Can it be disabled?
Let me explain my example below. Three plots are created. I expect each one shows nearly 45 degree line rising to the right. However, some of them have 45 degree line falling to the right because its x axis is inverted automatically. It appears that whether x axis is inverted or not depends on the values to be plotted.
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
df2 = pd.DataFrame(np.random.randn(10, 3), columns=["a", "b", "c"])
df3 = df2*1.1
df3.rename(columns={"a": "a*1.1", "b": "b*1.1", "c": "c*1.1"}, inplace=True)
df23 = df2.join(df3)
fig, ax_list = plt.subplots(1,3)
ax=ax_list[0]
df23[["a", "a*1.1"]].plot(ax=ax, x="a")
ax.axis('equal')
ax.set_title("(x,y)=(a,a*1.1)")
print ax.get_xlim() ## Added for clarity
ax=ax_list[1]
df23[["b", "b*1.1"]].plot(ax=ax, x="b")
ax.axis('equal')
ax.set_title("(x,y)=(b,b*1.1)")
print ax.get_xlim() ## Added for clarity
ax=ax_list[2]
df23[["c", "c*1.1"]].plot(ax=ax, x="c")
ax.axis('equal')
ax.set_title("(x,y)=(c,c*1.1)")
print ax.get_xlim() ## Added for clarity