-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
MEP22: Navigation by events #3652
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
Changes from 1 commit
8cceed4
3118a5a
b4d5fcf
1e8af47
622cb95
d1a9de4
3f89d52
4f3c10b
6065daa
f6a2f19
05db3b6
c08fe56
b207a72
9266447
a53419a
704c717
5056729
e6a4e1e
8942c47
022de6f
2c9a195
cafe668
224f745
94c711e
67257e7
ffa65d6
6739ee0
d18206f
34a52c8
c2da483
44a9b0e
a2ed47f
0665890
411e6e2
d484ebd
75bf97b
6cc040b
0ff5997
af6734f
78513d2
377ff54
7dbbf58
dd66b57
67a414f
e415d8d
1213086
ba61dec
9f2ee2b
9da2b13
110253f
e2804ea
9a64b7e
64f947f
e8cd5d5
4bbcf4e
73a2661
1b83628
e4edd23
d4ac2fb
a7640ef
48a6971
8dafe09
a0695d0
328b169
aac4744
f09b9ef
def3a52
9ee7e25
5eae4e1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
matplotlib.rcParams['toolbar'] = 'navigation' | ||
import matplotlib.pyplot as plt | ||
from matplotlib.backend_tools import ToolBase | ||
|
||
from pydispatch import dispatcher | ||
|
||
# Create a simple tool to list all the tools | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd prefer if these comments be class docstrings docstrings instead |
||
class ListTools(ToolBase): | ||
|
@@ -14,7 +14,7 @@ class ListTools(ToolBase): | |
|
||
def trigger(self, event): | ||
tools = self.navigation.get_tools() | ||
|
||
print ('_' * 80) | ||
print ("{0:12} {1:45} {2}".format('Name (id)', | ||
'Tool description', | ||
|
@@ -25,7 +25,7 @@ def trigger(self, event): | |
print ("{0:12} {1:45} {2}".format(name, | ||
tools[name]['description'], | ||
keys)) | ||
print ('_' * 80) | ||
print ('_' * 80) | ||
|
||
|
||
# A simple example of copy canvas | ||
|
@@ -45,15 +45,19 @@ def trigger(self, event): | |
clipboard.set_image(pb) | ||
|
||
|
||
|
||
|
||
|
||
fig = plt.figure() | ||
plt.plot([1, 2, 3]) | ||
|
||
# Add the custom tools that we created | ||
fig.canvas.manager.navigation.add_tool('List', ListTools) | ||
if matplotlib.rcParams['backend'] == 'GTK3Cairo': | ||
fig.canvas.manager.navigation.add_tool('copy', CopyToolGTK3) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd be fine with making this a GTK3Cairo-only example. Makes it a little bit simpler |
||
# | ||
# Just for fun, lets remove the forward button | ||
fig.canvas.manager.navigation.remove_tool('forward') | ||
|
||
# # Just for fun, lets remove the forward button | ||
# fig.canvas.manager.navigation.remove_tool('forward') | ||
|
||
|
||
plt.show() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since these are examples, I would suggest getting rid of extraneous commented out code, and also highlight important lines of code such as this one. For example, is it important that it gets called before importing pyplot? What is it for? Perhaps a short docstring at the top of this example would help explain its purpose/goal that it is demonstrating?