Skip to content

Commit 71d319e

Browse files
committed
Use ax.set() for a more compact notation of styling in plot types docs
1 parent 07fd38f commit 71d319e

19 files changed

+39
-66
lines changed

plot_types/arrays/imshow.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,6 @@
2121
ax.imshow(Z, extent=[0, 8, 0, 8], interpolation="nearest",
2222
cmap=plt.get_cmap('Blues'), vmin=0, vmax=1.6)
2323

24-
ax.set_xticks([])
25-
ax.set_yticks([])
24+
ax.set(xticks=[], yticks=[])
25+
2626
plt.show()

plot_types/arrays/quiver.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,7 @@
1919
plt.quiver(X, Y, U, V, color="C0", angles='xy',
2020
scale_units='xy', scale=0.5, width=.05)
2121

22-
ax.set_xlim(0, 8)
23-
ax.set_xticks(np.arange(1, 8))
24-
ax.set_ylim(0, 8)
25-
ax.set_yticks(np.arange(1, 8))
22+
ax.set(xlim=(0, 8), xticks=np.arange(1, 8),
23+
ylim=(0, 8), yticks=np.arange(1, 8))
2624

2725
plt.show()

plot_types/basic/bar.py

+3-4
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@
1717

1818
ax.bar(X, Y, width=1, edgecolor="white", linewidth=0.7)
1919

20-
ax.set_xlim(0, 8)
21-
ax.set_xticks(np.arange(1, 8))
22-
ax.set_ylim(0, 8)
23-
ax.set_yticks(np.arange(1, 8))
20+
ax.set(xlim=(0, 8), xticks=np.arange(1, 8),
21+
ylim=(0, 8), yticks=np.arange(1, 8))
22+
2423
plt.show()

plot_types/basic/pie.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,7 @@
2323
ax.pie(X, colors=colors, radius=3, center=(4, 4),
2424
wedgeprops={"linewidth": 1, "edgecolor": "white"}, frame=True)
2525

26-
ax.set_xlim(0, 8)
27-
ax.set_xticks(np.arange(1, 8))
28-
ax.set_ylim(0, 8)
29-
ax.set_yticks(np.arange(1, 8))
26+
ax.set(xlim=(0, 8), xticks=np.arange(1, 8),
27+
ylim=(0, 8), yticks=np.arange(1, 8))
3028

3129
plt.show()

plot_types/basic/plot.py

+3-4
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@
1818

1919
ax.plot(X, Y, linewidth=2.0)
2020

21-
ax.set_xlim(0, 8)
22-
ax.set_xticks(np.arange(1, 8))
23-
ax.set_ylim(0, 8)
24-
ax.set_yticks(np.arange(1, 8))
21+
ax.set(xlim=(0, 8), xticks=np.arange(1, 8),
22+
ylim=(0, 8), yticks=np.arange(1, 8))
23+
2524
plt.show()

plot_types/basic/scatter_plot.py

+3-4
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@
2020

2121
ax.scatter(X, Y, s=S, c=-S, cmap=plt.get_cmap('Blues'), vmin=-100, vmax=0)
2222

23-
ax.set_xlim(0, 8)
24-
ax.set_xticks(np.arange(1, 8))
25-
ax.set_ylim(0, 8)
26-
ax.set_yticks(np.arange(1, 8))
23+
ax.set(xlim=(0, 8), xticks=np.arange(1, 8),
24+
ylim=(0, 8), yticks=np.arange(1, 8))
25+
2726
plt.show()

plot_types/basic/stem.py

+3-4
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@
1818

1919
ax.stem(X, Y, bottom=0, linefmt="-", markerfmt="d")
2020

21-
ax.set_xlim(0, 8)
22-
ax.set_xticks(np.arange(1, 8))
23-
ax.set_ylim(0, 8)
24-
ax.set_yticks(np.arange(1, 8))
21+
ax.set(xlim=(0, 8), xticks=np.arange(1, 8),
22+
ylim=(0, 8), yticks=np.arange(1, 8))
23+
2524
plt.show()

plot_types/basic/step.py

+3-4
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@
1818

1919
ax.step(X, Y, linewidth=2.5)
2020

21-
ax.set_xlim(0, 8)
22-
ax.set_xticks(np.arange(1, 8))
23-
ax.set_ylim(0, 8)
24-
ax.set_yticks(np.arange(1, 8))
21+
ax.set(xlim=(0, 8), xticks=np.arange(1, 8),
22+
ylim=(0, 8), yticks=np.arange(1, 8))
23+
2524
plt.show()

plot_types/stats/barbs.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,7 @@
2121
ax.barbs(X, Y, U, V, barbcolor="C0", flagcolor="C0",
2222
length=10, linewidth=1.5)
2323

24-
ax.set_xlim(0, 8)
25-
ax.set_xticks(np.arange(1, 8))
26-
ax.set_ylim(0, 8)
27-
ax.set_yticks(np.arange(1, 8))
24+
ax.set(xlim=(0, 8), xticks=np.arange(1, 8),
25+
ylim=(0, 8), yticks=np.arange(1, 8))
2826

