rubydown 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.circleci/config.yml +35 -0
- data/.gitignore +3 -0
- data/Dockerfile +9 -0
- data/Gemfile +8 -0
- data/Gemfile.lock +43 -0
- data/LICENSE +21 -0
- data/README.md +32 -0
- data/Rakefile +2 -0
- data/_config.yml +1 -0
- data/appveyor.yml +25 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/docs/_config.yml +1 -0
- data/docs/index.html +20 -0
- data/docs/sidebyside.md +1 -0
- data/examples/bio.html +129 -0
- data/examples/bio.md +73 -0
- data/examples/graph.html +160 -0
- data/examples/graph.md +11 -0
- data/examples/index.html +217 -0
- data/examples/index.md +58 -0
- data/examples/numo-gnuplot.ipynb +1515 -0
- data/examples/rbplotly-bar.html +146 -0
- data/examples/rbplotly-bar.md +54 -0
- data/examples/rbplotly-basic.html +134 -0
- data/examples/rbplotly-basic.md +43 -0
- data/examples/rbplotly-boxplot.html +136 -0
- data/examples/rbplotly-boxplot.md +60 -0
- data/examples/rbplotly-heatmap.html +95 -0
- data/examples/rbplotly-heatmap.md +35 -0
- data/examples/rbplotly-hist.html +52 -0
- data/examples/rbplotly-hist.md +9 -0
- data/examples/rbplotly-line.html +62 -0
- data/examples/rbplotly-line.md +19 -0
- data/examples/rbplotly-pie.html +100 -0
- data/examples/rbplotly-pie.md +40 -0
- data/examples/rbplotly-scatter.html +148 -0
- data/examples/rbplotly-scatter.md +71 -0
- data/examples/rumale-kmeans.html +75 -0
- data/examples/rumale-kmeans.md +33 -0
- data/examples/rumale.html +967 -0
- data/examples/rumale.md +31 -0
- data/examples/table.html +57 -0
- data/examples/table.md +7 -0
- data/exe/rubydown +114 -0
- data/lib/rubydown.rb +59 -0
- data/lib/rubydown/version.rb +3 -0
- data/rubydown.gemspec +47 -0
- data/templates/template.html.erb +26 -0
- metadata +207 -0
@@ -0,0 +1,60 @@
|
|
1
|
+
# rbplotly boxplot usage
|
2
|
+
|
3
|
+
~~~ruby
|
4
|
+
require 'rbplotly'
|
5
|
+
|
6
|
+
n = 50
|
7
|
+
y0 = n.times.map { rand(-1.0..0.0) }
|
8
|
+
y1 = n.times.map { rand(0.0..1.0) }
|
9
|
+
|
10
|
+
trace0 = {
|
11
|
+
y: y0,
|
12
|
+
type: :box
|
13
|
+
}
|
14
|
+
|
15
|
+
trace1 = {
|
16
|
+
y: y1,
|
17
|
+
type: :box
|
18
|
+
}
|
19
|
+
|
20
|
+
data = [trace0, trace1]
|
21
|
+
|
22
|
+
plot = Plotly::Plot.new(data: data)
|
23
|
+
~~~
|
24
|
+
|
25
|
+
## Horizontal boxplot
|
26
|
+
|
27
|
+
~~~ruby
|
28
|
+
n = 50
|
29
|
+
x0 = n.times.map { rand(-1.0..0.0) }
|
30
|
+
x1 = n.times.map { rand(0.0..1.0) }
|
31
|
+
|
32
|
+
trace0 = {
|
33
|
+
x: x0,
|
34
|
+
type: :box
|
35
|
+
}
|
36
|
+
|
37
|
+
trace1 = {
|
38
|
+
x: x1,
|
39
|
+
type: :box
|
40
|
+
}
|
41
|
+
|
42
|
+
data = [trace0, trace1]
|
43
|
+
|
44
|
+
plot = Plotly::Plot.new(data: data)
|
45
|
+
~~~
|
46
|
+
|
47
|
+
|
48
|
+
## boxplot with the points
|
49
|
+
|
50
|
+
~~~ruby
|
51
|
+
trace = {
|
52
|
+
y: [0, 1, 1, 2, 3, 5, 8, 13, 21],
|
53
|
+
boxpoints: :all,
|
54
|
+
jitter: 0.3,
|
55
|
+
pointpos: -1.8,
|
56
|
+
type: :box
|
57
|
+
}
|
58
|
+
|
59
|
+
plot = Plotly::Plot.new(data: [trace])
|
60
|
+
~~~
|
@@ -0,0 +1,95 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
5
|
+
<link href='https://cdnjs.cloudflare.com/ajax/libs/github-markdown-css/2.10.0/github-markdown.min.css' rel='stylesheet' type='text/css' />
|
6
|
+
<style>
|
7
|
+
article.markdown-body {
|
8
|
+
box-sizing: border-box;
|
9
|
+
min-width: 200px;
|
10
|
+
max-width: 980px;
|
11
|
+
margin: 0 auto;
|
12
|
+
padding: 45px;
|
13
|
+
}
|
14
|
+
|
15
|
+
span.line-numbers {
|
16
|
+
display: none;
|
17
|
+
}
|
18
|
+
</style>
|
19
|
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.6/require.min.js"></script>
|
20
|
+
</head>
|
21
|
+
<body>
|
22
|
+
<article class='markdown-body'>
|
23
|
+
<h1 id="rbplotly-heatmap-usage">rbplotly heatmap usage</h1>
|
24
|
+
|
25
|
+
<pre><code class="language-ruby">require 'rbplotly'
|
26
|
+
|
27
|
+
z = [
|
28
|
+
[1, 20, 30],
|
29
|
+
[20, 1, 60],
|
30
|
+
[30, 60, 1]
|
31
|
+
]
|
32
|
+
|
33
|
+
data = [{
|
34
|
+
z: z,
|
35
|
+
type: :heatmap
|
36
|
+
}]
|
37
|
+
|
38
|
+
plot = Plotly::Plot.new(data: data)
|
39
|
+
</code></pre>
|
40
|
+
<script>
|
41
|
+
requirejs.config({paths: { 'plotly': ['https://cdn.plot.ly/plotly-latest.min'] }})
|
42
|
+
</script>
|
43
|
+
<div id="7b16d3c4-42b6-4520-a23e-eafd7e1805a6" style="height: 100%; width: 100%;"></div>
|
44
|
+
<script>
|
45
|
+
require(['plotly'], function(Plotly) {
|
46
|
+
Plotly.newPlot(
|
47
|
+
'7b16d3c4-42b6-4520-a23e-eafd7e1805a6',
|
48
|
+
[{"z":[[1,20,30],[20,1,60],[30,60,1]],"type":"heatmap"}],
|
49
|
+
{},
|
50
|
+
{"linkText":"Export to plot.ly","showLink":true}
|
51
|
+
)
|
52
|
+
|
53
|
+
window.addEventListener('resize', function() {
|
54
|
+
Plotly.Plots.resize(document.getElementById('7b16d3c4-42b6-4520-a23e-eafd7e1805a6'))
|
55
|
+
})
|
56
|
+
})
|
57
|
+
</script>
|
58
|
+
|
59
|
+
<pre><code class="language-ruby">n = 10
|
60
|
+
data = {
|
61
|
+
x: (1..n).map { |i| "x#{i}" },
|
62
|
+
y: (1..n).map { |i| "y#{i}" },
|
63
|
+
z: (1..n).map { (1..n).map { rand(10) } },
|
64
|
+
type: :heatmap
|
65
|
+
}
|
66
|
+
|
67
|
+
layout = {
|
68
|
+
width: 500,
|
69
|
+
height: 500
|
70
|
+
}
|
71
|
+
|
72
|
+
plot = Plotly::Plot.new(data: [data], layout: layout)
|
73
|
+
</code></pre>
|
74
|
+
<script>
|
75
|
+
requirejs.config({paths: { 'plotly': ['https://cdn.plot.ly/plotly-latest.min'] }})
|
76
|
+
</script>
|
77
|
+
<div id="d7fdcc3e-bc87-4a7b-b06f-ecef7653c8f4" style="height: 100%; width: 100%;"></div>
|
78
|
+
<script>
|
79
|
+
require(['plotly'], function(Plotly) {
|
80
|
+
Plotly.newPlot(
|
81
|
+
'd7fdcc3e-bc87-4a7b-b06f-ecef7653c8f4',
|
82
|
+
[{"z":[[3,9,7,6,9,1,5,6,4,3],[4,4,2,1,9,1,8,4,5,1],[7,6,7,2,4,3,7,8,4,3],[8,5,2,0,7,5,6,5,4,8],[1,5,7,0,3,8,4,5,4,8],[4,0,4,8,7,6,6,3,9,8],[5,5,8,6,6,6,8,8,1,7],[4,8,4,8,9,8,6,2,8,2],[7,2,5,2,7,3,9,5,2,9],[5,0,2,3,7,8,9,7,8,5]],"type":"heatmap","x":["x1","x2","x3","x4","x5","x6","x7","x8","x9","x10"],"y":["y1","y2","y3","y4","y5","y6","y7","y8","y9","y10"]}],
|
83
|
+
{"width":500,"height":500},
|
84
|
+
{"linkText":"Export to plot.ly","showLink":true}
|
85
|
+
)
|
86
|
+
|
87
|
+
window.addEventListener('resize', function() {
|
88
|
+
Plotly.Plots.resize(document.getElementById('d7fdcc3e-bc87-4a7b-b06f-ecef7653c8f4'))
|
89
|
+
})
|
90
|
+
})
|
91
|
+
</script>
|
92
|
+
|
93
|
+
</article>
|
94
|
+
</body>
|
95
|
+
</html>
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# rbplotly heatmap usage
|
2
|
+
|
3
|
+
~~~ruby
|
4
|
+
require 'rbplotly'
|
5
|
+
|
6
|
+
z = [
|
7
|
+
[1, 20, 30],
|
8
|
+
[20, 1, 60],
|
9
|
+
[30, 60, 1]
|
10
|
+
]
|
11
|
+
|
12
|
+
data = [{
|
13
|
+
z: z,
|
14
|
+
type: :heatmap
|
15
|
+
}]
|
16
|
+
|
17
|
+
plot = Plotly::Plot.new(data: data)
|
18
|
+
~~~
|
19
|
+
|
20
|
+
~~~ruby
|
21
|
+
n = 10
|
22
|
+
data = {
|
23
|
+
x: (1..n).map { |i| "x#{i}" },
|
24
|
+
y: (1..n).map { |i| "y#{i}" },
|
25
|
+
z: (1..n).map { (1..n).map { rand(10) } },
|
26
|
+
type: :heatmap
|
27
|
+
}
|
28
|
+
|
29
|
+
layout = {
|
30
|
+
width: 500,
|
31
|
+
height: 500
|
32
|
+
}
|
33
|
+
|
34
|
+
plot = Plotly::Plot.new(data: [data], layout: layout)
|
35
|
+
~~~
|
@@ -0,0 +1,52 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
5
|
+
<link href='https://cdnjs.cloudflare.com/ajax/libs/github-markdown-css/2.10.0/github-markdown.min.css' rel='stylesheet' type='text/css' />
|
6
|
+
<style>
|
7
|
+
article.markdown-body {
|
8
|
+
box-sizing: border-box;
|
9
|
+
min-width: 200px;
|
10
|
+
max-width: 980px;
|
11
|
+
margin: 0 auto;
|
12
|
+
padding: 45px;
|
13
|
+
}
|
14
|
+
|
15
|
+
span.line-numbers {
|
16
|
+
display: none;
|
17
|
+
}
|
18
|
+
</style>
|
19
|
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.6/require.min.js"></script>
|
20
|
+
</head>
|
21
|
+
<body>
|
22
|
+
<article class='markdown-body'>
|
23
|
+
<h1 id="rbplotly-histogram-usage">rbplotly histogram usage</h1>
|
24
|
+
|
25
|
+
<pre><code class="language-ruby">require 'rbplotly'
|
26
|
+
|
27
|
+
data = [{ x: (1..500).map { rand }, type: :histogram }]
|
28
|
+
|
29
|
+
plot = Plotly::Plot.new(data: data)
|
30
|
+
</code></pre>
|
31
|
+
<script>
|
32
|
+
requirejs.config({paths: { 'plotly': ['https://cdn.plot.ly/plotly-latest.min'] }})
|
33
|
+
</script>
|
34
|
+
<div id="7019b3a4-de26-40df-a17b-ee4a67c93fb8" style="height: 100%; width: 100%;"></div>
|
35
|
+
<script>
|
36
|
+
require(['plotly'], function(Plotly) {
|
37
|
+
Plotly.newPlot(
|
38
|
+
'7019b3a4-de26-40df-a17b-ee4a67c93fb8',
|
39
|
+
[{"x":[0.6347486838325643,0.9683601545604497,0.07224243708670863,0.8134297693149053,0.559131964244928,0.5640539040394165,0.3421274277908638,0.7192776154015307,0.9608434263579081,0.9179284777709036,0.01744662197457114,0.7605819878277414,0.8484333492058391,0.8422638828913539,0.031574557609566845,0.27762650966368707,0.8223644149242755,0.17308088490322604,0.3423598126666325,0.49684700627760847,0.7115454998357195,0.84306814013024,0.7653279844316125,0.2470076566283116,0.5796819547844608,0.6193108413379238,0.11680302311863489,0.009152991814388667,0.9069297310771407,0.6500777156138614,0.8156416851744179,0.24883543213663883,0.8157564476619303,0.13533855336684042,0.37969516781588186,0.04671151575578025,0.32698686129327237,0.3832087261534689,0.9641625882717932,0.6020140433588053,0.5391013181919431,0.10536099464129622,0.285603716591703,0.27602534009260615,0.22525701442395263,0.37188668043094364,0.7308785042115907,0.7430738451781879,0.354481339582019,0.22495061017736828,0.2583934581526054,0.20622640802347492,0.24259964788406496,0.055617029467649126,0.1294221421576578,0.7469530018625098,0.8120252903509642,0.5387020418377597,0.6358270298101708,0.6508620209595928,0.299748094082099,0.9748275970891562,0.5663022162282731,0.736212220336695,0.42632072326837733,0.0834990545950316,0.9090453583280276,0.3448333944802434,0.16650649785888838,0.7147437695016537,0.19586128931146995,0.6210597235154808,0.17994029310419413,0.920391328818118,0.4423016882367985,0.05402538773823762,0.9149325048804153,0.4635361783553599,0.8062002108217223,0.0785115957582816,0.5699993616005766,0.9678330909921887,0.05497945347683442,0.13316328059599947,0.6510045545599308,0.290491549334265,0.4462856849025626,0.7747034417069694,0.6955901126693641,0.754804209615644,0.6422229393911671,0.2728164807507608,0.002498344867125857,0.6760508116498731,0.7357820326322364,0.8813478093848596,0.36581285167944944,0.03898531342456113,0.9272378878769062,0.9519127917771226,0.16140009295668756,0.017950904319250505,0.9873631672401657,0.8308959142606169,0.7119305756632809,0.4203046491348007,0.47757465721624914,0.627910476555823,0.22988670664438038,0.6288868376422596,0.31744919734647004,0.24513754896653517,0.6015010040118807,0.3659672417177271,0.3593256406868338,0.49350389554386276,0.44790331625502533,0.8914258739431504,0.512605424364153,0.8935107328059425,0.5169365994545312,0.8175509122864271,0.9395899906759458,0.36995986759125743,0.7961823465570749,0.6023958412908405,0.5811646331614844,0.5249765889419429,0.6638193282667364,0.7373304457509198,0.8192437680854452,0.19272383147537786,0.6923337418406283,0.7672885737750603,0.1254234741823591,0.02244624816577212,0.13958836202516267,0.4866107227067933,0.3300151045722254,0.05995953412289623,0.11646950052445804,0.7217454739322877,0.8017335156874005,0.3082142545626464,0.5158472636936491,0.3128050924907845,0.470621289783665,0.0480340709230217,0.026313531328096773,0.07913294027175177,0.70742564722322,0.3765341264087614,0.3131638823360626,0.4203225209096829,0.5777263539564123,0.44894022570205494,0.15247981176687997,0.7607482964728317,0.5912956614318321,0.17906153373905154,0.7017448053572443,0.8549249860574452,0.24169115329167445,0.27663294129586613,0.08491504647951875,0.2042756730282076,0.36921508224412014,0.46578823252764834,0.197485902505808,0.725334423924335,0.8657696324017657,0.45354492451510287,0.8405296047150003,0.1907839372430411,0.5074995605172383,0.7558922826193342,0.49137044840932953,0.3566236710822124,0.3578370236756018,0.013005347470751327,0.8694497354669093,0.4296834114066457,0.5532109368326386,0.017002620923859513,0.8518461792152544,0.7432155592884926,0.6114356164647627,0.5614735072734997,0.6301893861841545,0.07658546071204142,0.5332484805361711,0.6382171500587805,0.3097828023010679,0.5937769227217654,0.8844270822866657,0.5494493329262897,0.8084881679860139,0.9114447804425972,0.6356666739827287,0.007113525694010803,0.09493599276634623,0.5752842994995347,0.7999126708585238,0.7086307142995705,0.07225438460616918,0.5326007886894711,0.46119282089868097,0.05971300451187378,0.2933236807036824,0.009324821067113409,0.04048663545892184,0.6379820448201828,0.6407459455492979,0.8757957695410546,0.196483422726612,0.5769127174525952,0.36047930827154306,0.8002162672685853,0.1789190040802826,0.8901130251685895,0.959812005843808,0.035871976039793196,0.4071323995189501,0.12118809799209795,0.3472654547863552,0.15540519066610814,0.16925894144966225,0.5327695073582421,0.556598398877278,0.22761569574779028,0.5018082510414928,0.029963730087796958,0.5697543570896796,0.8598765848517018,0.21604829691142424,0.5002172635205129,0.7372264025413311,0.003815339398136275,0.5837922775075572,0.9779141343249017,0.7892420491994052,0.7346146384426374,0.9853587578268717,0.847794723570703,0.4500026399710919,0.9294837187142558,0.2548963247593862,0.8384418876960305,0.2361371365097652,0.5881071132865984,0.6475512623337837,0.35176599328677827,0.19542606208785118,0.6735508574697096,0.39289620285379334,0.21036054054839937,0.7631683744050785,0.6673890559877586,0.9996829434794865,0.7958118741893633,0.06945545984685964,0.9415634819452142,0.789363463776489,0.1549905237839968,0.35204284942536257,0.9054479921009307,0.15607559778768698,0.9633489623628076,0.14558459895033504,0.30675176456593833,0.4783830400315061,0.10305302260657234,0.41819025115126396,0.1574762332229872,0.7298118463631077,0.36434835355916584,0.18216391740210924,0.6152310693107709,0.6828739323848192,0.9338525557797835,0.7561477233293326,0.564326416490363,0.7843563654400038,0.5125268006049978,0.41503184471735133,0.1426860853186801,0.5706717308713888,0.5609570391470653,0.3960632772748848,0.6865240438772761,0.5104915269563114,0.8972979919209809,0.48869315971250293,0.21418537433145268,0.48087735123901443,0.09500348099784439,0.33601048105208475,0.33485566699651803,0.6818211978224621,0.4257138826348067,0.03304996985015762,0.9977133785000961,0.9264051215948168,0.6014723912524956,0.7244803168885718,0.43653143571528696,0.9361843012622114,0.16696132073938363,0.9361070589507333,0.5116251139260175,0.483349674428434,0.6764547668773123,0.5381163214943728,0.4531299466369024,0.7600702459707765,0.44958044513637985,0.7500253092796441,0.004754678863689521,0.6045344294786125,0.25272244690741086,0.2761764438137181,0.3334084723685564,0.07585705046061342,0.5251839773129285,0.057675685028854784,0.5192608242015448,0.14946563168901972,0.5646927936872005,0.9961283065226997,0.39785085071019644,0.5650768329314052,0.7214075715357828,0.0018686878935778584,0.5879347878991087,0.8374988841639417,0.41608911031087725,0.880572273483777,0.4335621331489269,0.5877250002704341,0.6023962809420634,0.5722842003736311,0.7645897236599253,0.9075756972522584,0.04527234529142743,0.840046819349065,0.7191790390751466,0.8793816595184587,0.27102754839028775,0.23174786159909266,0.22520174075760757,0.4768368591938229,0.04173191159993106,0.7799177759776279,0.31605635265681997,0.7832471210767623,0.5851362516834888,0.7628907947812139,0.14618349266695507,0.5402062945024754,0.8981527810389445,0.007487215439508366,0.10069606877837634,0.8120731857591033,0.7651643633026615,0.030330875203649188,0.007735797027493829,0.34370991347906255,0.4849262072821925,0.4270587308503716,0.65426516489625,0.18222614043702745,0.7114555443076174,0.7162733247061074,0.9729274112344816,0.07793875324993338,0.46347052322281423,0.7258832329515292,0.23592407555722716,0.047074330321511204,0.9741679859799811,0.6848619427826295,0.924340759726112,0.2135225414015608,0.4172460084354076,0.240727455600098,0.27808309757846494,0.7983815364624692,0.37516311665212465,0.26126087780795193,0.5218269493901506,0.5015034761565922,0.7131988227249078,0.5693164135039537,0.919873286182549,0.2787329654209185,0.16009608330900726,0.26526218636862897,0.05109280140176975,0.5159502339100801,0.7489886773695466,0.050644996311550394,0.7675221178580472,0.5576339216768917,0.38062763487084283,0.6576127397813506,0.3034482807911002,0.8013831663256242,0.38134216687125333,0.6128055286974248,0.9461361562486195,0.27942658084152194,0.8465573571597634,0.41208090504209316,0.9102818593794331,0.1610559094131815,0.31049072740728423,0.5020824480056023,0.8285593423245035,0.35867295745555317,0.06723600045736156,0.5385976496818646,0.4755640548012052,0.31558161887421465,0.30530394455046983,0.8604292142326804,0.5711934475434506,0.10266343759865726,0.08628734698038754,0.8666686881872712,0.06168339707937176,0.4309661132066803,0.049687027047330634,0.3273694811436918,0.3249548929382028,0.5970279432200193,0.5923623268767554,0.004285143367088851,0.7809514804781849,0.33261772959313574,0.7228422960311405,0.09694154019279921,0.7381406014546685,0.6937591760488674,0.36634678541035304,0.6708819298815935,0.6534589850849309,0.4587930567323204,0.9713448314656424,0.4403741932462125,0.16178141346649455,0.49092132228604246,0.9154149237242138,0.053848745198802894,0.4667220245486893,0.5760868128989697,0.26989338827424936,0.32753646865797403,0.13737369010348788,0.6049160237441896,0.5648152676015074,0.026425445752311538,0.5112028396981391,0.19875763237150368,0.2379282596274115,0.9208997505829001,0.8034135744360227,0.2992059813858198,0.2687684422853438,0.30996026223173,0.16336181760087753,0.7751666946909811,0.7620192765416353,0.08081554953207748,0.3620252640877739,0.10225501227184475,0.5160102103495503,0.14950910444275511,0.7115921126199322,0.8417738461446134,0.5930747255163417,0.896944205000877,0.2591298792688457,0.5630355393381095,0.6783441082678345,0.5174565176720195,0.7050808608143603,0.2257637821823001,0.8819820429210248,0.8421671720675484,0.4444548737439502,0.9079426327301421,0.7211927923553263,0.7892822478948853,0.874452636184335,0.9171123642076946,0.4646859678518497,0.17480358994999778,0.0687760938016091,0.39314461337864115,0.4034415493596072],"type":"histogram"}],
|
40
|
+
{},
|
41
|
+
{"linkText":"Export to plot.ly","showLink":true}
|
42
|
+
)
|
43
|
+
|
44
|
+
window.addEventListener('resize', function() {
|
45
|
+
Plotly.Plots.resize(document.getElementById('7019b3a4-de26-40df-a17b-ee4a67c93fb8'))
|
46
|
+
})
|
47
|
+
})
|
48
|
+
</script>
|
49
|
+
|
50
|
+
</article>
|
51
|
+
</body>
|
52
|
+
</html>
|
@@ -0,0 +1,62 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
5
|
+
<link href='https://cdnjs.cloudflare.com/ajax/libs/github-markdown-css/2.10.0/github-markdown.min.css' rel='stylesheet' type='text/css' />
|
6
|
+
<style>
|
7
|
+
article.markdown-body {
|
8
|
+
box-sizing: border-box;
|
9
|
+
min-width: 200px;
|
10
|
+
max-width: 980px;
|
11
|
+
margin: 0 auto;
|
12
|
+
padding: 45px;
|
13
|
+
}
|
14
|
+
|
15
|
+
span.line-numbers {
|
16
|
+
display: none;
|
17
|
+
}
|
18
|
+
</style>
|
19
|
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.6/require.min.js"></script>
|
20
|
+
</head>
|
21
|
+
<body>
|
22
|
+
<article class='markdown-body'>
|
23
|
+
<h1 id="rbplotly-line-plot-usage">rbplotly line plot usage</h1>
|
24
|
+
|
25
|
+
<pre><code class="language-ruby">require 'rbplotly'
|
26
|
+
|
27
|
+
plot = Plotly::Plot.new
|
28
|
+
flip = -1
|
29
|
+
x = (0...100).map { |i| i.to_f / 10 }
|
30
|
+
(0..5).each do |i|
|
31
|
+
trace = {
|
32
|
+
x: x,
|
33
|
+
y: (1...100).map { |j| Math.sin(j.to_f / 10 + i) },
|
34
|
+
line: { shape: :spline },
|
35
|
+
mode: :lines
|
36
|
+
}
|
37
|
+
plot.data.push(trace)
|
38
|
+
end
|
39
|
+
plot
|
40
|
+
</code></pre>
|
41
|
+
<script>
|
42
|
+
requirejs.config({paths: { 'plotly': ['https://cdn.plot.ly/plotly-latest.min'] }})
|
43
|
+
</script>
|
44
|
+
<div id="534e55c3-1450-49c9-85f0-1a227ed26e7d" style="height: 100%; width: 100%;"></div>
|
45
|
+
<script>
|
46
|
+
require(['plotly'], function(Plotly) {
|
47
|
+
Plotly.newPlot(
|
48
|
+
'534e55c3-1450-49c9-85f0-1a227ed26e7d',
|
49
|
+
[{"x":[0.0,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1.0,1.1,1.2,1.3,1.4,1.5,1.6,1.7,1.8,1.9,2.0,2.1,2.2,2.3,2.4,2.5,2.6,2.7,2.8,2.9,3.0,3.1,3.2,3.3,3.4,3.5,3.6,3.7,3.8,3.9,4.0,4.1,4.2,4.3,4.4,4.5,4.6,4.7,4.8,4.9,5.0,5.1,5.2,5.3,5.4,5.5,5.6,5.7,5.8,5.9,6.0,6.1,6.2,6.3,6.4,6.5,6.6,6.7,6.8,6.9,7.0,7.1,7.2,7.3,7.4,7.5,7.6,7.7,7.8,7.9,8.0,8.1,8.2,8.3,8.4,8.5,8.6,8.7,8.8,8.9,9.0,9.1,9.2,9.3,9.4,9.5,9.6,9.7,9.8,9.9],"y":[0.09983341664682815,0.19866933079506122,0.29552020666133955,0.3894183423086505,0.479425538604203,0.5646424733950354,0.644217687237691,0.7173560908995228,0.7833269096274834,0.8414709848078965,0.8912073600614354,0.9320390859672263,0.963558185417193,0.9854497299884601,0.9974949866040544,0.9995736030415051,0.9916648104524686,0.9738476308781951,0.9463000876874145,0.9092974268256817,0.8632093666488737,0.8084964038195901,0.7457052121767203,0.675463180551151,0.5984721441039565,0.5155013718214642,0.4273798802338298,0.3349881501559051,0.23924932921398243,0.1411200080598672,0.04158066243329049,-0.058374143427580086,-0.1577456941432482,-0.2555411020268312,-0.35078322768961984,-0.44252044329485246,-0.5298361409084934,-0.6118578909427189,-0.6877661591839738,-0.7568024953079282,-0.8182771110644103,-0.8715757724135882,-0.9161659367494549,-0.951602073889516,-0.977530117665097,-0.9936910036334644,-0.9999232575641008,-0.9961646088358407,-0.9824526126243325,-0.9589242746631385,-0.9258146823277325,-0.8834546557201531,-0.8322674422239013,-0.7727644875559871,-0.7055403255703919,-0.6312666378723216,-0.5506855425976376,-0.46460217941375737,-0.373876664830236,-0.27941549819892586,-0.18216250427209588,-0.0830894028174964,0.016813900484349713,0.11654920485049364,0.21511998808781552,0.31154136351337786,0.4048499206165983,0.49411335113860816,0.5784397643882001,0.6569865987187891,0.7289690401258759,0.7936678638491531,0.8504366206285644,0.8987080958116269,0.9379999767747389,0.9679196720314863,0.9881682338770004,0.998543345374605,0.998941341839772,0.9893582466233818,0.9698898108450863,0.9407305566797731,0.9021718337562933,0.8545989080882804,0.7984871126234903,0.7343970978741133,0.6629692300821833,0.5849171928917617,0.5010208564578846,0.4121184852417566,0.3190983623493521,0.22288991410024764,0.1244544235070617,0.024775425453357765,-0.0751511204618093,-0.17432678122297965,-0.27176062641094245,-0.3664791292519284,-0.45753589377532133],"line":{"shape":"spline"},"mode":"lines"},{"x":[0.0,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1.0,1.1,1.2,1.3,1.4,1.5,1.6,1.7,1.8,1.9,2.0,2.1,2.2,2.3,2.4,2.5,2.6,2.7,2.8,2.9,3.0,3.1,3.2,3.3,3.4,3.5,3.6,3.7,3.8,3.9,4.0,4.1,4.2,4.3,4.4,4.5,4.6,4.7,4.8,4.9,5.0,5.1,5.2,5.3,5.4,5.5,5.6,5.7,5.8,5.9,6.0,6.1,6.2,6.3,6.4,6.5,6.6,6.7,6.8,6.9,7.0,7.1,7.2,7.3,7.4,7.5,7.6,7.7,7.8,7.9,8.0,8.1,8.2,8.3,8.4,8.5,8.6,8.7,8.8,8.9,9.0,9.1,9.2,9.3,9.4,9.5,9.6,9.7,9.8,9.9],"y":[0.8912073600614354,0.9320390859672263,0.963558185417193,0.9854497299884601,0.9974949866040544,0.9995736030415051,0.9916648104524686,0.9738476308781951,0.9463000876874145,0.9092974268256817,0.8632093666488737,0.8084964038195901,0.7457052121767203,0.675463180551151,0.5984721441039565,0.5155013718214642,0.4273798802338298,0.3349881501559051,0.23924932921398243,0.1411200080598672,0.04158066243329049,-0.058374143427580086,-0.1577456941432482,-0.2555411020268312,-0.35078322768961984,-0.44252044329485246,-0.5298361409084934,-0.6118578909427189,-0.6877661591839738,-0.7568024953079282,-0.8182771110644103,-0.8715757724135882,-0.9161659367494549,-0.951602073889516,-0.977530117665097,-0.9936910036334644,-0.9999232575641008,-0.9961646088358407,-0.9824526126243325,-0.9589242746631385,-0.9258146823277325,-0.8834546557201531,-0.8322674422239013,-0.7727644875559871,-0.7055403255703919,-0.6312666378723216,-0.5506855425976376,-0.46460217941375737,-0.373876664830236,-0.27941549819892586,-0.18216250427209588,-0.0830894028174964,0.016813900484349713,0.11654920485049364,0.21511998808781552,0.31154136351337786,0.4048499206165983,0.49411335113860816,0.5784397643882001,0.6569865987187891,0.7289690401258759,0.7936678638491531,0.8504366206285644,0.8987080958116269,0.9379999767747389,0.9679196720314863,0.9881682338770004,0.998543345374605,0.998941341839772,0.9893582466233818,0.9698898108450863,0.9407305566797731,0.9021718337562933,0.8545989080882804,0.7984871126234903,0.7343970978741133,0.6629692300821833,0.5849171928917617,0.5010208564578846,0.4121184852417566,0.3190983623493521,0.22288991410024764,0.1244544235070617,0.024775425453357765,-0.0751511204618093,-0.17432678122297965,-0.27176062641094245,-0.3664791292519284,-0.45753589377532133,-0.5440211108893698,-0.6250706488928821,-0.6998746875935423,-0.7676858097635825,-0.8278264690856537,-0.87969575997167,-0.9227754216128066,-0.9566350162701879,-0.9809362300664916,-0.9954362533063774],"line":{"shape":"spline"},"mode":"lines"},{"x":[0.0,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1.0,1.1,1.2,1.3,1.4,1.5,1.6,1.7,1.8,1.9,2.0,2.1,2.2,2.3,2.4,2.5,2.6,2.7,2.8,2.9,3.0,3.1,3.2,3.3,3.4,3.5,3.6,3.7,3.8,3.9,4.0,4.1,4.2,4.3,4.4,4.5,4.6,4.7,4.8,4.9,5.0,5.1,5.2,5.3,5.4,5.5,5.6,5.7,5.8,5.9,6.0,6.1,6.2,6.3,6.4,6.5,6.6,6.7,6.8,6.9,7.0,7.1,7.2,7.3,7.4,7.5,7.6,7.7,7.8,7.9,8.0,8.1,8.2,8.3,8.4,8.5,8.6,8.7,8.8,8.9,9.0,9.1,9.2,9.3,9.4,9.5,9.6,9.7,9.8,9.9],"y":[0.8632093666488737,0.8084964038195901,0.7457052121767203,0.675463180551151,0.5984721441039565,0.5155013718214642,0.4273798802338298,0.3349881501559051,0.23924932921398243,0.1411200080598672,0.04158066243329049,-0.058374143427580086,-0.1577456941432482,-0.2555411020268312,-0.35078322768961984,-0.44252044329485246,-0.5298361409084934,-0.6118578909427189,-0.6877661591839738,-0.7568024953079282,-0.8182771110644103,-0.8715757724135882,-0.9161659367494549,-0.951602073889516,-0.977530117665097,-0.9936910036334644,-0.9999232575641008,-0.9961646088358407,-0.9824526126243325,-0.9589242746631385,-0.9258146823277325,-0.8834546557201531,-0.8322674422239013,-0.7727644875559871,-0.7055403255703919,-0.6312666378723216,-0.5506855425976376,-0.46460217941375737,-0.373876664830236,-0.27941549819892586,-0.18216250427209588,-0.0830894028174964,0.016813900484349713,0.11654920485049364,0.21511998808781552,0.31154136351337786,0.4048499206165983,0.49411335113860816,0.5784397643882001,0.6569865987187891,0.7289690401258759,0.7936678638491531,0.8504366206285644,0.8987080958116269,0.9379999767747389,0.9679196720314863,0.9881682338770004,0.998543345374605,0.998941341839772,0.9893582466233818,0.9698898108450863,0.9407305566797731,0.9021718337562933,0.8545989080882804,0.7984871126234903,0.7343970978741133,0.6629692300821833,0.5849171928917617,0.5010208564578846,0.4121184852417566,0.3190983623493521,0.22288991410024764,0.1244544235070617,0.024775425453357765,-0.0751511204618093,-0.17432678122297965,-0.27176062641094245,-0.3664791292519284,-0.45753589377532133,-0.5440211108893698,-0.6250706488928821,-0.6998746875935423,-0.7676858097635825,-0.8278264690856537,-0.87969575997167,-0.9227754216128066,-0.9566350162701879,-0.9809362300664916,-0.9954362533063774,-0.9999902065507035,-0.9945525882039892,-0.9791777291513174,-0.954019249902089,-0.9193285256646757,-0.8754521746884285,-0.8228285949687089,-0.7619835839190333,-0.6935250847771224,-0.6181371122370333],"line":{"shape":"spline"},"mode":"lines"},{"x":[0.0,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1.0,1.1,1.2,1.3,1.4,1.5,1.6,1.7,1.8,1.9,2.0,2.1,2.2,2.3,2.4,2.5,2.6,2.7,2.8,2.9,3.0,3.1,3.2,3.3,3.4,3.5,3.6,3.7,3.8,3.9,4.0,4.1,4.2,4.3,4.4,4.5,4.6,4.7,4.8,4.9,5.0,5.1,5.2,5.3,5.4,5.5,5.6,5.7,5.8,5.9,6.0,6.1,6.2,6.3,6.4,6.5,6.6,6.7,6.8,6.9,7.0,7.1,7.2,7.3,7.4,7.5,7.6,7.7,7.8,7.9,8.0,8.1,8.2,8.3,8.4,8.5,8.6,8.7,8.8,8.9,9.0,9.1,9.2,9.3,9.4,9.5,9.6,9.7,9.8,9.9],"y":[0.04158066243329049,-0.058374143427580086,-0.1577456941432482,-0.2555411020268312,-0.35078322768961984,-0.44252044329485246,-0.5298361409084934,-0.6118578909427189,-0.6877661591839738,-0.7568024953079282,-0.8182771110644103,-0.8715757724135882,-0.9161659367494549,-0.951602073889516,-0.977530117665097,-0.9936910036334644,-0.9999232575641008,-0.9961646088358407,-0.9824526126243325,-0.9589242746631385,-0.9258146823277325,-0.8834546557201531,-0.8322674422239013,-0.7727644875559871,-0.7055403255703919,-0.6312666378723216,-0.5506855425976376,-0.46460217941375737,-0.373876664830236,-0.27941549819892586,-0.18216250427209588,-0.0830894028174964,0.016813900484349713,0.11654920485049364,0.21511998808781552,0.31154136351337786,0.4048499206165983,0.49411335113860816,0.5784397643882001,0.6569865987187891,0.7289690401258759,0.7936678638491531,0.8504366206285644,0.8987080958116269,0.9379999767747389,0.9679196720314863,0.9881682338770004,0.998543345374605,0.998941341839772,0.9893582466233818,0.9698898108450863,0.9407305566797731,0.9021718337562933,0.8545989080882804,0.7984871126234903,0.7343970978741133,0.6629692300821833,0.5849171928917617,0.5010208564578846,0.4121184852417566,0.3190983623493521,0.22288991410024764,0.1244544235070617,0.024775425453357765,-0.0751511204618093,-0.17432678122297965,-0.27176062641094245,-0.3664791292519284,-0.45753589377532133,-0.5440211108893698,-0.6250706488928821,-0.6998746875935423,-0.7676858097635825,-0.8278264690856537,-0.87969575997167,-0.9227754216128066,-0.9566350162701879,-0.9809362300664916,-0.9954362533063774,-0.9999902065507035,-0.9945525882039892,-0.9791777291513174,-0.954019249902089,-0.9193285256646757,-0.8754521746884285,-0.8228285949687089,-0.7619835839190333,-0.6935250847771224,-0.6181371122370333,-0.5365729180004349,-0.44964746453460147,-0.3582292822368287,-0.26323179136580094,-0.1656041754483094,-0.06632189735120068,0.033623047221136695,0.13323204141994222,0.23150982510153895,0.32747443913769303],"line":{"shape":"spline"},"mode":"lines"},{"x":[0.0,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1.0,1.1,1.2,1.3,1.4,1.5,1.6,1.7,1.8,1.9,2.0,2.1,2.2,2.3,2.4,2.5,2.6,2.7,2.8,2.9,3.0,3.1,3.2,3.3,3.4,3.5,3.6,3.7,3.8,3.9,4.0,4.1,4.2,4.3,4.4,4.5,4.6,4.7,4.8,4.9,5.0,5.1,5.2,5.3,5.4,5.5,5.6,5.7,5.8,5.9,6.0,6.1,6.2,6.3,6.4,6.5,6.6,6.7,6.8,6.9,7.0,7.1,7.2,7.3,7.4,7.5,7.6,7.7,7.8,7.9,8.0,8.1,8.2,8.3,8.4,8.5,8.6,8.7,8.8,8.9,9.0,9.1,9.2,9.3,9.4,9.5,9.6,9.7,9.8,9.9],"y":[-0.8182771110644103,-0.8715757724135882,-0.9161659367494549,-0.951602073889516,-0.977530117665097,-0.9936910036334644,-0.9999232575641008,-0.9961646088358407,-0.9824526126243325,-0.9589242746631385,-0.9258146823277325,-0.8834546557201531,-0.8322674422239013,-0.7727644875559871,-0.7055403255703919,-0.6312666378723216,-0.5506855425976376,-0.46460217941375737,-0.373876664830236,-0.27941549819892586,-0.18216250427209588,-0.0830894028174964,0.016813900484349713,0.11654920485049364,0.21511998808781552,0.31154136351337786,0.4048499206165983,0.49411335113860816,0.5784397643882001,0.6569865987187891,0.7289690401258759,0.7936678638491531,0.8504366206285644,0.8987080958116269,0.9379999767747389,0.9679196720314863,0.9881682338770004,0.998543345374605,0.998941341839772,0.9893582466233818,0.9698898108450863,0.9407305566797731,0.9021718337562933,0.8545989080882804,0.7984871126234903,0.7343970978741133,0.6629692300821833,0.5849171928917617,0.5010208564578846,0.4121184852417566,0.3190983623493521,0.22288991410024764,0.1244544235070617,0.024775425453357765,-0.0751511204618093,-0.17432678122297965,-0.27176062641094245,-0.3664791292519284,-0.45753589377532133,-0.5440211108893698,-0.6250706488928821,-0.6998746875935423,-0.7676858097635825,-0.8278264690856537,-0.87969575997167,-0.9227754216128066,-0.9566350162701879,-0.9809362300664916,-0.9954362533063774,-0.9999902065507035,-0.9945525882039892,-0.9791777291513174,-0.954019249902089,-0.9193285256646757,-0.8754521746884285,-0.8228285949687089,-0.7619835839190333,-0.6935250847771224,-0.6181371122370333,-0.5365729180004349,-0.44964746453460147,-0.3582292822368287,-0.26323179136580094,-0.1656041754483094,-0.06632189735120068,0.033623047221136695,0.13323204141994222,0.23150982510153895,0.32747443913769303,0.4201670368266409,0.5086614643723737,0.592073514707223,0.6695697621966024,0.7403758899524486,0.803784426551621,0.8591618148564958,0.9059547423084618,0.9436956694441048,0.9720075013949759],"line":{"shape":"spline"},"mode":"lines"},{"x":[0.0,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1.0,1.1,1.2,1.3,1.4,1.5,1.6,1.7,1.8,1.9,2.0,2.1,2.2,2.3,2.4,2.5,2.6,2.7,2.8,2.9,3.0,3.1,3.2,3.3,3.4,3.5,3.6,3.7,3.8,3.9,4.0,4.1,4.2,4.3,4.4,4.5,4.6,4.7,4.8,4.9,5.0,5.1,5.2,5.3,5.4,5.5,5.6,5.7,5.8,5.9,6.0,6.1,6.2,6.3,6.4,6.5,6.6,6.7,6.8,6.9,7.0,7.1,7.2,7.3,7.4,7.5,7.6,7.7,7.8,7.9,8.0,8.1,8.2,8.3,8.4,8.5,8.6,8.7,8.8,8.9,9.0,9.1,9.2,9.3,9.4,9.5,9.6,9.7,9.8,9.9],"y":[-0.9258146823277325,-0.8834546557201531,-0.8322674422239013,-0.7727644875559871,-0.7055403255703919,-0.6312666378723216,-0.5506855425976376,-0.46460217941375737,-0.373876664830236,-0.27941549819892586,-0.18216250427209588,-0.0830894028174964,0.016813900484349713,0.11654920485049364,0.21511998808781552,0.31154136351337786,0.4048499206165983,0.49411335113860816,0.5784397643882001,0.6569865987187891,0.7289690401258759,0.7936678638491531,0.8504366206285644,0.8987080958116269,0.9379999767747389,0.9679196720314863,0.9881682338770004,0.998543345374605,0.998941341839772,0.9893582466233818,0.9698898108450863,0.9407305566797731,0.9021718337562933,0.8545989080882804,0.7984871126234903,0.7343970978741133,0.6629692300821833,0.5849171928917617,0.5010208564578846,0.4121184852417566,0.3190983623493521,0.22288991410024764,0.1244544235070617,0.024775425453357765,-0.0751511204618093,-0.17432678122297965,-0.27176062641094245,-0.3664791292519284,-0.45753589377532133,-0.5440211108893698,-0.6250706488928821,-0.6998746875935423,-0.7676858097635825,-0.8278264690856537,-0.87969575997167,-0.9227754216128066,-0.9566350162701879,-0.9809362300664916,-0.9954362533063774,-0.9999902065507035,-0.9945525882039892,-0.9791777291513174,-0.954019249902089,-0.9193285256646757,-0.8754521746884285,-0.8228285949687089,-0.7619835839190333,-0.6935250847771224,-0.6181371122370333,-0.5365729180004349,-0.44964746453460147,-0.3582292822368287,-0.26323179136580094,-0.1656041754483094,-0.06632189735120068,0.033623047221136695,0.13323204141994222,0.23150982510153895,0.32747443913769303,0.4201670368266409,0.5086614643723737,0.592073514707223,0.6695697621966024,0.7403758899524486,0.803784426551621,0.8591618148564958,0.9059547423084618,0.9436956694441048,0.9720075013949759,0.9906073556948704,0.9993093887479176,0.9980266527163617,0.9867719642746133,0.9656577765492774,0.934895055524683,0.8947911721405042,0.8457468311429343,0.7882520673753163,0.722881349511976],"line":{"shape":"spline"},"mode":"lines"}],
|
50
|
+
{},
|
51
|
+
{"linkText":"Export to plot.ly","showLink":true}
|
52
|
+
)
|
53
|
+
|
54
|
+
window.addEventListener('resize', function() {
|
55
|
+
Plotly.Plots.resize(document.getElementById('534e55c3-1450-49c9-85f0-1a227ed26e7d'))
|
56
|
+
})
|
57
|
+
})
|
58
|
+
</script>
|
59
|
+
|
60
|
+
</article>
|
61
|
+
</body>
|
62
|
+
</html>
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# rbplotly line plot usage
|
2
|
+
|
3
|
+
~~~ruby
|
4
|
+
require 'rbplotly'
|
5
|
+
|
6
|
+
plot = Plotly::Plot.new
|
7
|
+
flip = -1
|
8
|
+
x = (0...100).map { |i| i.to_f / 10 }
|
9
|
+
(0..5).each do |i|
|
10
|
+
trace = {
|
11
|
+
x: x,
|
12
|
+
y: (1...100).map { |j| Math.sin(j.to_f / 10 + i) },
|
13
|
+
line: { shape: :spline },
|
14
|
+
mode: :lines
|
15
|
+
}
|
16
|
+
plot.data.push(trace)
|
17
|
+
end
|
18
|
+
plot
|
19
|
+
~~~
|
@@ -0,0 +1,100 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
5
|
+
<link href='https://cdnjs.cloudflare.com/ajax/libs/github-markdown-css/2.10.0/github-markdown.min.css' rel='stylesheet' type='text/css' />
|
6
|
+
<style>
|
7
|
+
article.markdown-body {
|
8
|
+
box-sizing: border-box;
|
9
|
+
min-width: 200px;
|
10
|
+
max-width: 980px;
|
11
|
+
margin: 0 auto;
|
12
|
+
padding: 45px;
|
13
|
+
}
|
14
|
+
|
15
|
+
span.line-numbers {
|
16
|
+
display: none;
|
17
|
+
}
|
18
|
+
</style>
|
19
|
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.6/require.min.js"></script>
|
20
|
+
</head>
|
21
|
+
<body>
|
22
|
+
<article class='markdown-body'>
|
23
|
+
<h1 id="rbplotly-pie-chart-usage">rbplotly pie chart usage</h1>
|
24
|
+
|
25
|
+
<h2 id="basic-pie-chart">Basic pie chart</h2>
|
26
|
+
|
27
|
+
<pre><code class="language-ruby">require 'rbplotly'
|
28
|
+
|
29
|
+
data = [{
|
30
|
+
labels: %w(Residential Non-Residential Utility),
|
31
|
+
values: [19, 26, 55],
|
32
|
+
type: :pie
|
33
|
+
}]
|
34
|
+
|
35
|
+
layout = { title: 'Forcasted 2014 U.S. PV Installations by Market Segment' }
|
36
|
+
|
37
|
+
plot = Plotly::Plot.new(data: data, layout: layout )
|
38
|
+
</code></pre>
|
39
|
+
<script>
|
40
|
+
requirejs.config({paths: { 'plotly': ['https://cdn.plot.ly/plotly-latest.min'] }})
|
41
|
+
</script>
|
42
|
+
<div id="e019765d-6d5f-4dc2-9fce-0fa3ee21a906" style="height: 100%; width: 100%;"></div>
|
43
|
+
<script>
|
44
|
+
require(['plotly'], function(Plotly) {
|
45
|
+
Plotly.newPlot(
|
46
|
+
'e019765d-6d5f-4dc2-9fce-0fa3ee21a906',
|
47
|
+
[{"labels":["Residential","Non-Residential","Utility"],"values":[19,26,55],"type":"pie"}],
|
48
|
+
{"title":"Forcasted 2014 U.S. PV Installations by Market Segment"},
|
49
|
+
{"linkText":"Export to plot.ly","showLink":true}
|
50
|
+
)
|
51
|
+
|
52
|
+
window.addEventListener('resize', function() {
|
53
|
+
Plotly.Plots.resize(document.getElementById('e019765d-6d5f-4dc2-9fce-0fa3ee21a906'))
|
54
|
+
})
|
55
|
+
})
|
56
|
+
</script>
|
57
|
+
|
58
|
+
<h2 id="donut-chart">Donut chart</h2>
|
59
|
+
|
60
|
+
<pre><code class="language-ruby">trace1 = {
|
61
|
+
name: 'GHG Emissions',
|
62
|
+
values: [16, 15, 12, 6, 5, 4, 42],
|
63
|
+
domain: { x: [0, 0.5] },
|
64
|
+
|
65
|
+
labels: %w(US China European Union Russian Federation Brazil India Rest\ of\ World),
|
66
|
+
hoverinfo: :'label+percent+name',
|
67
|
+
hole: 0.4,
|
68
|
+
type: :pie,
|
69
|
+
}
|
70
|
+
|
71
|
+
trace2 = trace1.merge({
|
72
|
+
name: 'CO2 Emissions',
|
73
|
+
values: [27, 11, 25, 8, 1, 3, 25],
|
74
|
+
domain: { x: [0.5, 1] }
|
75
|
+
})
|
76
|
+
|
77
|
+
plot = Plotly::Plot.new(data: [trace1, trace2])
|
78
|
+
</code></pre>
|
79
|
+
<script>
|
80
|
+
requirejs.config({paths: { 'plotly': ['https://cdn.plot.ly/plotly-latest.min'] }})
|
81
|
+
</script>
|
82
|
+
<div id="30fc5284-239a-4dc0-b3c9-9f273327538c" style="height: 100%; width: 100%;"></div>
|
83
|
+
<script>
|
84
|
+
require(['plotly'], function(Plotly) {
|
85
|
+
Plotly.newPlot(
|
86
|
+
'30fc5284-239a-4dc0-b3c9-9f273327538c',
|
87
|
+
[{"labels":["US","China","European","Union","Russian","Federation","Brazil","India","Rest of World"],"values":[16,15,12,6,5,4,42],"type":"pie","name":"GHG Emissions","domain":{"x":[0,0.5]},"hoverinfo":"label+percent+name","hole":0.4},{"labels":["US","China","European","Union","Russian","Federation","Brazil","India","Rest of World"],"values":[27,11,25,8,1,3,25],"type":"pie","name":"CO2 Emissions","domain":{"x":[0.5,1]},"hoverinfo":"label+percent+name","hole":0.4}],
|
88
|
+
{},
|
89
|
+
{"linkText":"Export to plot.ly","showLink":true}
|
90
|
+
)
|
91
|
+
|
92
|
+
window.addEventListener('resize', function() {
|
93
|
+
Plotly.Plots.resize(document.getElementById('30fc5284-239a-4dc0-b3c9-9f273327538c'))
|
94
|
+
})
|
95
|
+
})
|
96
|
+
</script>
|
97
|
+
|
98
|
+
</article>
|
99
|
+
</body>
|
100
|
+
</html>
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# rbplotly pie chart usage
|
2
|
+
|
3
|
+
## Basic pie chart
|
4
|
+
|
5
|
+
~~~ruby
|
6
|
+
require 'rbplotly'
|
7
|
+
|
8
|
+
data = [{
|
9
|
+
labels: %w(Residential Non-Residential Utility),
|
10
|
+
values: [19, 26, 55],
|
11
|
+
type: :pie
|
12
|
+
}]
|
13
|
+
|
14
|
+
layout = { title: 'Forcasted 2014 U.S. PV Installations by Market Segment' }
|
15
|
+
|
16
|
+
plot = Plotly::Plot.new(data: data, layout: layout )
|
17
|
+
~~~
|
18
|
+
|
19
|
+
## Donut chart
|
20
|
+
|
21
|
+
~~~ruby
|
22
|
+
trace1 = {
|
23
|
+
name: 'GHG Emissions',
|
24
|
+
values: [16, 15, 12, 6, 5, 4, 42],
|
25
|
+
domain: { x: [0, 0.5] },
|
26
|
+
|
27
|
+
labels: %w(US China European Union Russian Federation Brazil India Rest\ of\ World),
|
28
|
+
hoverinfo: :'label+percent+name',
|
29
|
+
hole: 0.4,
|
30
|
+
type: :pie,
|
31
|
+
}
|
32
|
+
|
33
|
+
trace2 = trace1.merge({
|
34
|
+
name: 'CO2 Emissions',
|
35
|
+
values: [27, 11, 25, 8, 1, 3, 25],
|
36
|
+
domain: { x: [0.5, 1] }
|
37
|
+
})
|
38
|
+
|
39
|
+
plot = Plotly::Plot.new(data: [trace1, trace2])
|
40
|
+
~~~
|