I'd like to shift a pcolor plot along the x direction. But I'm not sure how to do it, as it's not as simple as using plot with a vector that specifies the x values
With this code:
import matplotlib.pyplot as plt
import numpy as np
np.random.seed(0)
Z = np.random.rand(6, 5)
tk = list(range(0,10+1))
fig, ax = plt.subplots(figsize=(7.2, 2.3))
ax.pcolor(Z)
ax.set_xticks(tk)
plt.show()
It produced this plot:
However I want the heatmap shifted to the right to start at x = 2, for example, like the following plot:
What am I missing???
As a side question, if I swap lines 11 and 12 to:
ax.set_xticks(tk)
ax.pcolor(Z)
I get this plot with the x axis contracted to the range [0,5]. I'm not sure why setting ticks before adding pcolor would do that?