8000 Cleanup polar_legend example. · matplotlib/matplotlib@83b3acd · GitHub
[go: up one dir, main page]

Skip to content

Commit 83b3acd

Browse files
committed
Cleanup polar_legend example.
1 parent 9affee4 commit 83b3acd

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

examples/pie_and_polar_charts/polar_legend.py

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,19 @@
99
import matplotlib.pyplot as plt
1010
import numpy as np
1111

12-
# radar green, solid grid lines
13-
plt.rc('grid', color='#316931', linewidth=1, linestyle='-')
14-
plt.rc('xtick', labelsize=15)
15-
plt.rc('ytick', labelsize=15)
16-
17-
# force square figure and square axes looks better for polar, IMO
18-
fig = plt.figure(figsize=(8, 8))
19-
ax = fig.add_axes([0.1, 0.1, 0.8, 0.8],
20-
projection='polar', facecolor='#d5de9c')
12+
fig = plt.figure()
13+
ax = fig.add_subplot(projection='polar', facecolor='#d5de9c')
2114

2215
r = np.arange(0, 3.0, 0.01)
2316
theta = 2 * np.pi * r
24-
ax.plot(theta, r, color='#ee8d18', lw=3, label='a line')
25-
ax.plot(0.5 * theta, r, color='blue', ls='--', lw=3, label='another line')
26-
ax.legend()
17+
ax.plot(theta, r, color='tab:orange', lw=3, label='a line')
18+
ax.plot(0.5 * theta, r, color='tab:blue', ls='--', lw=3, label='another line')
19+
ax.tick_params(grid_color='darkolivegreen')
20+
# For polar axes, it may be useful to move the legend slightly away from the
21+
# axes center, to avoid overlap between the legend and the axes. This can
22+
# be achieved by setting borderaxespad (the padding between the axes and the
23+
# legend, in fontsize units) to a negative value.
24+
ax.legend(borderaxespad=-2)
2725

2826
plt.show()
2927

0 commit comments

Comments
 (0)
0