'NavigationToolbar2QT' object has no attribute 'add_tool'
时间: 2023-10-24 19:09:23 浏览: 173
This error occurs when you try to call the method `add_tool` on an instance of the `NavigationToolbar2QT` class, but that method does not exist in that class.
There are a few possible reasons for this error:
1. You might have misspelled the method name. Double-check the spelling and capitalization of the method name to make sure it matches the documentation or example code you are following.
2. You might be using an outdated version of Matplotlib. The `add_tool` method was removed in Matplotlib version 2.2, so if you are using an older version, you may need to update your code to use a different method or upgrade to a newer version of Matplotlib.
3. You might be using a different toolbar class that does not have an `add_tool` method. Check the documentation for the toolbar class you are using to see what methods are available and how to add custom tools or actions.
阅读全文