Skip to content

Remove extraneous if 1 statements in demo_axisline_style.py #12222

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

Merged
merged 7 commits into from
Sep 25, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 deletions examples/axisartist/demo_axisline_style.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,23 @@
import matplotlib.pyplot as plt
import numpy as np

if 1:
fig = plt.figure()
ax = SubplotZero(fig, 111)
fig.add_subplot(ax)

for direction in ["xzero", "yzero"]:
# adds arrows at the ends of each axis
ax.axis[direction].set_axisline_style("-|>")
fig = plt.figure()
ax = SubplotZero(fig, 111)
fig.add_subplot(ax)

# adds X and Y-axis from the origin
ax.axis[direction].set_visible(True)
for direction in ["xzero", "yzero"]:
# adds arrows at the ends of each axis
ax.axis[direction].set_axisline_style("-|>")

for direction in ["left", "right", "bottom", "top"]:
# hides borders
ax.axis[direction].set_visible(False)
# adds X and Y-axis from the origin
ax.axis[direction].set_visible(True)

x = np.linspace(-0.5, 1., 100)
ax.plot(x, np.sin(x*np.pi))
for direction in ["left", "right", "bottom", "top"]:
# hides borders
ax.axis[direction].set_visible(False)

plt.show()
x = np.linspace(-0.5, 1., 100)
ax.plot(x, np.sin(x*np.pi))

plt.show()
22 changes: 17 additions & 5 deletions examples/event_handling/pick_event_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,9 @@ def pick_handler(event):
import numpy as np
from numpy.random import rand

if 1: # simple picking, lines, rectangles and text

def pick_simple():
# simple picking, lines, rectangles and text
fig, (ax1, ax2) = plt.subplots(2, 1)
ax1.set_title('click on points, rectangles or text', picker=True)
ax1.set_ylabel('ylabel', picker=True, bbox=dict(facecolor='red'))
Expand All @@ -101,7 +103,9 @@ def onpick1(event):

fig.canvas.mpl_connect('pick_event', onpick1)

if 1: # picking with a custom hit test function

def pick_custom_hit():
# picking with a custom hit test function
# you can define custom pickers by setting picker to a callable
# function. The function has the signature
#
Expand Down Expand Up @@ -142,7 +146,8 @@ def onpick2(event):
fig.canvas.mpl_connect('pick_event', onpick2)


if 1: # picking on a scatter plot (matplotlib.collections.RegularPolyCollection)
def pick_scatter_plot():
# picking on a scatter plot (matplotlib.collections.RegularPolyCollection)

x, y, c, s = rand(4, 100)

Expand All @@ -155,7 +160,9 @@ def onpick3(event):
#fig.savefig('pscoll.eps')
fig.canvas.mpl_connect('pick_event', onpick3)

if 1: # picking images (matplotlib.image.AxesImage)

def pick_image():
# picking images (matplotlib.image.AxesImage)
fig, ax = plt.subplots()
im1 = ax.imshow(rand(10, 5), extent=(1, 2, 1, 2), picker=True)
im2 = ax.imshow(rand(5, 10), extent=(3, 4, 1, 2), picker=True)
Expand All @@ -173,4 +180,9 @@ def onpick4(event):
fig.canvas.mpl_connect('pick_event', onpick4)


plt.show()
if __name__ == '__main__':
pick_simple()
pick_custom_hit()
pick_scatter_plot()
pick_image()
plt.show()