Debian Codegraph @

tests/data/notebooks/outputs/ipynb_to_pandoc/julia_benchmark_plotly_barchart.md

raw
1 ---
2 jupyter:
3 kernelspec:
4 display_name: Julia 1.1.1
5 language: julia
6 name: julia-1.1
7 nbformat: 4
8 nbformat_minor: 1
9 ---
10
11 ::: {#cell-1 .cell .code}
12 ``` julia
13 # IJulia rocks! So does Plotly. Check it out
14
15 using Plotly
16 api_key = "" # visit https://plot.ly/api to generate an API username and password
17 username = ""
18
19 Plotly.signin(username, api_key)
20 ```
21 :::
22
23 ::: {#cell-2 .cell .code}
24 ``` julia
25 # Following data taken from http://julialang.org/ frontpage
26 benchmarks = ["fib", "parse_int", "quicksort3", "mandel", "pi_sum", "rand_mat_stat", "rand_mat_mul"]
27 platforms = ["Fortran", "Julia", "Python", "R", "Matlab", "Mathematica", "Javascript", "Go"]
28
29 data = {
30 platforms[1] => [0.26, 5.03, 1.11, 0.86, 0.80, 0.64, 0.96],
31 platforms[2] => [0.91, 1.60, 1.14, 0.85, 1.00, 1.66, 1.01],
32 platforms[3] => [30.37, 13.95, 31.98, 14.19, 16.33, 13.52, 3.41 ],
33 platforms[4] => [411.36, 59.40, 524.29, 106.97, 15.42, 10.84, 3.98 ],
34 platforms[5] => [1992.00, 1463.16, 101.84, 64.58, 1.29, 6.61, 1.10 ],
35 platforms[6] => [64.46, 29.54, 35.74, 6.07, 1.32, 4.52, 1.16 ],
36 platforms[7] => [2.18, 2.43, 3.51, 3.49, 0.84, 3.28, 14.60],
37 platforms[8] => [1.03, 4.79, 1.25, 2.36, 1.41, 8.12, 8.51]
38 }
39
40 pdata = [ {"x"=>benchmarks,"y"=>data[k],"bardir"=>"h","type"=>"bar","name"=>k} for k = platforms ]
41
42 layout = {
43 "title"=> "Julia benchmark comparison (smaller is better, C performance = 1.0)",
44 "barmode"=> "group",
45 "autosize"=> false,
46 "width"=> 900,
47 "height"=> 900,
48 "titlefont"=>
49 {
50 "family"=> "Open Sans",
51 "size"=> 18,
52 "color"=> "rgb(84, 39, 143)"
53 },
54 "margin"=> {"l"=>160, "pad"=>0},
55 "xaxis"=> {
56 "title"=> "Benchmark log-time",
57 "type"=> "log"
58 },
59 "yaxis"=> {"title"=> "Benchmark Name"}
60 }
61
62 response = Plotly.plot(pdata,["layout"=>layout])
63
64 # Embed in an iframe within IJulia
65 s = string("<iframe height='750' id='igraph' scrolling='no' seamless='seamless' src='",
66 response["url"],
67 "/700/700' width='750'></iframe>")
68 display("text/html", s)
69 ```
70 :::
71
72 ::: {#cell-3 .cell .code}
73 ``` julia
74 # checkout https://plot.ly/api/ for more Julia examples!
75 # But to show off some other Plotly features:
76 x = 1:1500
77 y1 = sin(2*pi*x/1500.) + rand(1500)-0.5
78 y2 = sin(2*pi*x/1500.)
79
80 fish = {"x"=>x,"y"=> y1,
81 "type"=>"scatter","mode"=>"markers",
82 "marker"=>{"color"=>"rgb(0, 0, 255)","opacity"=>0.5 } }
83
84 fit = {"x"=> x,"y"=> y2,
85 "type"=>"scatter", "mode"=>"markers", "opacity"=>0.8,
86 "marker"=>{"color"=>"rgb(255, 0, 0)"} }
87
88 layout = {"autosize"=> false,
89 "width"=> 650, "height"=> 550,
90 "title"=>"Fish School",
91 "xaxis"=>{ "ticks"=> "",
92 "gridcolor"=> "white",
93 "zerolinecolor"=> "white",
94 "linecolor"=> "white",
95 "autorange"=> false,
96 "range"=>[0,1500] },
97 "yaxis"=>{ "ticks"=> "",
98 "gridcolor"=> "white",
99 "zerolinecolor"=> "white",
100 "linecolor"=> "white",
101 "autorange"=> false,
102 "range"=>[-2.2,2.2] },
103 "plot_bgcolor"=> "rgb(245,245,247)",
104 "showlegend"=> false,
105 "hovermode"=> "closest"}
106
107 response = Plotly.plot([fish, fit],["layout"=>layout])
108 s = string("<iframe height='750' id='igraph' scrolling='no' seamless='seamless' src='",
109 response["url"],
110 "/700/700' width='750'></iframe>")
111 display("text/html", s)
112 ```
113 :::