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

Skip to content

Commit 5723f4d

Browse files
committed
Simplify plot types pie()
Colors are not exactly the same, but solid colors are significantly simpler. Before, due to using transparency one had to draw a white pie below the original pie to prevent the grid from shining through.
1 parent 6f92db0 commit 5723f4d

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

plot_types/basic/pie.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,12 @@
1414

1515
# make data
1616
X = [1, 2, 3, 4]
17-
colors = np.zeros((len(X), 4))
18-
colors[:] = mpl.colors.to_rgba("C0")
19-
colors[:, 3] = np.linspace(0.25, 0.75, len(X))
17+
colors = plt.get_cmap('Blues')(np.linspace(0.2, 0.7, len(X)))
2018

2119
# plot
2220
fig, ax = plt.subplots()
23-
ax.pie(X, colors=["white"]*len(X), radius=3, center=(4, 4),
24-
wedgeprops={"linewidth": 1, "edgecolor": "white"}, frame=True)
2521
ax.pie(X, colors=colors, radius=3, center=(4, 4),
26-
wedgeprops={"linewidth": 1, "edgecolor": "white"}, frame=True)
22+
wedgeprops={"linewidth": 1, "edgecolor": "white"}, frame=True)
2723

2824
ax.set(xlim=(0, 8), xticks=np.arange(1, 8),
2925
ylim=(0, 8), yticks=np.arange(1, 8))

0 commit comments

Comments
 (0)