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

Commit c26b5c4

Browse filesBrowse files
authored
Merge pull request #96 from jimustafa/pep8
apply PEP-8 throughout the codebase
2 parents 798ee83 + 2398af6 commit c26b5c4
Copy full SHA for c26b5c4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Dismiss banner
Expand file treeCollapse file tree

43 files changed

+336
-278
lines changed

‎.flake8

Copy file name to clipboard
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[flake8]
2+
ignore = E20,E22,E501,E701,F401,W
3+
4+
[pep8]
5+
select = E12,E231,E241,E251,E26,E30

‎.pre-commit-config.yaml

Copy file name to clipboardExpand all lines: .pre-commit-config.yaml
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,7 @@ repos:
99
- id: check-yaml
1010
- id: end-of-file-fixer
1111
- id: trailing-whitespace
12+
- repo: https://github.com/pycqa/flake8
13+
rev: 4.0.1
14+
hooks:
15+
- id: flake8

‎docs/conf.py

Copy file name to clipboardExpand all lines: docs/conf.py
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
html_title = 'Visualization with Python'
66
project = "Matplotlib cheatsheets"
77
copyright = (
8-
f"2012 - {datetime.datetime.now().year} The Matplotlib development team"
9-
)
8+
f"2012 - {datetime.datetime.now().year} The Matplotlib development team"
9+
)
1010
author = "Matplotlib Developers"
1111

1212
# -- General configuration ---------------------------------------------------

‎logos/mpl-logos2.py

Copy file name to clipboardExpand all lines: logos/mpl-logos2.py
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ def make_logo(height_px, lw_bars, lw_grid, lw_border, rgrid, with_text=False):
155155

156156
return fig, ax
157157

158+
158159
##############################################################################
159160
# A large logo:
160161

‎requirements/requirements.in

Copy file name to clipboard
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1+
autopep8
12
bump2version
23
cartopy==0.19.0.post1
4+
flake8
35
matplotlib==3.4.2
6+
mpl-sphinx-theme
47
pdfx
58
pip-tools
69
pre-commit
710
scipy
811
sphinx
9-
mpl-sphinx-theme
1012

1113
--no-binary shapely

‎requirements/requirements.txt

Copy file name to clipboardExpand all lines: requirements/requirements.txt
+26-1Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# This file is autogenerated by pip-compile with python 3.9
2+
# This file is autogenerated by pip-compile
33
# To update, run:
44
#
55
# pip-compile requirements.in
@@ -10,6 +10,8 @@ alabaster==0.7.12
1010
# via sphinx
1111
appdirs==1.4.4
1212
# via virtualenv
13+
autopep8==1.6.0
14+
# via -r requirements.in
1315
babel==2.9.1
1416
# via sphinx
1517
beautifulsoup4==4.9.3
@@ -44,12 +46,20 @@ docutils==0.17.1
4446
# sphinx
4547
filelock==3.0.12
4648
# via virtualenv
49+
flake8==4.0.1
50+
# via -r requirements.in
4751
identify==2.2.2
4852
# via pre-commit
4953
idna==3.3
5054
# via requests
5155
imagesize==1.2.0
5256
# via sphinx
57+
importlib-metadata==4.2.0
58+
# via
59+
# flake8
60+
# pep517
61+
# pre-commit
62+
# virtualenv
5363
jinja2==3.0.2
5464
# via sphinx
5565
kiwisolver==1.3.1
@@ -58,6 +68,8 @@ markupsafe==2.0.1
5868
# via jinja2
5969
matplotlib==3.4.2
6070
# via -r requirements.in
71+
mccabe==0.6.1
72+
# via flake8
6173
mpl-sphinx-theme==0.0.6
6274
# via -r requirements.in
6375
nodeenv==1.5.0
@@ -81,10 +93,16 @@ pip-tools==6.1.0
8193
# via -r requirements.in
8294
pre-commit==2.11.1
8395
# via -r requirements.in
96+
pycodestyle==2.8.0
97+
# via
98+
# autopep8
99+
# flake8
84100
pycparser==2.20
85101
# via cffi
86102
pydata-sphinx-theme==0.7.1
87103
# via mpl-sphinx-theme
104+
pyflakes==2.4.0
105+
# via flake8
88106
pygments==2.10.0
89107
# via sphinx
90108
pyparsing==2.4.7
@@ -134,12 +152,19 @@ sphinxcontrib-serializinghtml==1.1.5
134152
# via sphinx
135153
toml==0.10.2
136154
# via
155+
# autopep8
137156
# pep517
138157
# pre-commit
158+
typing-extensions==4.0.0
159+
# via importlib-metadata
139160
urllib3==1.26.7
140161
# via requests
141162
virtualenv==20.4.3
142163
# via pre-commit
164+
zipp==3.6.0
165+
# via
166+
# importlib-metadata
167+
# pep517
143168

