import numpy as np
import plotly.graph_objects as go
x = np.linspace(-1, 5, 200)
y = x**2 - 4 * x + 3
fig = go.Figure(go.Scatter(x=x, y=y, mode="lines"))
fig.update_layout(
title="A quadratic function",
xaxis_title="x",
yaxis_title="f(x)",
)
fig.show()Interactive plots with Python
Quarto lets you mix Markdown, math, and executable Python in one post.
For example, the quadratic function is
\[ f(x) = x^2 - 4x + 3. \]
The Python code below creates an interactive Plotly chart. Drag to zoom and hover over the curve to inspect values.