Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions exercises/exercise_12_0_0_plotly.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import plotly.graph_objs as go

x = [0, 1]
y = [1, 0]

fig = go.Figure(data=go.Scatter(x=x, y=y, mode='lines'))

fig.show()
10 changes: 10 additions & 0 deletions exercises/exercise_12_0_1_plotly.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import plotly.graph_objs as go

x = [0, 1]
y = [1, 0]

fig = go.Figure(data=go.Scatter(x=x, y=y, mode='lines', line=dict(color='rgba(0, 128, 0, 0.4)', width=10), name="straight line"))

fig.update_layout(title="My first plot", showlegend=True, xaxis=dict(showgrid=True), yaxis=dict(showgrid=True))

fig.show()
11 changes: 11 additions & 0 deletions exercises/exercise_12_0_2_plotly.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import numpy as np
import plotly.graph_objs as go

x = np.linspace(-3, 3, 200)
y = 4 * x ** 3 + x ** 2

fig = go.Figure(data=go.Scatter(x=x, y=y, mode='lines', line=dict(color='black'), name="f(x)"))

fig.update_layout(title="f(x)", showlegend=True, xaxis=dict(showgrid=True), yaxis=dict(showgrid=True))

fig.show()
19 changes: 19 additions & 0 deletions exercises/exercise_12_0_3_plotly.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import numpy as np
import plotly.graph_objs as go

x = np.linspace(-3, 3, 200)
y = np.exp(x**2)**-0.5

fig = go.Figure()

fig.add_trace(go.Scatter(x=x, y=y, mode='lines', line=dict(color='black'), name="f(x)"))

highlighted_region_1 = np.where((x > -3) & (x < -1), y, None)
highlighted_region_2 = np.where((x > 1) & (x < 3), y, None)

fig.add_trace(go.Scatter(x=x, y=highlighted_region_1, fill='tozeroy', fillcolor='rgba(0, 128, 0, 0.3)', line=dict(color='rgba(0, 0, 0, 0)'), showlegend=False))
fig.add_trace(go.Scatter(x=x, y=highlighted_region_2, fill='tozeroy', fillcolor='rgba(0, 128, 0, 0.3)', line=dict(color='rgba(0, 0, 0, 0)'), showlegend=False))

fig.update_layout(title="f(x)", showlegend=True, xaxis=dict(showgrid=True), yaxis=dict(showgrid=True))

fig.show()