144169
# The following packages are considered to be unsafe in a requirements file:
145170
# pip

‎scripts/adjustements.py

Copy file name to clipboardExpand all lines: scripts/adjustements.py
+25-25Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -10,39 +10,39 @@
1010

1111

1212
fig = plt.figure(figsize=(4.25, 4.25 * 95/115))
13-
ax = fig.add_axes([0,0,1,1], frameon=False, aspect=1,
14-
xlim=(0-5,100+10), ylim=(-10,80+5), xticks=[], yticks=[])
13+
ax = fig.add_axes([0, 0, 1, 1], frameon=False, aspect=1,
14+
xlim=(0-5, 100+10), ylim=(-10, 80+5), xticks=[], yticks=[])
1515

1616

1717
box = mpatches.FancyBboxPatch(
18-
(0,0), 100, 83, mpatches.BoxStyle("Round", pad=0, rounding_size=2),
18+
(0, 0), 100, 83, mpatches.BoxStyle("Round", pad=0, rounding_size=2),
1919
linewidth=1., facecolor="0.9", edgecolor="black")
2020
ax.add_artist(box)
2121

2222
box = mpatches.FancyBboxPatch(
23-
(0,0), 100, 75, mpatches.BoxStyle("Round", pad=0, rounding_size=0),
23+
(0, 0), 100, 75, mpatches.BoxStyle("Round", pad=0, rounding_size=0),
2424
linewidth=1., facecolor="white", edgecolor="black")
2525
ax.add_artist(box)
2626

2727

2828
box = mpatches.Rectangle(
29-
(5,5), 45, 30, zorder=10,
29+
(5, 5), 45, 30, zorder=10,
3030
linewidth=1.0, facecolor="white", edgecolor="black")
3131
ax.add_artist(box)
3232

3333
box = mpatches.Rectangle(
34-
(5,40), 45, 30, zorder=10,
34+
(5, 40), 45, 30, zorder=10,
3535
linewidth=1.0, facecolor="white", edgecolor="black")
3636
ax.add_artist(box)
3737

3838
box = mpatches.Rectangle(
39-
(55,5), 40, 65, zorder=10,
39+
(55, 5), 40, 65, zorder=10,
4040
linewidth=1.0, facecolor="white", edgecolor="black")
4141
ax.add_artist(box)
4242

4343
# Window button
44-
X, Y = [5,10,15], [79,79,79]
45-
plt.scatter(X, Y, s=75, zorder=10,
44+
X, Y = [5, 10, 15], [79, 79, 79]
45+
plt.scatter(X, Y, s=75, zorder=10,
4646
edgecolor="black", facecolor="white", linewidth=1)
4747

4848

@@ -60,7 +60,7 @@
6060
plt.plot(X, Y, color="black", linestyle=":", linewidth=1, clip_on=False)
6161

6262

63-
def ext_arrow(p0,p1,p2,p3):
63+
def ext_arrow(p0, p1, p2, p3):
6464
p0, p1 = np.asarray(p0), np.asarray(p1)
6565
p2, p3 = np.asarray(p2), np.asarray(p3)
6666
ax.arrow(*p0, *(p1-p0), zorder=20, linewidth=0,
@@ -69,9 +69,10 @@ def ext_arrow(p0,p1,p2,p3):
6969
ax.arrow(*p3, *(p2-p3), zorder=20, linewidth=0,
7070
length_includes_head=True, width=.4,
7171
head_width=2, head_length=2, color="black")
72-
plt.plot([p1[0],p2[0]], [p1[1],p2[1]], linewidth=.9, color="black")
72+
plt.plot([p1[0], p2[0]], [p1[1], p2[1]], linewidth=.9, color="black")
7373

74-
def int_arrow(p0,p1):
74+
75+
def int_arrow(p0, p1):
7576
p0, p1 = np.asarray(p0), np.asarray(p1)
7677
ax.arrow(*((p0+p1)/2), *((p1-p0)/2), zorder=20, linewidth=0,
7778
length_includes_head=True, width=.4,
@@ -81,48 +82,47 @@ def int_arrow(p0,p1):
8182
head_width=2, head_length=2, color="black")
8283

8384

84-
8585
x = 0
8686
y = 10
87-
ext_arrow( (x-4,y), (x,y), (x+5,y), (x+9,y) )
87+
ext_arrow( (x-4, y), (x, y), (x+5, y), (x+9, y) )
8888
ax.text(x+9.5, y, "left", ha="left", va="center", size="x-small", zorder=20)
8989

9090
x += 50
91-
ext_arrow( (x-4,y), (x,y), (x+5,y), (x+9,y) )
91+
ext_arrow( (x-4, y), (x, y), (x+5, y), (x+9, y) )
9292
ax.text(x-4.5, y, "wspace", ha="right", va="center", size="x-small", zorder=20)
9393

9494
x += 45
95-
ext_arrow( (x-4,y), (x,y), (x+5,y), (x+9,y) )
95+
ext_arrow( (x-4, y), (x, y), (x+5, y), (x+9, y) )
9696
ax.text(x-4.5, y, "right", ha="right", va="center", size="x-small", zorder=20)
9797

9898
y = 0
9999
x = 25
100-
ext_arrow( (x,y-4), (x,y), (x,y+5), (x,y+9) )
100+
ext_arrow( (x, y-4), (x, y), (x, y+5), (x, y+9) )
101101
ax.text(x, y+9.5, "bottom", ha="center", va="bottom", size="x-small", zorder=20)
102102

103103
y += 35
104-
ext_arrow( (x,y-4), (x,y), (x,y+5), (x,y+9) )
104+
ext_arrow( (x, y-4), (x, y), (x, y+5), (x, y+9) )
105105
ax.text(x, y-4.5, "hspace", ha="center", va="top", size="x-small", zorder=20)
106106

107107
y += 35
108-
ext_arrow( (x,y-4), (x,y), (x,y+5), (x,y+9) )
108+
ext_arrow( (x, y-4), (x, y), (x, y+5), (x, y+9) )
109109
ax.text(x, y-4.5, "top", ha="center", va="top", size="x-small", zorder=20)
110110

111-
int_arrow((0,-5), (100,-5))
111+
int_arrow((0, -5), (100, -5))
112112
ax.text(50, -5, "figure width", backgroundcolor="white", zorder=30,
113113
ha="center", va="center", size="x-small")
114114

115-
int_arrow((105,0), (105,75))
115+
int_arrow((105, 0), (105, 75))
116116
ax.text(105, 75/2, "figure height", backgroundcolor="white", zorder=30,
117-
rotation = "vertical", ha="center", va="center", size="x-small")
117+
rotation="vertical", ha="center", va="center", size="x-small")
118118

119-
int_arrow((55,62.5), (95,62.5))
119+
int_arrow((55, 62.5), (95, 62.5))
120120
ax.text(75, 62.5, "axes width", backgroundcolor="white", zorder=30,
121121
ha="center", va="center", size="x-small")
122122

123-
int_arrow((62.5,5), (62.5,70))
123+
int_arrow((62.5, 5), (62.5, 70))
124124
ax.text(62.5, 35, "axes height", backgroundcolor="white", zorder=30,
125-
rotation = "vertical", ha="center", va="center", size="x-small")
125+
rotation="vertical", ha="center", va="center", size="x-small")
126126

127127

128128
plt.savefig("../figures/adjustments.pdf")

‎scripts/anatomy.py

Copy file name to clipboardExpand all lines: scripts/anatomy.py
+3-2Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ def minor_tick(x, pos):
2323
return ""
2424
return "%.2f" % x
2525

26+
2627
ax.xaxis.set_major_locator(MultipleLocator(1.000))
2728
ax.xaxis.set_minor_locator(AutoMinorLocator(4))
2829
ax.yaxis.set_major_locator(MultipleLocator(1.000))
@@ -124,13 +125,13 @@ def text(x, y, text):
124125

125126
color = '#000099'
126127
ax.annotate('Spines', xy=(4.0, 0.35), xytext=(3.3, 0.5), color=color,
127-
weight='regular', # fontsize="large", fontname="Yanone Kaffeesatz",
128+
weight='regular', # fontsize="large", fontname="Yanone Kaffeesatz",
128129
arrowprops=dict(arrowstyle='->',
129130
connectionstyle="arc3",
130131
color=color))
131132

132133
ax.annotate('', xy=(3.15, 0.0), xytext=(3.45, 0.45), color=color,
133-
weight='regular', # fontsize="large", fontname="Yanone Kaffeesatz",
134+
weight='regular', # fontsize="large", fontname="Yanone Kaffeesatz",
134135
arrowprops=dict(arrowstyle='->',
135136
connectionstyle="arc3",
136137
color=color))

‎scripts/animation.py

Copy file name to clipboardExpand all lines: scripts/animation.py
+5-1Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,15 @@
22
import matplotlib.pyplot as plt
33
import matplotlib.animation as animation
44

5-
T = np.linspace(0,2*np.pi,100)
5+
T = np.linspace(0, 2*np.pi, 100)
66
S = np.sin(T)
77
line, = plt.plot(T, S)
8+
9+
810
def animate(i):
911
line.set_ydata(np.sin(T+i/50))
12+
13+
1014
a=animation.FuncAnimation(
1115
plt.gcf(), animate, interval=5)
1216
# plt.show()

‎scripts/annotate.py

Copy file name to clipboardExpand all lines: scripts/annotate.py
+6-7Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,17 @@
77
import matplotlib.pyplot as plt
88

