You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Factor out & improve accuracy of derivatives calculations in axisartist.
grid_helper_curvelinear and floating_axes, which can both draw axes that
are neither horizontal nor vertical, need to compute the derivatives of
the data-coords-to-screen-coords transform (actually, of
data-coords-to-data-coords-of-intermediate-horizontal/vertical-axes) to
get the angles at which to draw the axes labels, ticks and ticklabels.
Factor out this calculation into a _value_and_jacobian helper. Instead
of selecting the step size as some fraction of
lat_factor/lon_factor/delta_extremes, use the square root of machine
precision epsilon, which is standard and (approximately) optimal for
non-centered numerical differentiation (see e.g.
scipy.optimize.approx_fprime, or the Wikipedia article on numerical
differentiation) -- and also happens to avoid introducing an extra
paremeter into _value_and_jacobian.
Also lift some calculations out of get_tick_iterators (it doesn't really
matter whether they are done inside or outside of get_tick_iterators,
but dedenting the block is always nice).
The increases in tolerances arise because the calculations of the
derivatives actually become *more* precise; for example, printing the
angle returned by get_axislabel_pos_angle and running test_polar_box
shows that previously the axes labels were drawn at angles of
(45+1e-11) and 45.135 degrees, whereas they are now drawn at exactly 45
degrees. These tolerances (0.27/0.12) are actually still very small;
e.g. removing the text.kerning_factor backcompat setting would require
bumping the tolerance to more than 5.
0 commit comments