Skip to content

Commit

Permalink
Pie chart can now be set with or without a hole
Browse files Browse the repository at this point in the history
  • Loading branch information
Kartmaan committed Nov 16, 2022
1 parent fc016b5 commit 2ef2f84
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions plotly_intervals.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ def plot_intervals(series, title='', x_label='', y_label='',
higher_vals : an interval will be added for all values greater
than the last interval (default = False)
kind : plot kind, 'bar' for bar chart, 'pie' for pie chart
(default = 'bar')
kind : plot kind, 'bar' for bar chart, 'pie' for pie chart,
'pie_hole' for pie chart with hole. (default = 'bar')
grid : show grid True/False
(only for bar chart, default = False)
Expand Down Expand Up @@ -269,12 +269,19 @@ def plot_intervals(series, title='', x_label='', y_label='',
gridwidth=0.5)

# Pie chart
elif kind == 'pie':
fig = go.Figure(data=[go.Pie(
labels=x,
values=y,
hole=.5
)])
elif kind == 'pie' or kind == 'pie_hole':
if kind == 'pie':
fig = go.Figure(data=[go.Pie(
labels=x,
values=y,
)])

else:
fig = go.Figure(data=[go.Pie(
labels=x,
values=y,
hole=.5
)])

fig.update_layout(
title_text = f'{title}')
Expand Down

0 comments on commit 2ef2f84

Please sign in to comment.