2927
plt.show()

plot_types/stats/boxplot_plot.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,7 @@
2222
whiskerprops={"color": "C0", "linewidth": 1.5},
2323
capprops={"color": "C0", "linewidth": 1.5})
2424

25-
ax.set_xlim(0, 8)
26-
ax.set_xticks(np.arange(1, 8))
27-
ax.set_ylim(0, 8)
28-
ax.set_yticks(np.arange(1, 8))
25+
ax.set(xlim=(0, 8), xticks=np.arange(1, 8),
26+
ylim=(0, 8), yticks=np.arange(1, 8))
2927

3028
plt.show()

plot_types/stats/errorbar_plot.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,7 @@
1919

2020
ax.errorbar(X, Y, E, linewidth=2, capsize=6)
2121

22-
ax.set_xlim(0, 8)
23-
ax.set_xticks(np.arange(1, 8))
24-
ax.set_ylim(0, 8)
25-
ax.set_yticks(np.arange(1, 8))
22+
ax.set(xlim=(0, 8), xticks=np.arange(1, 8),
23+
ylim=(0, 8), yticks=np.arange(1, 8))
2624

2725
plt.show()

plot_types/stats/eventplot.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,7 @@
1818

1919
ax.eventplot(D, orientation="vertical", lineoffsets=X, linewidth=0.75)
2020

21-
ax.set_xlim(0, 8)
22-
ax.set_xticks(np.arange(1, 8))
23-
ax.set_ylim(0, 8)
24-
ax.set_yticks(np.arange(1, 8))
21+
ax.set(xlim=(0, 8), xticks=np.arange(1, 8),
22+
ylim=(0, 8), yticks=np.arange(1, 8))
2523

2624
plt.show()

plot_types/stats/hexbin.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818

1919
ax.hexbin(x, y, gridsize=20)
2020

21-
ax.set_xlim(-2, 2)
22-
ax.set_ylim(-3, 3)
21+
ax.set(xlim=(-2, 2), ylim=(-3, 3))
2322

2423
plt.show()

plot_types/stats/hist2d.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818

1919
ax.hist2d(x, y, bins=(np.arange(-3, 3, 0.1), np.arange(-3, 3, 0.1)))
2020

21-
ax.set_xlim(-2, 2)
22-
ax.set_ylim(-3, 3)
21+
ax.set(xlim=(-2, 2), ylim=(-3, 3))
2322

2423
plt.show()

plot_types/stats/hist_plot.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,7 @@
1717

1818
ax.hist(X, bins=8, linewidth=0.5, edgecolor="white")
1919

20-
ax.set_xlim(0, 8)
21-
ax.set_xticks(np.arange(1, 8))
22-
ax.set_ylim(0, 80)
23-
ax.set_yticks(np.arange(1, 80, 10))
20+
ax.set(xlim=(0, 8), xticks=np.arange(1, 8),
21+
ylim=(0, 8), yticks=np.arange(1, 8))
2422

2523
plt.show()

plot_types/stats/violin.py

+3-6
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,10 @@
1717

1818
VP = ax.violinplot(D, [2, 4, 6], widths=2,
1919
showmeans=False, showmedians=False, showextrema=False)
20-
#style:
20+
# styling:
2121
for body in VP['bodies']:
2222
body.set_alpha(0.9)
23-
24-
ax.set_xlim(0, 8)
25-
ax.set_xticks(np.arange(1, 8))
26-
ax.set_ylim(0, 8)
27-
ax.set_yticks(np.arange(1, 8))
23+
ax.set(xlim=(0, 8), xticks=np.arange(1, 8),
24+
ylim=(0, 8), yticks=np.arange(1, 8))
2825

2926
plt.show()

plot_types/unstructured/tricontour.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
levs = np.linspace(np.min(Z), np.max(Z), 7)
2929
ax.tricontourf(x, y, z, levels=levs)
3030

31-
ax.set_xlim(-3, 3)
32-
ax.set_ylim(-3, 3)
31+
ax.set(xlim=(-3, 3), ylim=(-3, 3))
3332

3433
plt.show()

plot_types/unstructured/tripcolor.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
ax.plot(x, y, '.k', alpha=0.5)
2828
ax.tripcolor(x, y, z)
2929

30-
ax.set_xlim(-3, 3)
31-
ax.set_ylim(-3, 3)
30+
ax.set(xlim=(-3, 3), ylim=(-3, 3))
3231

3332
plt.show()

plot_types/unstructured/triplot.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323

2424
ax.triplot(x, y)
2525

26-
ax.set_xlim(-3, 3)
27-
ax.set_ylim(-3, 3)
26+
ax.set(xlim=(-3, 3), ylim=(-3, 3))
2827

2928
plt.show()

0 commit comments

Comments
 (0)