{
"cells": [
{
"cell_type": "markdown",
"id": "4b8e310d",
"metadata": {},
"source": [
"### Return the Content into a String Using `to_html()` and `to_svg()`"
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "8c2050f6",
"metadata": {},
"outputs": [],
"source": [
"import numpy as np\n",
"import io\n",
"from IPython import display\n",
"from lets_plot import *"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "17a6e0d1",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
" \n",
" \n",
" "
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"LetsPlot.setup_html()"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "1c4c6a00",
"metadata": {},
"outputs": [],
"source": [
"p = ggplot() + geom_point(x=0, y=0)"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "95af2676",
"metadata": {
"scrolled": false
},
"outputs": [
{
"data": {
"text/plain": [
"'"
],
"text/plain": [
""
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"display.SVG(svg)"
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "663b4ab3",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"'\\n \\n \\n \\n \\n \\n \\n \\n \\n'"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"html = p.to_html()\n",
"html"
]
},
{
"cell_type": "code",
"execution_count": 7,
"id": "92030feb",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"' '"
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"p.to_html(iframe=True)"
]
},
{
"cell_type": "code",
"execution_count": 8,
"id": "af51a603",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
""
],
"text/plain": [
""
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"display.HTML(html)"
]
},
{
"cell_type": "code",
"execution_count": 9,
"id": "99b2c196",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"'D:\\\\Projects\\\\lets-plot-master\\\\lets-plot-1067\\\\docs\\\\dev\\\\notebooks\\\\lets-plot-images\\\\hist_plot.html'"
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"ggsave(p, 'hist_plot.html')"
]
},
{
"cell_type": "code",
"execution_count": 10,
"id": "45b8fedc",
"metadata": {},
"outputs": [],
"source": [
"data = {'x': np.random.normal(size=100),\n",
" 'y': np.random.normal(size=100)}\n",
"grid = gggrid([\n",
" ggplot() + geom_point(x=0, y=0),\n",
" ggplot() + geom_point(x=1.0, y=1.0)\n",
"])\n",
"html = grid.to_html()"
]
},
{
"cell_type": "code",
"execution_count": 11,
"id": "5e7b88ab",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
""
],
"text/plain": [
""
]
},
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"display.HTML(html)"
]
},
{
"cell_type": "code",
"execution_count": 12,
"id": "3052f03b",
"metadata": {
"scrolled": false
},
"outputs": [
{
"data": {
"text/plain": [
"'