99

10-
fig = plt.figure(figsize=(6,1))
11-
#ax = plt.subplot(111, frameon=False, aspect=.1)
10+
fig = plt.figure(figsize=(6, 1))
11+
# ax = plt.subplot(111, frameon=False, aspect=.1)
1212
# b = 0.0
13-
ax = fig.add_axes([0,0,1,1], frameon=False, aspect=1)
13+
ax = fig.add_axes([0, 0, 1, 1], frameon=False, aspect=1)
1414

1515

16-
17-
plt.scatter([5.5],[0.75], s=100, c="k")
18-
plt.xlim(0,6), plt.ylim(0,1)
16+
plt.scatter([5.5], [0.75], s=100, c="k")
17+
plt.xlim(0, 6), plt.ylim(0, 1)
1918
plt.xticks([]), plt.yticks([])
2019

21-
plt.annotate("Annotation", (5.5,.75), (0.1,.75), size=16, va="center",
20+
plt.annotate("Annotation", (5.5, .75), (0.1, .75), size=16, va="center",
2221
arrowprops=dict(facecolor='black', shrink=0.05))
2322

2423
plt.text( 5.5, 0.6, "xy\nycoords", size=10, va="top", ha="center", color=".5")

‎scripts/annotation-arrow-styles.py

Copy file name to clipboardExpand all lines: scripts/annotation-arrow-styles.py
+5-2Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,18 @@
22
import matplotlib.patches as mpatches
33

44
styles = mpatches.ArrowStyle.get_styles()
5+
6+
57
def demo_con_style(ax, connectionstyle):
68
ax.text(.05, .95, connectionstyle.replace(",", ",\n"),
79
family="Source Code Pro",
810
transform=ax.transAxes, ha="left", va="top", size="x-small")
911

12+
1013
(fig, axes) = plt.subplots(5, 3, figsize=(4, 2.5), frameon=False)
1114
for ax in axes.flatten():
1215
ax.axis("off")
13-
for i,(ax,style) in enumerate(zip(axes.flatten(), mpatches.ArrowStyle.get_styles())):
16+
for i, (ax, style) in enumerate(zip(axes.flatten(), mpatches.ArrowStyle.get_styles())):
1417
x0, y0 = 0.8, 0.5
1518
x1, y1 = 0.2, 0.5
1619
ax.plot([x0, x1], [y0, y1], ".", color="0.25")
@@ -24,7 +27,7 @@ def demo_con_style(ax, connectionstyle):
2427
connectionstyle="arc3,rad=0"))
2528
ax.text( (x1+x0)/2, y0-0.2, style,
2629
transform=ax.transAxes,
27-
family = "Source Code Pro", ha="center", va="top")
30+
family="Source Code Pro", ha="center", va="top")
2831

2932
plt.savefig("../figures/annotation-arrow-styles.pdf")
3033
# plt.show()

‎scripts/annotation-connection-styles.py

Copy file name to clipboardExpand all lines: scripts/annotation-connection-styles.py
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import matplotlib.pyplot as plt
22

3+
34
def demo_con_style(ax, connectionstyle):
45
x1, y1 = 0.3, 0.2
56
x2, y2 = 0.8, 0.6
@@ -16,6 +17,7 @@ def demo_con_style(ax, connectionstyle):
1617
family="Source Code Pro",
1718
transform=ax.transAxes, ha="left", va="top", size="x-small")
1819

20+
1921
fig, axs = plt.subplots(3, 3, figsize=(5, 5))
2022
demo_con_style(axs[0, 0], "arc3,rad=0")
2123
demo_con_style(axs[0, 1], "arc3,rad=0.3")

‎scripts/basic-plots.py

Copy file name to clipboardExpand all lines: scripts/basic-plots.py
+4-4Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,10 @@
6868
# Basic imshow plot
6969
# -----------------------------------------------------------------------------
7070
np.random.seed(3)
71-
I = np.zeros((8, 8, 4))
72-
I[:,:] = mpl.colors.to_rgba("C1")
73-
I[...,3] = np.random.uniform(0.25, 1.0, (8, 8))
74-
ax.imshow(I, extent=[0, 8, 0, 8], interpolation="nearest")
71+
Z = np.zeros((8, 8, 4))
72+
Z[:, :] = mpl.colors.to_rgba("C1")
73+
Z[..., 3] = np.random.uniform(0.25, 1.0, (8, 8))
74+
ax.imshow(Z, extent=[0, 8, 0, 8], interpolation="nearest")
7575
ax.set_xlim(0, 8), ax.set_xticks(np.arange(1, 8))
7676
ax.set_ylim(0, 8), ax.set_yticks(np.arange(1, 8))
7777
ax.grid(linewidth=0.25, color="white")

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.