Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 17947d1

Browse files
authored
Merge pull request #19882 from timhoffm/doc-plot-types
Use ax.set() for a more compact notation of styling in plot types docs
2 parents 660d4e7 + 9567fd6 commit 17947d1

File tree

19 files changed

+39
-66
lines changed

19 files changed

+39
-66
lines changed

plot_types/arrays/imshow.py

Lines changed: 2 additions & 2 deletions
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

Lines changed: 2 additions & 4 deletions
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

Lines changed: 3 additions & 4 deletions
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

Lines changed: 2 additions & 4 deletions
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

Lines changed: 3 additions & 4 deletions
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

Lines changed: 3 additions & 4 deletions
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

Lines changed: 3 additions & 4 deletions
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

Lines changed: 3 additions & 4 deletions
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

Lines changed: 2 additions & 4 deletions
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

Lines changed: 2 additions & 4 deletions
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()

0 commit comments

Comments
 (0)