Skip to content

Instantly share code, notes, and snippets.

@ugo-nama-kun
Last active August 10, 2021 08:03
Show Gist options
  • Save ugo-nama-kun/84623f1e11fb79bb49a19725c30195b9 to your computer and use it in GitHub Desktop.
Save ugo-nama-kun/84623f1e11fb79bb49a19725c30195b9 to your computer and use it in GitHub Desktop.
Plot figure in the center of jupyter notebook
import numpy as np
from IPython.core.display import HTML
import matplotlib.pyplot as plt
# if you like seaborn:
import seaborn as sns
sns.set()
sns.set_context("talk")
HTML("""
<style>
.output_png {
display: table-cell;
text-align: center;
vertical-align: middle;
}
</style>
""")
# plot a normal dist.
mu, sigma = 38, 3 # mean and standard deviation
s = np.random.normal(mu, sigma, 1000)
count, bins, ignored = plt.hist(s, 13, density=True)
plt.plot(bins, 1/(sigma * np.sqrt(2 * np.pi)) *
np.exp( - (bins - mu)**2 / (2 * sigma**2) ),
linewidth=2, color='r')
plt.show()
@ugo-nama-kun
Copy link
Author

you will see this:
Screen Shot 2021-08-10 at 17 02 56

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment