forked from avinashkranjan/Amazing-Python-Scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpie_chart.py
More file actions
28 lines (23 loc) · 680 Bytes
/
pie_chart.py
File metadata and controls
28 lines (23 loc) · 680 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import plotly.graph_objects as go
import numpy as np
np.random.seed(42)
# declaring size of arr
size = 7
x = [f'Product {i}' for i in range(size)]
y = np.random.randint(low=0, high=100, size=size)
# creating a Pie Chart
fig = go.Figure(data=[go.Pie(labels=x, values=y)])
# Adjusting width and height of the image
fig.layout.template = 'plotly_dark'
# To display labels with the percentage
fig.update_traces(textposition='inside', textinfo='percent+label')
fig.update_layout(
title='Pie Chart',
xaxis_title='X Axis Title',
yaxis_title='Y Axis Title',
autosize=False,
width=600,
height=600,
margin=dict(l=50, r=50, b=100, t=100, pad=4)
)
fig.show()