Dear all I want to recalculate the x y values written in the tick labeling of my figure after i have zoomed in it in such a way that the origin is always at (0,0) and obviously the relative distances of the values on the x and y axis stay the same.
I think I need to track the limits of my figure after having zoomed in to it and than simply subtract the current xmin and ymin from the actual x y tick values. I guess this can be achieved with the event handling API Event handling as i have learned here : Source1
This is also the place where I got the start of my MWE:
import matplotlib.pyplot as plt
#
# Some toy data
x_seq = [x / 100.0 for x in xrange(1, 100)]
y_seq = [x**2 for x in x_seq]
#
# Scatter plot
fig, ax = plt.subplots(1, 1)
ax.scatter(x_seq, y_seq)
#
# Declare and register callbacks
def on_xlims_change(axes):
a=axes.get_xlim()
print "updated xlims: ", axes.get_xlim()
return a
def on_ylims_change(axes):
a=axes.get_ylim()
print "updated ylims: ", axes.get_ylim()
return a
ax.callbacks.connect('xlim_changed', on_xlims_change)
ax.callbacks.connect('ylim_changed', on_ylims_change)
#
# Show
plt.show()
But I do not really know how I should go from here? Do i have to do the calculation inside the on_xlims_change function and change the x and y tick labels there? Again, I think I really only need to change the value given in the label, right? or would it be easier to change the actual value of the coordinates such that the automatic tick labeling still works?