Suppose I have two numpy arrays x
and y
, and I would like to plot a simple curve of y
as a function of x
. At the y
axis, I would like to put (as labels) the values of y
, but at the x
axis I would like to put as labels some function of the values there.
For example, if x=array([1, 2, 4, 8, 16])
and y=array([1, 2, 1, 2, 1])
, I would like to assign labels to the xticks which will be the result of the following string formatting:
lambda x_val: "$2^{{+{:.0f}}}$".format(log2(x_val))
but I am interested in a general solution.