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
There is a "communication" issue between the axes.locator_params and the LogLocator class:
plt_scale='log'#plt_scale = 'linear'fig, (ax1) =plt.subplots(1, 1)
ax1.set(yscale=plt_scale)
# works for linear scale, not for log:ax1.axes.locator_params('y', nbins=5)
Result:
AttributeError Traceback (most recent call last)
<ipython-input-74-3492af5f93c8> in <module>()
7
8 # works for linear scale, not for log:
----> 9 ax1.axes.locator_params('y', nbins=5)
/home/pierre/anaconda/lib/python2.7/site-packages/matplotlib/axes.pyc in locator_params(self, axis, tight, **kwargs)
2305 self.xaxis.get_major_locator().set_params(**kwargs)
2306 if _y:
-> 2307 self.yaxis.get_major_locator().set_params(**kwargs)
2308 self.autoscale_view(tight=tight, scalex=_x, scaley=_y)
2309
AttributeError: 'LogLocator' object has no attribute 'set_params'
What I get from the traceback is that locator_params method forwards the locator attributes (in my case nbins) to the actual locator object via its set_params method. And this method is missing from LogLocator. (set_params is indeed defined in MaxNLocatorhttps://github.com/matplotlib/matplotlib/blob/master/lib/matplotlib/ticker.py#L1297)
So my question is: shouldn't all Locator subclasses have a set_params method ?
(and then, my code example could raise a different error, or maybe a warning, complaining that LogLocator makes in fact no use of an nbins parameter!)
best,
Pierre
The text was updated successfully, but these errors were encountered:
Would you be interested in doing this generalization? The easiest path would be to add a set_params to Locator that is a no-op + warning (so the code stops dying!) and then to add sensible implementations to each of the Locator classes.
There is a "communication" issue between the
axes.locator_params
and theLogLocator
class:Result:
What I get from the traceback is that
locator_params
method forwards the locator attributes (in my casenbins
) to the actual locator object via itsset_params
method. And this method is missing from LogLocator. (set_params
is indeed defined inMaxNLocator
https://github.com/matplotlib/matplotlib/blob/master/lib/matplotlib/ticker.py#L1297)So my question is: shouldn't all
Locator
subclasses have aset_params
method ?(and then, my code example could raise a different error, or maybe a warning, complaining that
LogLocator
makes in fact no use of annbins
parameter!)best,
Pierre
The text was updated successfully, but these errors were encountered: