I am trying to create a column density plot of a data set. The data includes the result of a 3D simulation with particles, that have been interpolated on a grid. When I plot with imshow()
I get ticks on the x and y axis that represent the pixels (from 0 to 512). My dataset, before the interpolation, extended from -0.5 to 0.5. How can I get imshow
to change the ticks from 0-512
to -0.5
to 0.5
? All the questions and answers I can find are for changing the frequency of ticks or their layout but nothing for changing the whole axis to represent something else.
The code I am running is:
import numpy as np
import matplotlib.pyplot as plt
data = np.loadtxt('pdf')
fig=plt.figure()
ax=fig.add_subplot(1,1,1)
p=ax.imshow(np.log(data),origin='lower')
cb = plt.colorbar(p,ticks=np.arange(np.amin(np.log(data)),np.amax(np.log(data)),2),aspect=15)
plt.show()