Skip to content

Commit

Permalink
Fix: The set_view_interval, set_data_interval and set_bounds methods …
Browse files Browse the repository at this point in the history
…of Locators and Formatters (and their common base class, TickHelper) are removed. in matplotlib 3.7.0 https://matplotlib.org/stable/api/prev_api_changes/api_changes_3.7.0.html
  • Loading branch information
WISEPLAT committed Apr 1, 2023
1 parent 5bce508 commit becfbb0
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions backtrader/plot/locator.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,20 @@ def get_locator(self, dmin, dmax):
locator = MicrosecondLocator(interval, tz=self.tz)

locator.set_axis(self.axis)

try:
# try for matplotlib < 3.6.0
locator.set_view_interval(*self.axis.get_view_interval())
locator.set_data_interval(*self.axis.get_data_interval())
except Exception as e:
try:
# try for matplotlib >= 3.6.0
self.axis.set_view_interval(*self.axis.get_view_interval())
self.axis.set_data_interval(*self.axis.get_data_interval())
locator.set_axis(self.axis)
except Exception as e:
print("Error:", e)

return locator


Expand Down

0 comments on commit becfbb0

Please sign in to comment.