Skip to content

Commit 2398af6

Browse files
committed
fix formatting
- fix E12,E231,E241,E251,E26,E30 with autopep8 - fix the rest by hand
1 parent b0f3b17 commit 2398af6

39 files changed

+298
-276
lines changed

docs/conf.py

Lines 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

Lines 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

scripts/adjustements.py

Lines 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

Lines 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

Lines 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

Lines 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

Lines 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

Lines 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

Lines 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")

scripts/colorbar.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,16 @@
77
import matplotlib.pyplot as plt
88

99

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

1515
cmap = plt.get_cmap("Oranges")
16-
norm = mpl.colors.Normalize(vmin=0,vmax=1)
16+
norm = mpl.colors.Normalize(vmin=0, vmax=1)
1717
sm = plt.cm.ScalarMappable(cmap=cmap, norm=norm)
1818
sm.set_array([])
19-
plt.colorbar(sm, cax=ax, ticks=np.linspace(0,1,11),
19+
plt.colorbar(sm, cax=ax, ticks=np.linspace(0, 1, 11),
2020
orientation="horizontal")
2121

2222
plt.savefig("../figures/colorbar.pdf")

scripts/colormaps.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
figsize = 4.0, 0.25
66
fig = plt.figure(figsize=figsize)
7-
ax = fig.add_axes([0,0,1,1], frameon=False, aspect=1)
7+
ax = fig.add_axes([0, 0, 1, 1], frameon=False, aspect=1)
88
ymin, ymax= 0, 1
99
xmin, xmax = 0, figsize[0]/figsize[1]
1010

@@ -13,23 +13,23 @@
1313
cmaps = ('viridis', 'plasma', 'inferno', 'magma', 'cividis',
1414

1515
'PRGn', 'PiYG', 'RdYlGn', 'BrBG', 'RdGy', 'PuOr', 'RdBu',
16-
'RdYlBu', 'Spectral', 'coolwarm', 'bwr', 'seismic',
16+
'RdYlBu', 'Spectral', 'coolwarm', 'bwr', 'seismic',
1717

1818
'tab10', 'tab20', 'tab20b', 'tab20c',
1919
'Pastel1', 'Pastel2', 'Paired',
2020
'Set1', 'Set2', 'Set3', 'Accent', 'Dark2',
2121

22-
'Greys', 'Reds','Oranges', 'YlOrBr', 'YlOrRd', 'OrRd',
22+
'Greys', 'Reds', 'Oranges', 'YlOrBr', 'YlOrRd', 'OrRd',
2323
'PuRd', 'RdPu', 'BuPu', 'Purples', 'YlGnBu', 'Blues',
24-
'PuBu', 'GnBu', 'PuBuGn', 'BuGn','Greens', 'YlGn',
24+
'PuBu', 'GnBu', 'PuBuGn', 'BuGn', 'Greens', 'YlGn',
2525

2626
'bone', 'gray', 'pink', 'afmhot', 'hot', 'gist_heat', 'copper',
2727
'Wistia', 'autumn', 'summer', 'spring', 'cool', 'winter',
2828

2929
'twilight', 'twilight_shifted', 'hsv',
3030

3131
'terrain', 'ocean', 'gist_earth', 'cubehelix', 'rainbow'
32-
)
32+
)
3333

3434
for cmap in cmaps:
3535
n = 512
@@ -40,7 +40,7 @@
4040
if cmap in ['Pastel2', 'Accent', 'Dark2', 'Set2']: n = 8
4141
if cmap in ['Set3']: n = 12
4242
if cmap in ['Greys']: n = 11
43-
Z = np.linspace(0,1,n).reshape(1,n)
43+
Z = np.linspace(0, 1, n).reshape(1, n)
4444

4545
ax.imshow(Z, extent=[xmin, xmax, ymin, ymax], cmap=plt.get_cmap(cmap))
4646
ax.set_xlim(xmin, xmax), ax.set_xticks([])

scripts/colors.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
figsize = 4.0, 0.25
1111
fig = plt.figure(figsize=figsize)
12-
ax = fig.add_axes([0,0,1,1], frameon=False, aspect=1)
12+
ax = fig.add_axes([0, 0, 1, 1], frameon=False, aspect=1)
1313
ymin, ymax= 0, 1
1414
xmin, xmax = 0, figsize[0]/figsize[1]
1515
ax.set_xlim(xmin, xmax), ax.set_xticks([])
@@ -19,22 +19,22 @@
1919
# -----------------------------------------------------------------------------
2020
palettes = {
2121
'raw' : ['b', 'g', 'r', 'c', 'm', 'y', 'k', 'w'],
22-
'rgba' : [(1,0,0), (1,0,0,0.75), (1,0,0,0.50), (1,0,0,0.25)],
22+
'rgba' : [(1, 0, 0), (1, 0, 0, 0.75), (1, 0, 0, 0.50), (1, 0, 0, 0.25)],
2323
'HexRGBA' : ["#FF0000", "#FF0000BB", "#FF000088", "#FF000044"],
2424
'cycle' : ["C%d" % i for i in range(10)],
2525
'grey' : ["%1.1f" % (i/10) for i in range(11)],
2626
'name' : ["DarkRed", "Firebrick", "Crimson", "IndianRed", "Salmon" ] }
2727

2828
for name, colors in palettes.items():
29-
C = mpl.colors.to_rgba_array(colors).reshape((1,len(colors),4))
29+
C = mpl.colors.to_rgba_array(colors).reshape((1, len(colors), 4))
3030
ax.imshow(C, extent=[xmin, xmax, ymin, ymax])
3131
dx = (xmax-xmin)/len(colors)
3232
for i in range(len(colors)):
3333
color = "white"
3434
if colors[i] in ['1.0', 'w']: color = "black"
3535
text = str(colors[i]).replace(' ', '')
3636
ax.text((i+0.5)*dx, (ymin+ymax)/2, text, color=color, zorder=10,
37-
family = "Source Code Pro", size=9, ha="center", va="center")
37+
family="Source Code Pro", size=9, ha="center", va="center")
3838

3939
plt.savefig("../figures/colors-%s.pdf" % name)
4040
ax.clear()

0 commit comments

Comments
 (0)