-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy path3D_Trigonometric_Identities.py
31 lines (24 loc) · 1.02 KB
/
3D_Trigonometric_Identities.py
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
29
30
31
import numpy as np
import pandas as pd
import plotly.express as px
import plotly.graph_objects as go
# Define a range of angles
angles_degrees = np.linspace(0, 360, 360)
angles_radians = np.radians(angles_degrees)
# Calculate trigonometric functions
sin_values = np.sin(angles_radians)
cos_values = np.cos(angles_radians)
# Create a Pandas DataFrame to store the data
df = pd.DataFrame({'Angle (degrees)': angles_degrees, 'sin(theta)': sin_values, 'cos(theta)': cos_values})
# Create a scatter plot using Plotly Express
fig = px.scatter(df, x='Angle (degrees)', y=['sin(theta)', 'cos(theta)'], title='Trigonometric Identities')
# Create a line plot for the tangent identity
tan_values = np.tan(angles_radians)
fig.add_trace(go.Scatter(x=angles_degrees, y=tan_values, mode='lines', name='tan(theta)'))
# Customize the layout
fig.update_xaxes(title_text='Angle (degrees)')
fig.update_yaxes(title_text='Value')
fig.update_layout(legend_title_text='Trig Functions')
fig.update_traces(marker=dict(size=4))
# Show the interactive plot
fig.show()