Skip to content

Instantly share code, notes, and snippets.

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 msund/25ee1ba3ceab020dc806 to your computer and use it in GitHub Desktop.
Save msund/25ee1ba3ceab020dc806 to your computer and use it in GitHub Desktop.
{
"metadata": {
"language": "Julia",
"name": "Julia Benchmark Plotly Barchart"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
"cell_type": "code",
"collapsed": true,
"input": "# IJulia rocks! So does Plotly. Check it out\n\nusing Plotly\napi_key = \"\" # visit https://plot.ly/api to generate an API username and password\nusername = \"\"\n\nPlotly.signin(username, api_key)",
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 1
},
{
"cell_type": "code",
"collapsed": false,
"input": "# Following data taken from http://julialang.org/ frontpage \nbenchmarks = [\"fib\", \"parse_int\", \"quicksort3\", \"mandel\", \"pi_sum\", \"rand_mat_stat\", \"rand_mat_mul\"]\nplatforms = [\"Fortran\", \"Julia\", \"Python\", \"R\", \"Matlab\", \"Mathematica\", \"Javascript\", \"Go\"]\n\ndata = {\n platforms[1] => [0.26, 5.03, 1.11, 0.86, 0.80, 0.64, 0.96],\n platforms[2] => [0.91, 1.60, 1.14, 0.85, 1.00, 1.66, 1.01],\n platforms[3] => [30.37, 13.95, 31.98, 14.19, 16.33, 13.52, 3.41 ],\n platforms[4] => [411.36, 59.40, 524.29, 106.97, 15.42, 10.84, 3.98 ],\n platforms[5] => [1992.00, 1463.16, 101.84, 64.58, 1.29, 6.61, 1.10 ],\n platforms[6] => [64.46, 29.54, 35.74, 6.07, 1.32, 4.52, 1.16 ],\n platforms[7] => [2.18, 2.43, 3.51, 3.49, 0.84, 3.28, 14.60],\n platforms[8] => [1.03, 4.79, 1.25, 2.36, 1.41, 8.12, 8.51]\n }\n\npdata = [ {\"x\"=>benchmarks,\"y\"=>data[k],\"bardir\"=>\"h\",\"type\"=>\"bar\",\"name\"=>k} for k = platforms ]\n\nlayout = {\n \"title\"=> \"Julia benchmark comparison (smaller is better, C performance = 1.0)\",\n \"barmode\"=> \"group\",\n \"autosize\"=> false,\n \"width\"=> 900,\n \"height\"=> 900,\n \"titlefont\"=>\n {\n \"family\"=> \"Open Sans\",\n \"size\"=> 18,\n \"color\"=> \"rgb(84, 39, 143)\"\n },\n \"margin\"=> {\"l\"=>160, \"pad\"=>0},\n \"xaxis\"=> {\n \"title\"=> \"Benchmark log-time\",\n \"type\"=> \"log\"\n },\n \"yaxis\"=> {\"title\"=> \"Benchmark Name\"}\n }\n\nresponse = Plotly.plot(pdata,[\"layout\"=>layout])\n\n# Embed in an iframe within IJulia\ns = string(\"<iframe height='750' id='igraph' scrolling='no' seamless='seamless' src='\",\n response[\"url\"],\n \"/700/700' width='750'></iframe>\")\ndisplay(\"text/html\", s)",
"language": "python",
"metadata": {},
"outputs": [
{
"html": "<iframe height='750' id='igraph' scrolling='no' seamless='seamless' src='http://plot.ly/~bpostlethwaiteb/24/700/700' width='750'></iframe>",
"metadata": {},
"output_type": "display_data"
}
],
"prompt_number": 13
},
{
"cell_type": "code",
"collapsed": false,
"input": "# checkout https://plot.ly/api/ for more Julia examples!\n# But to show off some other Plotly features:\nx = 1:1500\ny1 = sin(2*pi*x/1500.) + rand(1500)-0.5\ny2 = sin(2*pi*x/1500.)\n\nfish = {\"x\"=>x,\"y\"=> y1,\n\t\"type\"=>\"scatter\",\"mode\"=>\"markers\",\n\t\"marker\"=>{\"color\"=>\"rgb(0, 0, 255)\",\"opacity\"=>0.5 } }\n\nfit = {\"x\"=> x,\"y\"=> y2,\n\t\"type\"=>\"scatter\", \"mode\"=>\"markers\", \"opacity\"=>0.8,\n\t\"marker\"=>{\"color\"=>\"rgb(255, 0, 0)\"} }\n\nlayout = {\"autosize\"=> false,\n \"width\"=> 650, \"height\"=> 550,\n \"title\"=>\"Fish School\",\n\t\"xaxis\"=>{ \"ticks\"=> \"\",\n \"gridcolor\"=> \"white\",\n \"zerolinecolor\"=> \"white\", \n \"linecolor\"=> \"white\",\n \"autorange\"=> false,\n \"range\"=>[0,1500] },\n\t\"yaxis\"=>{ \"ticks\"=> \"\",\n \"gridcolor\"=> \"white\",\n \"zerolinecolor\"=> \"white\",\n\t\t\"linecolor\"=> \"white\",\n \"autorange\"=> false,\n \"range\"=>[-2.2,2.2] },\n\t\"plot_bgcolor\"=> \"rgb(245,245,247)\",\n \"showlegend\"=> false,\n \"hovermode\"=> \"closest\"}\n\nresponse = Plotly.plot([fish, fit],[\"layout\"=>layout])\ns = string(\"<iframe height='750' id='igraph' scrolling='no' seamless='seamless' src='\",\n response[\"url\"],\n \"/700/700' width='750'></iframe>\")\ndisplay(\"text/html\", s)",
"language": "python",
"metadata": {},
"outputs": [
{
"html": "<iframe height='750' id='igraph' scrolling='no' seamless='seamless' src='http://plot.ly/~bpostlethwaiteb/26/700/700' width='750'></iframe>",
"metadata": {},
"output_type": "display_data"
}
],
"prompt_number": 15
}
],
"metadata": {}
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment