Testing out Jupyter HTML export¶
This is just a test.
> jupyter notebook
- Write new notebook.
- Add markdown, a computation, and a plot.
- Export to HTML
- Copy and paste into website.
In [1]:
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from random_word import RandomWords
rw = RandomWords()
r = np.random.randint(0,256, size=100)
g = np.random.randint(0,256, size=100)
b = np.random.randint(0,256, size=100)
w = np.array([rw.get_random_word()
for i in range(100)])
df = pd.DataFrame({'word':w,
'r':r,
'g':g,
'b':b})
df
Out[1]:
word | r | g | b | |
---|---|---|---|---|
0 | bag-holder | 97 | 105 | 221 |
1 | tanzim | 169 | 25 | 105 |
2 | stucco | 220 | 201 | 161 |
3 | air-braving | 168 | 194 | 142 |
4 | sarawakian | 70 | 80 | 52 |
… | … | … | … | … |
95 | flybane | 32 | 11 | 127 |
96 | chavettes | 240 | 88 | 218 |
97 | El Nino | 59 | 63 | 25 |
98 | resectable | 40 | 73 | 193 |
99 | savely | 45 | 66 | 109 |
100 rows × 4 columns
The above cell creates a dataframe with random words and random RGB color coordinates. Below, the coordinates are plotted in 3D.
In [9]:
%matplotlib inline
from mpl_toolkits import mplot3d
fig = plt.figure(figsize=[4,4],dpi=150)
ax = fig.add_subplot(projection='3d')
ax.scatter3D(df['r'],
df['g'],
df['b'])
plt.show()
Fin.
NOTE: I needed to use the following reference to get the above image to show in HTML,
https://stackoverflow.com/questions/51975699/embedding-image-into-jupyter-notebook-and-exporting-to-html
Basically involved employed the following commands (was already installed, so just the last two) and configured the appropriate extension, “Export HTML With Embedded Images”, under NBExtensions:
$ pip install jupyter_contrib_nbextensions
$ pip install jupyter_nbextensions_configurator
$ jupyter contrib nbextension install --user
$ jupyter nbextensions_configurator enable --user
Then you will see in your Jupyter homepage a new tab (Nbextensions), where you can enable and configure different extension.
After enabling the "Export HTML With Embedded Images", you will see the corresponding option in the "File-Download as" menu.
In [ ]: