Skip to content

Commit 1bece29

Browse files
committed
Used Plotly for Data Visualization. Issue avinashkranjan#515
1 parent a123ce7 commit 1bece29

20 files changed

Lines changed: 227 additions & 73 deletions

File tree

Data-Visualization/Bar Plotting/program.py

Lines changed: 0 additions & 14 deletions
This file was deleted.
12.9 KB
Loading
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import plotly.graph_objects as go
2+
import numpy as np
3+
4+
np.random.seed(42)
5+
6+
# declaring size of arr
7+
size = 7
8+
9+
x = [f'Product {i}' for i in range(size)]
10+
y = np.random.randint(low = 0, high = 100, size=size)
11+
12+
# creating the Bar Chart
13+
fig = go.Figure(go.Bar(
14+
x = x,
15+
y = y,
16+
marker_color='indianred',
17+
hovertemplate = "%{x} : %{y} <extra></extra>",
18+
showlegend = False
19+
))
20+
21+
# Modifying the tickangle of the xaxis, and adjusting width and height of the image
22+
fig.layout.template = 'plotly_dark'
23+
fig.update_layout(
24+
title = 'Bar Chart',
25+
xaxis_title = 'X Axis Title',
26+
yaxis_title = 'Y Axis Title',
27+
xaxis_tickangle = -45,
28+
autosize=False,
29+
width=600,
30+
height=600,
31+
margin=dict(l=50, r=50, b=100, t=100, pad=4)
32+
)
33+
fig.show()
34+
14.8 KB
Loading
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import plotly.graph_objects as go
2+
import numpy as np
3+
4+
np.random.seed(1)
5+
6+
# declaring size of arr
7+
size = 10
8+
size_arr = np.random.randint(low = 50, high = 600, size=size)
9+
10+
x = np.random.randint(low = 0, high = 30, size=size)
11+
y = np.random.randint(low = 0, high = 20, size=size)
12+
13+
fig = go.Figure(data=[go.Scatter(
14+
x = x,
15+
y = y,
16+
mode='markers',
17+
marker=dict(
18+
size=size_arr,
19+
sizemode='area',
20+
sizeref=2.*max(size_arr)/(40.**2),
21+
sizemin=4
22+
),
23+
hovertemplate = " x : %{x} <br> y : %{y} <br>"
24+
)])
25+
26+
# Adjusting width and height of the image
27+
fig.layout.template = 'plotly_dark'
28+
fig.update_layout(
29+
title = 'Bubble Chart',
30+
xaxis_title = 'X Axis Title',
31+
yaxis_title = 'Y Axis Title',
32+
autosize=False,
33+
width=600,
34+
height=600,
35+
margin=dict(l=50, r=50, b=100, t=100, pad=4)
36+
)
37+
38+
39+
fig.show()
19.6 KB
Loading
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import plotly.express as px
2+
import numpy as np
3+
4+
np.random.seed(42)
5+
6+
# declaring the size of an array
7+
rows = 5
8+
columns = 3
9+
10+
data = np.random.randint(low = 0, high = 50, size=(columns, rows))
11+
12+
fig = px.imshow(data,
13+
labels=dict(x="X Axis Title", y="Y Axis Title", color="Productivity"),
14+
x=[f'Product {i}' for i in range(rows)],
15+
y=[f'Type {i}' for i in range(columns)],
16+
)
17+
18+
# Modifying the tickangle of the xaxis, and adjusting width and height of the image
19+
fig.layout.template = 'plotly_dark'
20+
fig.update_xaxes(side="top")
21+
fig.update_layout(
22+
title = 'Heat Map ',
23+
xaxis_tickangle = -45,
24+
autosize=False,
25+
width=600,
26+
height=600,
27+
margin=dict(l=50, r=50, b=100, t=100, pad=4)
28+
)
29+
fig.show()

Data-Visualization/Histogram Plotting/program.py

Lines changed: 0 additions & 12 deletions
This file was deleted.
8.59 KB
Loading
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import plotly.express as px
2+
import numpy as np
3+
4+
np.random.seed(0)
5+
6+
# declaring size of arr
7+
size = 50
8+
9+
data = np.random.randint(low = 0, high = 150, size=size)
10+
# create the bins
11+
fig = px.histogram(x = data, labels={'x': 'data', 'y':'count'})
12+
13+
fig.layout.template = 'plotly_dark'
14+
fig.update_layout(
15+
title = 'Histogram',
16+
xaxis_title = 'X Axis Title',
17+
yaxis_title = 'Y Axis Title',
18+
autosize=False,
19+
width=600,
20+
height=600,
21+
margin=dict(l=50, r=50, b=100, t=100, pad=4)
22+
)
23+
fig.show()

0 commit comments

Comments
 (0)