3

So i'm trying to plot a (125 x 1000) grid with specified values. I'm using matplotlib with pcolormesh. This is how my code looks, enzyme array just symbolic.

enzyme = np.array([125 x 1000])

plt.pcolormesh(enzyme, cmap='Reds')
plt.colorbar()
plt.show()

The x-axis is my spatial resolution and my y-axis is time. My x-axis just runs from 0 to 125 and y-axis runs from 0 to 1000. But my actual problem is in hours, so I want the y-axis to show like 0hours -> 24hours per 2hours step. Something similar for the x-axis. So the grid index is not the right scale and number for my plot. How do I fix this.

I tried already including like

pcolormesh(x, y, enzyme)

with x and y a 1D array, but these have to match the length of my enzyme grid and i have way too many datapoints to put on the x- and y- axis.

CFRedDemon
  • 135
  • 1
  • 7
  • make sure that `x` and `y` are floats; if they are strings they will be treated as categories, and each tick will get labeled. Otherwise, I'm not sure what you mean by "i have way too many datapoints to put on the x- and y- axis". – Jody Klymak Apr 12 '19 at 16:56

1 Answers1

0

I would suggest creating a new x and y array that fits the size of your enzyme array. You would assign each x and y value the time that corresponds to each of your indices. For example, if your 0-1000 y-axis is supposed to represent 24 hours, you could do something like this:

increase=24/1000.
yvals=np.arange(0,24,increase)

Dividing 24/1000 will give you the increment needed such that you have 1000 values going from 0,24 hours.

You then can change the xtick increments with something like this:

ax.set_xticks(np.arange(0,24,2))
Benkerroum Mohamed
  • 1,867
  • 3
  • 13
  • 19
Karly
  • 1
  • 1