Created
January 9, 2020 12:23
-
-
Save ImportanceOfBeingErnest/846fc3da59520ad7589d970cb46ebebd to your computer and use it in GitHub Desktop.
Button inside nested Gridspec
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import matplotlib.pyplot as plt | |
import matplotlib.gridspec as gridspec | |
from matplotlib.widgets import Button | |
def on_click(event): | |
print("hey") | |
fig = plt.figure(constrained_layout=True) | |
gs = gridspec.GridSpec(2, 1, height_ratios=[14, 1], figure=fig) | |
gs1 = gs[0, 0].subgridspec(1, 1) | |
ax1 = fig.add_subplot(gs1[0, 0]) | |
ax1.text(0.5, 0.5, "ax1", va="center", ha="center") | |
gs2 = gs[1, 0].subgridspec(1, 2) | |
ax2 = fig.add_subplot(gs2[0, 1]) | |
b = Button(ax2, 'hey') | |
b.on_clicked(on_click) | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment