Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Pep8ify examples #3425

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 21 commits into from
Sep 9, 2014
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
fix some pep8 issues overseen by autopep8
  • Loading branch information
twmr committed Aug 28, 2014
commit 1171a967c1d4b645b56b46523f072cc7721f2acb
3 changes: 2 additions & 1 deletion 3 examples/animation/double_pendulum_animated.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ def derivs(state, t):
del_ = state[2]-state[0]
den1 = (M1+M2)*L1 - M2*L1*cos(del_)*cos(del_)
dydx[1] = (M2*L1*state[1]*state[1]*sin(del_)*cos(del_)
+ M2*G*sin(state[2])*cos(del_) + M2*L2*state[3]*state[3]*sin(del_)
+ M2*G*sin(state[2])*cos(del_)
+ M2*L2*state[3]*state[3]*sin(del_)
- (M1+M2)*G*sin(state[0]))/den1

dydx[2] = state[3]
Expand Down
10 changes: 5 additions & 5 deletions 10 examples/animation/subplots.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
from matplotlib.lines import Line2D
import matplotlib.animation as animation

# This example uses subclassing, but there is no reason that the proper function
# couldn't be set up and then use FuncAnimation. The code is long, but not
# really complex. The length is due solely to the fact that there are a total
# of 9 lines that need to be changed for the animation as well as 3 subplots
# that need initial set up.
# This example uses subclassing, but there is no reason that the proper
# function couldn't be set up and then use FuncAnimation. The code is long, but
# not really complex. The length is due solely to the fact that there are a
# total of 9 lines that need to be changed for the animation as well as 3
# subplots that need initial set up.


Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spacing between important comments and its class (and another spurious blank line between the class declaration and its init below)

class SubplotAnimation(animation.TimedAnimation):
Expand Down
6 changes: 3 additions & 3 deletions 6 examples/api/date_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@
datemax = datetime.date(r.date.max().year + 1, 1, 1)
ax.set_xlim(datemin, datemax)

# format the coords message box


def price(x): return '$%1.2f' % x
# format the coords message box
def price(x):
return '$%1.2f' % x
ax.format_xdata = mdates.DateFormatter('%Y-%m-%d')
ax.format_ydata = price
ax.grid(True)
Expand Down
14 changes: 10 additions & 4 deletions 14 examples/api/logo2.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,14 @@ def add_math_background():

text = []
text.append(
(r"$W^{3\beta}_{\delta_1 \rho_1 \sigma_2} = U^{3\beta}_{\delta_1 \rho_1} + \frac{1}{8 \pi 2} \int^{\alpha_2}_{\alpha_2} d \alpha^\prime_2 \left[\frac{ U^{2\beta}_{\delta_1 \rho_1} - \alpha^\prime_2U^{1\beta}_{\rho_1 \sigma_2} }{U^{0\beta}_{\rho_1 \sigma_2}}\right]$", (0.7, 0.2), 20))
text.append((r"$\frac{d\rho}{d t} + \rho \vec{v}\cdot\nabla\vec{v} = -\nabla p + \mu\nabla^2 \vec{v} + \rho \vec{g}$",
(r"$W^{3\beta}_{\delta_1 \rho_1 \sigma_2} = "
r"U^{3\beta}_{\delta_1 \rho_1} + \frac{1}{8 \pi 2}"
r"\int^{\alpha_2}_{\alpha_2} d \alpha^\prime_2 "
r"\left[\frac{ U^{2\beta}_{\delta_1 \rho_1} - "
r"\alpha^\prime_2U^{1\beta}_{\rho_1 \sigma_2} "
r"}{U^{0\beta}_{\rho_1 \sigma_2}}\right]$", (0.7, 0.2), 20))
text.append((r"$\frac{d\rho}{d t} + \rho \vec{v}\cdot\nabla\vec{v} "
r"= -\nabla p + \mu\nabla^2 \vec{v} + \rho \vec{g}$",
(0.35, 0.9), 20))
text.append((r"$\int_{-\infty}^\infty e^{-x^2}dx=\sqrt{\pi}$",
(0.15, 0.3), 25))
Expand All @@ -36,8 +42,8 @@ def add_math_background():
text.append((r"$F_G = G\frac{m_1m_2}{r^2}$",
(0.85, 0.7), 30))
for eq, (x, y), size in text:
ax.text(x, y, eq, ha='center', va='center', color="#11557c", alpha=0.25,
transform=ax.transAxes, fontsize=size)
ax.text(x, y, eq, ha='center', va='center', color="#11557c",
alpha=0.25, transform=ax.transAxes, fontsize=size)
ax.set_axis_off()
return ax

Expand Down
9 changes: 3 additions & 6 deletions 9 examples/api/mathtext_asarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,15 @@
Load a mathtext image as numpy array
"""

import numpy as np
import matplotlib.mathtext as mathtext
import matplotlib.pyplot as plt
import matplotlib
matplotlib.rc('image', origin='upper')

parser = mathtext.MathTextParser("Bitmap")


parser.to_png(
'test2.png', r'$\left[\left\lfloor\frac{5}{\frac{\left(3\right)}{4}} y\right)\right]$', color='green', fontsize=14, dpi=100)

parser.to_png('test2.png',
r'$\left[\left\lfloor\frac{5}{\frac{\left(3\right)}{4}} '
r'y\right)\right]$', color='green', fontsize=14, dpi=100)

rgba1, depth1 = parser.to_rgba(
r'IQ: $\sigma_i=15$', color='blue', fontsize=20, dpi=200)
Expand Down
9 changes: 5 additions & 4 deletions 9 examples/api/radar_chart.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,11 @@ def example_data():
# The following data is from the Denver Aerosol Sources and Health study.
# See doi:10.1016/j.atmosenv.2008.12.017
#
# The data are pollution source profile estimates for five modeled pollution
# sources (e.g., cars, wood-burning, etc) that emit 7-9 chemical species.
# The radar charts are experimented with here to see if we can nicely
# visualize how the modeled source profiles change across four scenarios:
# The data are pollution source profile estimates for five modeled
# pollution sources (e.g., cars, wood-burning, etc) that emit 7-9 chemical
# species. The radar charts are experimented with here to see if we can
# nicely visualize how the modeled source profiles change across four
# scenarios:
# 1) No gas-phase species present, just seven particulate counts on
# Sulfate
# Nitrate
Expand Down
10 changes: 6 additions & 4 deletions 10 examples/api/sankey_demo_rankine.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
"""Demonstrate the Sankey class with a practicle example of a Rankine power cycle.
"""Demonstrate the Sankey class with a practicle example of a Rankine power
cycle.

"""
import numpy as np
import matplotlib.pyplot as plt

from matplotlib.sankey import Sankey

fig = plt.figure(figsize=(8, 9))
ax = fig.add_subplot(1, 1, 1, xticks=[], yticks=[],
title="Rankine Power Cycle: Example 8.6 from Moran and Shapiro\n"
+ "\x22Fundamentals of Engineering Thermodynamics\x22, 6th ed., 2008")
title="Rankine Power Cycle: Example 8.6 from Moran and "
"Shapiro\n\x22Fundamentals of Engineering Thermodynamics "
"\x22, 6th ed., 2008")
Hdot = [260.431, 35.078, 180.794, 221.115, 22.700,
142.361, 10.193, 10.210, 43.670, 44.312,
68.631, 10.758, 10.758, 0.017, 0.642,
Expand Down
8 changes: 4 additions & 4 deletions 8 examples/api/skewt.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,8 @@ def _set_lim_and_transforms(self):
# coordinates thus performing the transform around the proper origin
# We keep the pre-transAxes transform around for other users, like the
# spines for finding bounds
self.transDataToAxes = self.transScale + (self.transLimits +
transforms.Affine2D().skew_deg(rot, 0))
self.transDataToAxes = self.transScale + \
self.transLimits + transforms.Affine2D().skew_deg(rot, 0)

# Create the full transform from Data to Pixels
self.transData = self.transDataToAxes + self.transAxes
Expand All @@ -148,7 +148,6 @@ def _set_lim_and_transforms(self):
if __name__ == '__main__':
# Now make a simple example using the custom projection.
from matplotlib.ticker import ScalarFormatter, MultipleLocator
from matplotlib.collections import LineCollection
import matplotlib.pyplot as plt
from StringIO import StringIO
import numpy as np
Expand Down Expand Up @@ -227,7 +226,8 @@ def _set_lim_and_transforms(self):
107.8 15850 -64.1 -75.1 21 0.01 265 58 395.0 395.1 395.0
105.0 16010 -64.7 -75.7 21 0.01 272 50 396.9 396.9 396.9
103.0 16128 -62.9 -73.9 21 0.02 277 45 402.5 402.6 402.5
100.0 16310 -62.5 -73.5 21 0.02 285 36 406.7 406.8 406.7'''
100.0 16310 -62.5 -73.5 21 0.02 285 36 406.7 406.8 406.7
'''

# Parse the data
sound_data = StringIO(data_txt)
Expand Down
10 changes: 4 additions & 6 deletions 10 examples/axes_grid/demo_axes_divider.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,27 +97,25 @@ def demo():
fig1 = plt.figure(1, (6, 6))
fig1.clf()

## PLOT 1
# PLOT 1
# simple image & colorbar
ax = fig1.add_subplot(2, 2, 1)
demo_simple_image(ax)

## PLOT 2
# PLOT 2
# image and colorbar whose location is adjusted in the drawing time.
# a hard way

demo_locatable_axes_hard(fig1)


## PLOT 3
# PLOT 3
# image and colorbar whose location is adjusted in the drawing time.
# a easy way

ax = fig1.add_subplot(2, 2, 3)
demo_locatable_axes_easy(ax)


## PLOT 4
# PLOT 4
# two images side by side with fixed padding.

ax = fig1.add_subplot(2, 2, 4)
Expand Down
5 changes: 2 additions & 3 deletions 5 examples/axes_grid/demo_curvelinear_grid.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import numpy as np
#from matplotlib.path import Path

import matplotlib.pyplot as plt
import matplotlib.cbook as cbook

from mpl_toolkits.axisartist.grid_helper_curvelinear import GridHelperCurveLinear
from mpl_toolkits.axisartist import Subplot

from mpl_toolkits.axisartist import SubplotHost, \
ParasiteAxesAuxTrans
from mpl_toolkits.axisartist.grid_helper_curvelinear import \
GridHelperCurveLinear


def curvelinear_test1(fig):
Expand Down
5 changes: 2 additions & 3 deletions 5 examples/axes_grid/demo_curvelinear_grid2.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import numpy as np
#from matplotlib.path import Path

import matplotlib.pyplot as plt

from mpl_toolkits.axes_grid.grid_helper_curvelinear import GridHelperCurveLinear
from mpl_toolkits.axes_grid.grid_helper_curvelinear import \
GridHelperCurveLinear
from mpl_toolkits.axes_grid.axislines import Subplot

import mpl_toolkits.axes_grid.angle_helper as angle_helper
Expand Down
32 changes: 13 additions & 19 deletions 32 examples/axes_grid/demo_floating_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,6 @@ def setup_axes2(fig, rect):
With custom locator and formatter.
Note that the extreme values are swapped.
"""

#tr_scale = Affine2D().scale(np.pi/180., 1.)

tr = PolarAxes.PolarTransform()

pi = np.pi
Expand All @@ -48,13 +45,12 @@ def setup_axes2(fig, rect):

grid_locator2 = MaxNLocator(2)

grid_helper = floating_axes.GridHelperCurveLinear(tr,
extremes=(.5*pi, 0, 2, 1),
grid_locator1=grid_locator1,
grid_locator2=grid_locator2,
tick_formatter1=tick_formatter1,
tick_formatter2=None,
)
grid_helper = floating_axes.GridHelperCurveLinear(
tr, extremes=(.5*pi, 0, 2, 1),
grid_locator1=grid_locator1,
grid_locator2=grid_locator2,
tick_formatter1=tick_formatter1,
tick_formatter2=None)

ax1 = floating_axes.FloatingSubplot(fig, rect, grid_helper=grid_helper)
fig.add_subplot(ax1)
Expand Down Expand Up @@ -91,14 +87,12 @@ def setup_axes3(fig, rect):

ra0, ra1 = 8.*15, 14.*15
cz0, cz1 = 0, 14000
grid_helper = floating_axes.GridHelperCurveLinear(tr,
extremes=(
ra0, ra1, cz0, cz1),
grid_locator1=grid_locator1,
grid_locator2=grid_locator2,
tick_formatter1=tick_formatter1,
tick_formatter2=None,
)
grid_helper = floating_axes.GridHelperCurveLinear(
tr, extremes=(ra0, ra1, cz0, cz1),
grid_locator1=grid_locator1,
grid_locator2=grid_locator2,
tick_formatter1=tick_formatter1,
tick_formatter2=None)

ax1 = floating_axes.FloatingSubplot(fig, rect, grid_helper=grid_helper)
fig.add_subplot(ax1)
Expand Down Expand Up @@ -138,7 +132,7 @@ def setup_axes3(fig, rect):

# theta = np.random.rand(10) #*.5*np.pi
# radius = np.random.rand(10) #+1.
#aux_ax1.scatter(theta, radius)
# aux_ax1.scatter(theta, radius)

ax2, aux_ax2 = setup_axes2(fig, 132)

Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.