Skip to content

Commit

Permalink
remove plot_piechart from plotbase
Browse files Browse the repository at this point in the history
  • Loading branch information
zm711 committed Oct 4, 2023
1 parent 3c53932 commit a9591c8
Showing 1 changed file with 1 addition and 43 deletions.
44 changes: 1 addition & 43 deletions src/spikeanalysis/plotbase.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Optional, Sequence
from typing import Optional
import matplotlib.pyplot as plt


Expand Down Expand Up @@ -43,45 +43,3 @@ def _set_kwargs(self, **kwargs):
if "figsize" in kwargs:
self.figsize = kwargs["figsize"]

def plot_piechart(self, wedges: Sequence, counts: Sequence, colors: Optional[Sequence] = None):
"""Plots a piechart"""

assert len(wedges) == len(counts), "each wedge needs a corresponding count"
assert not counts.index(0), "counts with 0 will display incorrectly"
assert counts[0] != 0, "counts with 0 will display incorrectly"
import numpy as np

if self.figsize[0] <= 10:
fontsize = 10
else:
fontsize = 14

f, ax = plt.subplots(figsize=self.figsize)

if colors is None:
colors = [
"#ff9999",
"#66b3ff",
"#99ff99",
"#FEC8D8",
"#ffcc99",
"#F6BF85",
"#B7ADED",
]

ax.pie(
counts,
labels=wedges,
autopct=lambda pct: "{:.1f}%\n(n={:d})".format(pct, int(np.round(pct / 100 * np.sum(counts)))),
shadow=False,
startangle=90,
colors=colors,
textprops={"fontsize": fontsize},
)
ax.axis("equal")
if self.title:
plt.title(self.title)
plt.tight_layout()
plt.figure(dpi=self.dpi)

plt.show()

0 comments on commit a9591c8

Please sign in to comment.