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
remove limitation linscale>=1.0 in SymmetricLogScale;
set linscale=1.0/math.log(base) or multiply linscale*=1.0/math.log(base) internally
explanation
currently one cannot set linscale values less than 1 in
Axes.set_{x,y}scale
due to
(matplotlib/scale.py:449) assert linscale >= 1.0
Setting linscale=1.0/math.log(base) (which is < 1.0) ensures that the symlog transformation function is smooth, i.e. its derivative is continuous at the border between linear and logarithmic regions. Smoothness of the transformation function is necessary&sufficient to avoid kinks in plots of smooth curves, i.e a smooth curve (with a continuous derivative) will be shown as a smooth curve. (see pictures). It makes sense then to set linscale=1.0/log(base) by default, or multiply it by this appropriate factor internally.
examples
(default)
(smooth, generated with patched matplotlib/scale.py sans 'assert linscale >= 1.0')
(kink)
generated with the following script
import matplotlib as mpl
import matplotlib.pyplot as plt
import numpy as np
import math
x = np.r_[-1:1:2000j]
y = 1e2**(-x) - 0.02
# default
ax = plt.figure().add_axes([0.1, 0.1, 0.8, 0.8])
ax.plot(x, y, ls='-')
ax.set_yscale('symlog')
ax.figure.savefig('fig_default.png')
# smooth
ax = plt.figure().add_axes([0.1, 0.1, 0.8, 0.8])
ax.plot(x, y, ls='-')
ax.set_yscale('symlog', linscaley=1./math.log(10))
ax.figure.savefig('fig_smooth.png')
# rough
ax = plt.figure().add_axes([0.1, 0.1, 0.8, 0.8])
ax.plot(x, y, ls='-')
ax.set_yscale('symlog', linscaley=math.log(10))
ax.figure.savefig('fig_kink.png')
To be more exact, i think we should allow linscale to be smaller than 1, does anybody see why this is enforced. For the rest of the issuse: the smoothness depends not only one linscale, but also on linthresh. I also think it is a little bit late to change defaults.
linscale defines the space ratio between a decade in the log-plot and halve of the linear part.
I actually need a ratio smaller than 1, else the log-part is to small for my case.
Activity
Tillsten commentedon May 7, 2014
This should be 1.4 milestone. I will try to solve this tomorrow.
Tillsten commentedon May 7, 2014
To be more exact, i think we should allow linscale to be smaller than 1, does anybody see why this is enforced. For the rest of the issuse: the smoothness depends not only one linscale, but also on linthresh. I also think it is a little bit late to change defaults.
Tillsten commentedon May 7, 2014
It is probably fine to just change the assert to > 0?
tacaswell commentedon May 7, 2014
milestoned an requested, but did not really read/understand what is going on.
Tillsten commentedon May 7, 2014
linscaledefines the space ratio between a decade in the log-plot and halve of the linear part.I actually need a ratio smaller than 1, else the log-part is to small for my case.
Tillsten commentedon May 7, 2014
pinging @mdboom
tacaswell commentedon Jun 2, 2014
Closing as #3053 is merged.