From 4faac386a0a25298431ddb801d589cf8986d09ee Mon Sep 17 00:00:00 2001 From: Tim Hoffmann <2836374+timhoffm@users.noreply.github.com> Date: Wed, 23 Jun 2021 23:03:43 +0200 Subject: [PATCH] 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. --- plot_types/basic/pie.py | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/plot_types/basic/pie.py b/plot_types/basic/pie.py index 5af4ca91b8b9..9beb0d490dc2 100644 --- a/plot_types/basic/pie.py +++ b/plot_types/basic/pie.py @@ -5,7 +5,6 @@ See `~matplotlib.axes.Axes.pie`. """ -import matplotlib as mpl import matplotlib.pyplot as plt import numpy as np @@ -14,16 +13,12 @@ # make data X = [1, 2, 3, 4] -colors = np.zeros((len(X), 4)) -colors[:] = mpl.colors.to_rgba("C0") -colors[:, 3] = np.linspace(0.25, 0.75, len(X)) +colors = plt.get_cmap('Blues')(np.linspace(0.2, 0.7, len(X))) # plot fig, ax = plt.subplots() -ax.pie(X, colors=["white"]*len(X), radius=3, center=(4, 4), - wedgeprops={"linewidth": 1, "edgecolor": "white"}, frame=True) ax.pie(X, colors=colors, radius=3, center=(4, 4), - wedgeprops={"linewidth": 1, "edgecolor": "white"}, frame=True) + wedgeprops={"linewidth": 1, "edgecolor": "white"}, frame=True) ax.set(xlim=(0, 8), xticks=np.arange(1, 8), ylim=(0, 8), yticks=np.arange(1, 8))