Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix plot issue after updated to matplotlib 3.7.0 #91

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

iaalm
Copy link

@iaalm iaalm commented Mar 5, 2023

locator.set_view_interval is deprecated and replace with locator.axis.set_view_interval. The plot feature will break if updated to matplotlib 3.7.0.

@iaalm
Copy link
Author

iaalm commented Mar 5, 2023

it breaks like

    cerebro.plot()
  File "/Users/simon/Projects/pretzel/py311/lib/python3.11/site-packages/backtrader/cerebro.py", line 989, in plot
    rfig = plotter.plot(strat, figid=si * 100,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/simon/Projects/pretzel/py311/lib/python3.11/site-packages/backtrader/plot/plot.py", line 262, in plot
    self.mpyplot.setp(ax.get_xticklabels(), visible=False)
                      ^^^^^^^^^^^^^^^^^^^^
  File "/Users/simon/Projects/pretzel/py311/lib/python3.11/site-packages/matplotlib/axes/_base.py", line 74, in wrapper
    return get_method(self)(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/simon/Projects/pretzel/py311/lib/python3.11/site-packages/matplotlib/axis.py", line 1451, in get_ticklabels
    return self.get_majorticklabels()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/simon/Projects/pretzel/py311/lib/python3.11/site-packages/matplotlib/axis.py", line 1408, in get_majorticklabels
    self._update_ticks()
  File "/Users/simon/Projects/pretzel/py311/lib/python3.11/site-packages/matplotlib/axis.py", line 1257, in _update_ticks
    major_locs = self.get_majorticklocs()
                 ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/simon/Projects/pretzel/py311/lib/python3.11/site-packages/matplotlib/axis.py", line 1479, in get_majorticklocs
    return self.major.locator()
           ^^^^^^^^^^^^^^^^^^^^
  File "/Users/simon/Projects/pretzel/py311/lib/python3.11/site-packages/matplotlib/dates.py", line 1378, in __call__
    locator = self.get_locator(dmin, dmax)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/simon/Projects/pretzel/py311/lib/python3.11/site-packages/backtrader/plot/locator.py", line 226, in get_locator
    locator.set_view_interval(*self.axis.get_view_interval())
    ^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'RRuleLocator' object has no attribute 'set_view_interval'

@iaalm
Copy link
Author

iaalm commented Mar 5, 2023

@neilsmurphy could you help review this?

@iaalm
Copy link
Author

iaalm commented Mar 5, 2023

Root cause should be matplotlib/matplotlib@21e5876

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant