I've used scale from sklearn.preprocessing
to scale my data on the X and Y axis which compressed my data to -2 < x < 2
. When I plot this data, I want the original scaling back for use on the tick marks.
My code looks like:
scale(readings_array, copy=False)
plt.plot(readings_array)
ax = plt.gca()
ax.set_xticklabels(np.arange(0,24))
plt.ylabel("Total Traffic Volume")
plt.xlabel("Time")
plt.show()
Which looks like:
What I really want is for the the xlabels to be 0->24 (0 at the smallest value) for hours of the day and the ylabels to be 0->600
My first answer is: just keep a copy of your original data. Much the simplest, most pythonic answer.
If you are trying to avoid making copies of your data. use
StandardScaler()
instead ofscale()
. You can eitherinverse_transform()
the data when you are done using the scaled data:or use the scaling factors to create x_ticks and x_ticklabels:
With my apologies for typos.