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 68f7e8c

Browse files
Exception Handling in Data Visualization
Signed-off-by: Mukesh Sai Madepalli <madepallimukesh@gmail.com>
1 parent 2717a2c commit 68f7e8c

File tree

1 file changed

+24
-19
lines changed

1 file changed

+24
-19
lines changed
Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,31 @@
11
import plotly.graph_objects as go
22
import numpy as np
33

4-
np.random.seed(42)
4+
def create_line_chart(x_data, y_data):
5+
fig = go.Figure(data=go.Scatter(x=x_data, y=y_data))
56

6-
# declaring size of arr
7-
size = 7
7+
# Modifying the tickangle of the xaxis, and adjusting width and height of the image
8+
fig.layout.template = 'plotly_dark'
9+
fig.update_layout(
10+
title='Line Chart',
11+
xaxis_title='X Axis Title',
12+
yaxis_title='Y Axis Title',
13+
xaxis_tickangle=-45,
14+
autosize=False,
15+
width=600,
16+
height=600,
17+
margin=dict(l=50, r=50, b=100, t=100, pad=4)
18+
)
19+
fig.show()
820

9-
x=np.arange(10)
10-
y=x**2
21+
if__name__=="__main__":
22+
np.random.seed(42)
1123

12-
fig = go.Figure(data=go.Scatter(x=x, y=x**2))
24+
# Generating sample data
25+
x_data = np.arange(10)
26+
y_data = x_data ** 2
1327

14-
# Modifying the tickangle of the xaxis, and adjusting width and height of the image
15-
fig.layout.template = 'plotly_dark'
16-
fig.update_layout(
17-
title='Line Chart',
18-
xaxis_title='X Axis Title',
19-
yaxis_title='Y Axis Title',
20-
xaxis_tickangle=-45,
21-
autosize=False,
22-
width=600,
23-
height=600,
24-
margin=dict(l=50, r=50, b=100, t=100, pad=4)
25-
)
26-
fig.show()
28+
try:
29+
create_line_chart(x_data, y_data)
30+
except Exception as e:
31+
print("An error occurred:", str(e))

0 commit comments

Comments
(0)

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