Skip to content

Instantly share code, notes, and snippets.

@empet
Created November 20, 2020 21:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save empet/fad7586a28872a6065fd51c5c0eb1822 to your computer and use it in GitHub Desktop.
Save empet/fad7586a28872a6065fd51c5c0eb1822 to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"using HTTP\n",
"using CSV\n",
"using DataFrames\n",
"using PlotlyJS\n",
"include(\"plotlyju.jl\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"url = \"https://raw.githubusercontent.com/plotly/datasets/master/vortex.csv\" \n",
"df = CSV.File(HTTP.get(url).body)|> DataFrame;"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"ice = [[0.0, \"rgb(3, 5, 18)\"],\n",
" [0.1, \"rgb(27, 26, 54)\"],\n",
" [0.2, \"rgb(48, 46, 95)\"],\n",
" [0.3, \"rgb(60, 66, 136)\"],\n",
" [0.4, \"rgb(62, 93, 168)\"],\n",
" [0.5, \"rgb(66, 122, 183)\"],\n",
" [0.6, \"rgb(82, 149, 192)\"],\n",
" [0.7, \"rgb(106, 177, 203)\"],\n",
" [0.8, \"rgb(140, 203, 213)\"],\n",
" [0.9, \"rgb(188, 227, 230)\"],\n",
" [1.0, \"rgb(234, 252, 253)\"]];"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"trace = cone(x=df[\"x\"],\n",
" y=df[\"y\"],\n",
" z=df[\"z\"],\n",
" u=df[\"u\"],\n",
" v=df[\"v\"],\n",
" w=df[\"w\"],\n",
" sizemode=\"absolute\",\n",
" sizeref=40,\n",
" colorscale=ice, \n",
" colorbar_len=0.7,\n",
" anchor=\"tip\"\n",
" );"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"layout = Layout(title=\"Vortex as a cone plot\",\n",
" width=800,\n",
" height=650,\n",
" autosize=false,\n",
" scene_camera_eye=attr(x=1.3, y=1.3, z=0.7),\n",
" scene_aspectratio=attr(x=1, y=1, z=0.8))\n",
"pl= plot(trace, layout, style=plotlyju)\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"savefig(pl, \"vortex.svg\");"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"![alt text](vortex.svg)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"@webio": {
"lastCommId": null,
"lastKernelId": null
},
"kernelspec": {
"display_name": "Julia 1.5.2",
"language": "julia",
"name": "julia-1.5"
},
"language_info": {
"file_extension": ".jl",
"mimetype": "application/julia",
"name": "julia",
"version": "1.5.2"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment