Skip to content

Cleanup examples and re-enable pep8 #8603

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 5 commits into from
May 12, 2017
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
6 changes: 3 additions & 3 deletions ci/travis/test_script.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#! /bin/bash

set -e
set -ev

# This script is meant to be called by the "script" step defined in
# .travis.yml. See http://docs.travis-ci.com/ for more details.
Expand All @@ -26,9 +26,9 @@ if [[ $BUILD_DOCS == false ]]; then

echo The following args are passed to pytest $PYTEST_ARGS $RUN_PEP8
if [[ $TRAVIS_OS_NAME == 'osx' ]]; then
python tests.py $PYTEST_ARGS $RUN_PEP8
pytest $PYTEST_ARGS $RUN_PEP8
else
gdb -return-child-result -batch -ex r -ex bt --args python $PYTHON_ARGS tests.py $PYTEST_ARGS $RUN_PEP8
gdb -return-child-result -batch -ex r -ex bt --args python $PYTHON_ARGS -m pytest $PYTEST_ARGS $RUN_PEP8
fi
else
cd doc
Expand Down
17 changes: 7 additions & 10 deletions examples/axes_grid1/demo_colorbar_of_inset_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@
from mpl_toolkits.axes_grid1.inset_locator import inset_axes, zoomed_inset_axes
from mpl_toolkits.axes_grid1.colorbar import colorbar


def get_demo_image():
from matplotlib.cbook import get_sample_data
import numpy as np
f = get_sample_data("axes_grid/bivariate_normal.npy", asfileobj=False)
z = np.load(f)
# z is a numpy array of 15x15
return z, (-3,4,-4,3)
return z, (-3, 4, -4, 3)


fig = plt.figure(1, [5,4])
ax = fig.add_subplot(111)
fig, ax = plt.subplots(figsize=[5, 4])

Z, extent = get_demo_image()

Expand All @@ -28,7 +28,7 @@ def get_demo_image():
ylim=(-20, 5))


axins = zoomed_inset_axes(ax, 2, loc=2) # zoom = 6
axins = zoomed_inset_axes(ax, 2, loc=2) # zoom = 6
im = axins.imshow(Z, extent=extent, interpolation="nearest",
origin="lower")

Expand All @@ -38,17 +38,14 @@ def get_demo_image():

# colorbar
cax = inset_axes(axins,
width="5%", # width = 10% of parent_bbox width
height="100%", # height : 50%
width="5%", # width = 10% of parent_bbox width
height="100%", # height : 50%
loc=3,
bbox_to_anchor=(1.05, 0., 1, 1),
bbox_transform=axins.transAxes,
borderpad=0,
)

colorbar(im, cax=cax)

colorbar(im, cax=cax) #, ticks=[1,2,3])


plt.draw()
plt.show()
4 changes: 2 additions & 2 deletions examples/axes_grid1/demo_colorbar_with_axes_divider.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@
fig.subplots_adjust(wspace=0.5)

ax1 = fig.add_subplot(121)
im1 = ax1.imshow([[1,2],[3,4]])
im1 = ax1.imshow([[1, 2], [3, 4]])

ax1_divider = make_axes_locatable(ax1)
cax1 = ax1_divider.append_axes("right", size="7%", pad="2%")
cb1 = colorbar(im1, cax=cax1)

ax2 = fig.add_subplot(122)
im2 = ax2.imshow([[1,2],[3,4]])
im2 = ax2.imshow([[1, 2], [3, 4]])

ax2_divider = make_axes_locatable(ax2)
cax2 = ax2_divider.append_axes("top", size="7%", pad="2%")
Expand Down
22 changes: 7 additions & 15 deletions examples/axes_grid1/demo_fixed_size_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

from mpl_toolkits.axes_grid1 import Divider, LocatableAxes, Size

def demo_fixed_size_axes():

def demo_fixed_size_axes():
fig1 = plt.figure(1, (6, 6))

# The first items are for padding and the second items are for the axes.
Expand All @@ -25,19 +25,16 @@ def demo_fixed_size_axes():

fig1.add_axes(ax)

ax.plot([1,2,3])


ax.plot([1, 2, 3])


def demo_fixed_pad_axes():

fig = plt.figure(2, (6, 6))

# The first & third items are for padding and the second items are for the axes.
# sizes are in inch.
h = [Size.Fixed(1.0), Size.Scaled(1.), Size.Fixed(.2),]
v = [Size.Fixed(0.7), Size.Scaled(1.), Size.Fixed(.5),]
# The first & third items are for padding and the second items are for the
# axes. Sizes are in inches.
h = [Size.Fixed(1.0), Size.Scaled(1.), Size.Fixed(.2)]
v = [Size.Fixed(0.7), Size.Scaled(1.), Size.Fixed(.5)]

divider = Divider(fig, (0.0, 0.0, 1., 1.), h, v, aspect=False)
# the width and height of the rectangle is ignored.
Expand All @@ -47,16 +44,11 @@ def demo_fixed_pad_axes():

fig.add_axes(ax)

ax.plot([1,2,3])




ax.plot([1, 2, 3])


if __name__ == "__main__":
demo_fixed_size_axes()
demo_fixed_pad_axes()

plt.draw()
plt.show()
17 changes: 8 additions & 9 deletions examples/axes_grid1/demo_new_colorbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,20 @@

"""
import matplotlib.pyplot as plt
from mpl_toolkits.axes_grid1.colorbar import colorbar


plt.rcParams["text.usetex"]=False
plt.rcParams["text.usetex"] = False

fig = plt.figure(1, figsize=(6, 3))
fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(6, 3))

ax1 = fig.add_subplot(121)
im1 = ax1.imshow([[1,2],[3,4]])
cb1 = plt.colorbar(im1)
im1 = ax1.imshow([[1, 2], [3, 4]])
cb1 = fig.colorbar(im1, ax=ax1)
cb1.ax.set_yticks([1, 3])
ax1.set_title("Original MPL's colorbar w/\nset_yticks([1,3])", size=10)

from mpl_toolkits.axes_grid1.colorbar import colorbar
ax2 = fig.add_subplot(122)
im2 = ax2.imshow([[1,2],[3,4]])
cb2 = colorbar(im2)
im2 = ax2.imshow([[1, 2], [3, 4]])
cb2 = colorbar(im2, ax=ax2)
cb2.ax.set_yticks([1, 3])
ax2.set_title("AxesGrid's colorbar w/\nset_yticks([1,3])", size=10)

Expand Down
1 change: 0 additions & 1 deletion examples/axes_grid1/parasite_simple.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,3 @@
leg.texts[1].set_color(p2.get_color())

plt.show()

2 changes: 0 additions & 2 deletions examples/axes_grid1/simple_axes_divider1.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,4 @@
ax3.set_axes_locator(divider.new_locator(nx=2, ny=2))
ax4.set_axes_locator(divider.new_locator(nx=2, nx1=4, ny=0))


plt.draw()
plt.show()
3 changes: 1 addition & 2 deletions examples/axes_grid1/simple_axes_divider2.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

# the rect parameter will be ignore as we will set axes_locator
rect = (0.1, 0.1, 0.8, 0.8)
ax = [fig1.add_axes(rect, label="%d"%i) for i in range(4)]
ax = [fig1.add_axes(rect, label="%d" % i) for i in range(4)]

horiz = [Size.Scaled(1.5), Size.Fixed(.5), Size.Scaled(1.),
Size.Scaled(.5)]
Expand All @@ -31,5 +31,4 @@
plt.setp(ax1.get_xticklabels()+ax1.get_yticklabels(),
visible=False)

plt.draw()
plt.show()
3 changes: 1 addition & 2 deletions examples/axes_grid1/simple_axes_divider3.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

# the rect parameter will be ignore as we will set axes_locator
rect = (0.1, 0.1, 0.8, 0.8)
ax = [fig1.add_axes(rect, label="%d"%i) for i in range(4)]
ax = [fig1.add_axes(rect, label="%d" % i) for i in range(4)]


horiz = [Size.AxesX(ax[0]), Size.Fixed(.5), Size.AxesX(ax[1])]
Expand All @@ -40,5 +40,4 @@
plt.setp(ax1.get_xticklabels()+ax1.get_yticklabels(),
visible=False)

plt.draw()
plt.show()
3 changes: 1 addition & 2 deletions examples/axes_grid1/simple_colorbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,11 @@
import numpy as np

ax = plt.subplot(111)
im = ax.imshow(np.arange(100).reshape((10,10)))
im = ax.imshow(np.arange(100).reshape((10, 10)))

# create an axes on the right side of ax. The width of cax will be 5%
# of ax and the padding between cax and ax will be fixed at 0.05 inch.
divider = make_axes_locatable(ax)
cax = divider.append_axes("right", size="5%", pad=0.05)

plt.colorbar(im, cax=cax)

16 changes: 8 additions & 8 deletions examples/axes_grid1/simple_rgb.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,25 @@

from mpl_toolkits.axes_grid1.axes_rgb import RGBAxes


def get_demo_image():
import numpy as np
from matplotlib.cbook import get_sample_data
f = get_sample_data("axes_grid/bivariate_normal.npy", asfileobj=False)
z = np.load(f)
# z is a numpy array of 15x15
return z, (-3,4,-4,3)
return z, (-3, 4, -4, 3)


def get_rgb():
Z, extent = get_demo_image()

Z[Z<0] = 0.
Z = Z/Z.max()
Z[Z < 0] = 0.
Z = Z / Z.max()

R = Z[:13,:13]
G = Z[2:,2:]
B = Z[:13,2:]
R = Z[:13, :13]
G = Z[2:, 2:]
B = Z[:13, 2:]

return R, G, B

Expand All @@ -39,6 +41,4 @@ def get_rgb():
ax.RGB.set_xlim(0., 9.5)
ax.RGB.set_ylim(0.9, 10.6)


plt.draw()
plt.show()
1 change: 1 addition & 0 deletions examples/pylab_examples/ginput_manual_clabel_sgskip.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ def tellme(s):
for p in ph:
p.remove()


##################################################
# Now contour according to distance from triangle
# corners - just an example
Expand Down
2 changes: 0 additions & 2 deletions examples/user_interfaces/embedding_in_qt5_sgskip.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
may be distributed without limitation.
"""



from __future__ import unicode_literals
import sys
import os
Expand Down
8 changes: 3 additions & 5 deletions examples/userdemo/anchored_box01.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,11 @@
import matplotlib.pyplot as plt
from matplotlib.offsetbox import AnchoredText

fig=plt.figure(1, figsize=(3,3))
ax = plt.subplot(111)

fig, ax = plt.subplots(figsize=(3, 3))

at = AnchoredText("Figure 1a",
prop=dict(size=15), frameon=True,
loc=2,
)
prop=dict(size=15), frameon=True, loc=2)
at.patch.set_boxstyle("round,pad=0.,rounding_size=0.2")
ax.add_artist(at)

Expand Down
3 changes: 1 addition & 2 deletions examples/userdemo/anchored_box02.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@
import matplotlib.pyplot as plt
from mpl_toolkits.axes_grid1.anchored_artists import AnchoredDrawingArea

fig=plt.figure(1, figsize=(3,3))
ax = plt.subplot(111)

fig, ax = plt.subplots(figsize=(3, 3))

ada = AnchoredDrawingArea(40, 20, 0, 0,
loc=1, pad=0., frameon=False)
Expand Down
6 changes: 3 additions & 3 deletions examples/userdemo/anchored_box03.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
import matplotlib.pyplot as plt
from mpl_toolkits.axes_grid1.anchored_artists import AnchoredAuxTransformBox

fig=plt.figure(1, figsize=(3,3))
ax = plt.subplot(111)

fig, ax = plt.subplots(figsize=(3, 3))

box = AnchoredAuxTransformBox(ax.transData, loc=2)
el = Ellipse((0,0), width=0.1, height=0.4, angle=30) # in data coordinates!
el = Ellipse((0, 0), width=0.1, height=0.4, angle=30) # in data coordinates!
box.drawing_area.add_artist(el)

ax.add_artist(box)
Expand Down
13 changes: 6 additions & 7 deletions examples/userdemo/anchored_box04.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,22 @@
"""
from matplotlib.patches import Ellipse
import matplotlib.pyplot as plt
from matplotlib.offsetbox import AnchoredOffsetbox, TextArea, DrawingArea, HPacker
from matplotlib.offsetbox import (AnchoredOffsetbox, DrawingArea, HPacker,
TextArea)

fig=plt.figure(1, figsize=(3,3))
ax = plt.subplot(111)

fig, ax = plt.subplots(figsize=(3, 3))

box1 = TextArea(" Test : ", textprops=dict(color="k"))

box2 = DrawingArea(60, 20, 0, 0)
el1 = Ellipse((10, 10), width=16, height=5, angle=30, fc="r")
el2 = Ellipse((30, 10), width=16, height=5, angle=170, fc="g")
el3 = Ellipse((50, 10), width=16, height=5, angle=230, fc="b")
el2 = Ellipse((30, 10), width=16, height=5, angle=170, fc="g")
el3 = Ellipse((50, 10), width=16, height=5, angle=230, fc="b")
box2.add_artist(el1)
box2.add_artist(el2)
box2.add_artist(el3)


box = HPacker(children=[box1, box2],
align="center",
pad=0, sep=5)
Expand All @@ -34,7 +34,6 @@
borderpad=0.,
)


ax.add_artist(anchored_box)

fig.subplots_adjust(top=0.8)
Expand Down
Loading