Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit d46c524

Browse files
Merge pull request avinashkranjan#542 from ELITA04/enhance_data_visualization
Enhancing Data Visualization Scripts avinashkranjan#515
2 parents e7eec08 + e636fee commit d46c524

File tree

20 files changed

+236
-73
lines changed

20 files changed

+236
-73
lines changed

‎Data-Visualization/Bar Plotting/program.py‎

Lines changed: 0 additions & 14 deletions
This file was deleted.
10.3 KB
Loading[フレーム]
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
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+
text = y,
17+
textposition='outside',
18+
marker_color='indianred',
19+
hovertemplate = "%{x} : %{y} <extra></extra>",
20+
showlegend = False,
21+
))
22+
23+
# Modifying the tickangle of the xaxis, and adjusting width and height of the image
24+
fig.layout.template = 'plotly_dark'
25+
#Hiding y-axis labels
26+
layout_yaxis_visible = False
27+
layout_yaxis_showticklabels = False
28+
fig.update_layout(
29+
xaxis_title = 'X Axis Title',
30+
yaxis_title = 'Y Axis Title',
31+
xaxis_tickangle = -45,
32+
autosize=False,
33+
width=600,
34+
height=600,
35+
margin=dict(l=50, r=50, b=100, t=100, pad=4)
36+
)
37+
# Removing the background grid and the Y-axis labels
38+
fig.update_yaxes(showgrid = False, showticklabels = False)
39+
40+
fig.show()
41+
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)

AltStyle によって変換されたページ (->オリジナル) /