Skip to content

Instantly share code, notes, and snippets.

@empet
Created October 7, 2022 09:05
Show Gist options
  • Select an option

  • Save empet/3bb979f33cdc59b8267d5fe6f9e5faca to your computer and use it in GitHub Desktop.

Select an option

Save empet/3bb979f33cdc59b8267d5fe6f9e5faca to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": 6,
"id": "f9510980",
"metadata": {},
"outputs": [],
"source": [
"using DataFrames, CSV, PlotlyJS, BenchmarkTools\n",
"include(\"quiver.jl\")\n",
"function get_quiver_plot(df)\n",
" X = vcat(df[!, :x], df[!, :x])\n",
" Y = vcat(df[!, :y], df[!, :y])\n",
"\n",
" U = vcat(df[!, :u], map(x->-1*x, df[!, :u]))\n",
" V = vcat(df[!, :v], map(x->-1*x, df[!, :v]));\n",
" q=Quiver(x=X, y=Y, u=U, v=V, vector_scale=0.01, arrow_scale=0.001, angle=pi/18)\n",
" fig = quiverPlot(q;) \n",
" update!(fig, line_width=0.75, [1], \n",
" layout=Layout(width=700, height=500)) \n",
" return(fig)\n",
"end \n",
"df = CSV.read(\"quiver.csv\", DataFrame);\n",
"fig= get_quiver_plot(df);\n"
]
},
{
"cell_type": "code",
"execution_count": 7,
"id": "a02a3c12",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
" 8.131 ms (123422 allocations: 26.05 MiB)\n"
]
}
],
"source": [
"@btime get_quiver_plot(df);"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "1588168a",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"@webio": {
"lastCommId": "e484ea29cf7540a885eb6f5786bf704e",
"lastKernelId": "0bad2e79-842e-4172-9717-daa16441656e"
},
"kernelspec": {
"display_name": "Julia 1.7.3",
"language": "julia",
"name": "julia-1.7"
},
"language_info": {
"file_extension": ".jl",
"mimetype": "application/julia",
"name": "julia",
"version": "1.7.3"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment