Adding a Plot
Constellate displays plots alongside Markdown cells. This lets you explain what's going on or offer context on the same screen. Let's add a graph and some explanation. Add a Markdown cell after the first one you added above, and add the text below or freestyle your own:
## Example Graph
The standard <span class='text-c1'>normal</span> distribution has the probability density function
$$\frac{1}{\sqrt{2 \pi}} e^{-\frac{1}{2} x^2}$$
The standard <span class='text-c2'>Cauchy</span> distribution has probability density function
$$\frac{1}{\pi(x^2 + 1)}$$
Then, in a Python cell below that one, add the following code or write your own:
import numpy as np
import matplotlib.pyplot as plt
xx = np.linspace(-5, 5, 100)
plt.plot(xx, np.exp(0.5 * xx ** 2) / np.sqrt(2 * np.pi), label='Normal Distribution')
plt.plot(xx, 1 / (np.pi * (xx ** 2 + 1)), label='Cauchy Distribution')
plt.legend()
Running the cell in a notebook should produce a graph.1 Now let's see how Constellate displays your new output.
- You might need to install
numpy
withpip install numpy
.↩
Adding a Plot
Constellate displays plots alongside Markdown cells. This lets you explain what's going on or offer context on the same screen. Let's add a graph and some explanation. Add a Markdown cell after the first one you added above, and add the text below or freestyle your own:
## Example Graph
The standard <span class='text-c1'>normal</span> distribution has the probability density function
$$\frac{1}{\sqrt{2 \pi}} e^{-\frac{1}{2} x^2}$$
The standard <span class='text-c2'>Cauchy</span> distribution has probability density function
$$\frac{1}{\pi(x^2 + 1)}$$
Then, in a Python cell below that one, add the following code or write your own:
import numpy as np
import matplotlib.pyplot as plt
xx = np.linspace(-5, 5, 100)
plt.plot(xx, np.exp(0.5 * xx ** 2) / np.sqrt(2 * np.pi), label='Normal Distribution')
plt.plot(xx, 1 / (np.pi * (xx ** 2 + 1)), label='Cauchy Distribution')
plt.legend()
Running the cell in a notebook should produce a graph.1 Now let's see how Constellate displays your new output.
- You might need to install
numpy
withpip install numpy
.↩