Plots.jl/examples/animations.ipynb
Thomas Breloff 1db36c05a8 animations
2015-10-16 16:36:40 -04:00

120 lines
2.4 KiB
Plaintext

{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO: Recompiling stale cache file /home/tom/.julia/lib/v0.4/Plots.ji for module Plots.\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"[Plots.jl] Initializing backend: gadfly\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO: Saved animation to /home/tom/.julia/v0.4/Plots/examples/tmp.gif\n"
]
},
{
"data": {
"text/html": [
"<img src=\"tmp.gif?0.4950005887019313>\" />"
],
"text/plain": [
"Plots.AnimatedGif(\"/home/tom/.julia/v0.4/Plots/examples/tmp.gif\")"
]
},
"execution_count": 1,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"using Plots\n",
"gadfly()\n",
"\n",
"# create a plot\n",
"n = 10\n",
"p = scatter(randn(n), randn(n), size=(500,300))\n",
"\n",
"# make an animation by adding data and saving the frames\n",
"anim = Animation()\n",
"for i in 1:100\n",
" append!(p, 1, randn(n), randn(n))\n",
" frame(anim)\n",
"end\n",
"g = gif(anim, fps=50)"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO: Saved animation to /home/tom/.julia/v0.4/Plots/examples/tmp.gif\n"
]
},
{
"data": {
"text/html": [
"<img src=\"tmp.gif?0.30448413983944445>\" />"
],
"text/plain": [
"Plots.AnimatedGif(\"/home/tom/.julia/v0.4/Plots/examples/tmp.gif\")"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"g = gif(anim, fps=1)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Julia 0.4.0-rc4",
"language": "julia",
"name": "julia-0.4"
},
"language_info": {
"file_extension": ".jl",
"mimetype": "application/julia",
"name": "julia",
"version": "0.4.0"
}
},
"nbformat": 4,
"nbformat_minor": 0
}