How can I use the default tickformatters (which I like and don't want to have to recreate) to make my own custom tickmarks? The problem I am trying to solve is that I'd like to apply a function to all of the numbers on the y-axis.
For instance, let's say that I wanted to square all of the y-axis tick labels. I don't want to change their positions or change the underlying data, I just want to change the labels. I understand that I could write my own formatter from scratch, but I'd prefer to just write a wrapper around the existing formatters. I tried:
import matplotlib.pyplot as plt
from matplotlib.ticker import ScalarFormatter
def my_formatter(x,pos):
return ScalarFormatter(x**2,pos)
x = np.arange(10)
y = x
fig, ax = plt.subplots()
plt.plot(x,y)
ax.yaxis.set_major_formatter(plt.FuncFormatter(my_formatter))
plt.show()
I understand why it doesn't work, I'm trying to figure out how to actually call the ScalarFormatter so that I can get the strings it would generate.

