168 lines
4.2 KiB
Plaintext
168 lines
4.2 KiB
Plaintext
{
|
|
"cells": [
|
|
{
|
|
"cell_type": "raw",
|
|
"id": "bb4361d9",
|
|
"metadata": {},
|
|
"source": [
|
|
"---\n",
|
|
"title: summary\n",
|
|
"---"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "58e5805d",
|
|
"metadata": {},
|
|
"source": [
|
|
"format:\n",
|
|
" html:\n",
|
|
" include-in-header:\n",
|
|
" text: |\n",
|
|
" <script type=\"application/javascript\">\n",
|
|
" requirejs.config({ baseUrl: '.',\n",
|
|
" //paths: {\n",
|
|
" // Plotly: 'plotly-latest.min.js'\n",
|
|
" // }\n",
|
|
" });\n",
|
|
" </script>\n",
|
|
"\n",
|
|
"\n",
|
|
"https://github.com/JuliaPlots/PlotlyJS.jl/issues/322\n",
|
|
"\n",
|
|
"In summary, this book has no content whatsoever.\n",
|
|
"\n",
|
|
"https://discourse.julialang.org/t/seven-lines-of-julia-examples-sought/50416\n"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "caf6e3b3",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"#| error: false\n",
|
|
"using PlotlyJS, Random\n",
|
|
"using HypertextLiteral\n",
|
|
"using JSON, UUIDs\n",
|
|
"using Base64\n",
|
|
"\n",
|
|
"function IJulia.display_dict(p::PlotlyJS.SyncPlot)\n",
|
|
" Dict(\n",
|
|
" # \"application/vnd.plotly.v1+json\" => JSON.lower(p),\n",
|
|
" # \"text/plain\" => sprint(show, \"text/plain\", p),\n",
|
|
" \"text/html\" => let\n",
|
|
" buf = IOBuffer()\n",
|
|
" show(buf, MIME(\"text/html\"), p)\n",
|
|
" String(resize!(buf.data, buf.size))\n",
|
|
" end,\n",
|
|
" \"image/png\" => let\n",
|
|
" buf = IOBuffer()\n",
|
|
" buf64 = Base64EncodePipe(buf)\n",
|
|
" show(buf64, MIME(\"image/png\"), p)\n",
|
|
" String(resize!(buf.data, buf.size))\n",
|
|
" end,\n",
|
|
"\n",
|
|
" )\n",
|
|
" end\n",
|
|
" \n",
|
|
" function Base.show(io::IO, mimetype::MIME\"text/html\", p::PlotlyJS.SyncPlot)\n",
|
|
" uuid = string(UUIDs.uuid4())\n",
|
|
" show(io,mimetype,@htl(\"\"\"\n",
|
|
" <div style=\"height: auto\" id=\\\"$(uuid)\\\"></div>\n",
|
|
" <script>\n",
|
|
" require(['../js/plotly-latest.min.js'], function(plotly) { \n",
|
|
" plotly.newPlot($(uuid),\n",
|
|
" $(HypertextLiteral.JavaScript(json(p.plot.data))),\n",
|
|
" $(HypertextLiteral.JavaScript(json(p.plot.layout))),{responsive: true});\n",
|
|
" });\n",
|
|
" </script>\n",
|
|
"\"\"\"))\n",
|
|
"end "
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "a6260dc2",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"Random.seed!(42)\n",
|
|
"\n",
|
|
"N = 100\n",
|
|
"random_x = range(0, stop=1, length=N)\n",
|
|
"random_y0 = randn(N) .+ 5\n",
|
|
"random_y1 = randn(N)\n",
|
|
"random_y2 = randn(N) .- 5\n",
|
|
"\n",
|
|
"plot([\n",
|
|
" scatter(x=random_x, y=random_y0, mode=\"markers\", name=\"markers\"),\n",
|
|
" scatter(x=random_x, y=random_y1, mode=\"lines\", name=\"lines\"),\n",
|
|
" scatter(x=random_x, y=random_y2, mode=\"markers+lines\", name=\"markers+lines\")\n",
|
|
"])"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "dd0a1a29",
|
|
"metadata": {},
|
|
"source": [
|
|
"jkjkjkj\n"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "813b97ce",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"#| warning: false\n",
|
|
"\n",
|
|
"plot([\n",
|
|
" scatter(x=random_x, y=random_y0, mode=\"markers\", name=\"markers\") ])"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "c271b5dc",
|
|
"metadata": {},
|
|
"source": [
|
|
";;l;l;l\n"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "6cb53248",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"#| warning: false\n",
|
|
"\n",
|
|
"plot([\n",
|
|
" scatter(x=random_x, y=random_y2, mode=\"markers\", name=\"markers\") ])"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "7df06b26",
|
|
"metadata": {},
|
|
"source": [
|
|
"lllklk"
|
|
]
|
|
}
|
|
],
|
|
"metadata": {
|
|
"kernelspec": {
|
|
"display_name": "Julia 1.8.5",
|
|
"language": "julia",
|
|
"name": "julia-1.8"
|
|
}
|
|
},
|
|
"nbformat": 4,
|
|
"nbformat_minor": 5
|
|
}
|