As you can see, px and py are arrays that contain 100 numbers from 0 to 1. But nevertheless, in the plot generated, the axis range is wrong (from 0 to 100 instead of from 0 to 1), and this bothers me a lot because I need to plot several curves in the same plot, and the next curve is not corresponding with the first because of the wrong axis values of the first. (My real data is a very huge dataset; I used the case of px and py as an useful example)
I will appreciate your help. Puravida.
The code I am using:
import numpy as np
px=np.linspace(0,1,100)
py=px
import matplotlib.pyplot as plt
import matplotlib.colors as colors
startcolor = '#FFFFFF' # white
midcolor = '#FEDB8B' # yellow
endcolor = '#FE9272' # Orange
endcolor2 = '#723472' # Purpple
colorsforCmap=[startcolor,midcolor,endcolor,endcolor2]
cmap2 = colors.LinearSegmentedColormap.from_list('own2',colorsforCmap)
plt.cm.register_cmap(cmap=cmap2)
plt.rcParams["figure.figsize"] = [12,9]
heatmap, xedges, yedges = np.histogram2d(px, py, bins=(100, 100))
plt.clf()
plt.imshow(heatmap.T, origin='lower',cmap=cmap2)
plt.show()
Wrong plot generated. Look at the axis values: