In [1]:
require 'nyaplot'
plot = Nyaplot::Plot.new
sc = plot.add(:scatter, [0,1,2,3,4], [-1,2,-3,4,-5])
plot.show
In [2]:
df = Nyaplot::DataFrame.new({a: [0,1,2,3,4], b: [-1,2,-3,4,-5], type: ['a','b','a','a','b']})
sc = plot.add_with_df(df, :scatter, :a, :b)
sc.fill_by(:type)
plot.show
In [4]:
require 'rbplotly'

trace1 = { x: [1,2,3,4,5,6], y: [100,200,300,400,500,600] }
trace2 = { x: [1,2,3,4,5,6], y: [600,500,400,300,200,100] }
traces = [trace1, trace2]
pl = Plotly::Plot.new(data: traces)
pl.show
In [3]:
require 'daru'

df = Daru::DataFrame.from_csv('./O_TUKIBETSU_NENREI.csv')
Out[3]:
Daru::DataFrame(107x6)
year month age male female total_count
0 2018 4 0 427 416 843
1 2018 4 1 424 456 880
2 2018 4 2 474 453 927
3 2018 4 3 476 457 933
4 2018 4 4 501 442 943
5 2018 4 5 491 434 925
6 2018 4 6 490 478 968
7 2018 4 7 536 486 1022
8 2018 4 8 515 464 979
9 2018 4 9 543 504 1047
10 2018 4 10 527 537 1064
11 2018 4 11 545 516 1061
12 2018 4 12 542 502 1044
13 2018 4 13 571 556 1127
14 2018 4 14 590 546 1136
15 2018 4 15 585 569 1154
16 2018 4 16 654 623 1277
17 2018 4 17 630 651 1281
18 2018 4 18 544 592 1136
19 2018 4 19 603 581 1184
20 2018 4 20 515 512 1027
21 2018 4 21 550 556 1106
22 2018 4 22 466 488 954
23 2018 4 23 543 522 1065
24 2018 4 24 506 507 1013
25 2018 4 25 532 493 1025
26 2018 4 26 555 543 1098
27 2018 4 27 531 515 1046
28 2018 4 28 577 532 1109
29 2018 4 29 601 589 1190
... ... ... ... ... ... ...
106 2018 4 106 1 1 2
In [5]:
require 'daru/plotly'
include Daru::Plotly::Methods # plotメソッドが使えるようになる

plot(df, x: 'age', y: 'total_count')
plot(df, x: 'age', y: ['total_count', 'male', 'female']).show
In [4]:
require 'pandas'
pd = Pandas
x = pd.read_csv('./O_TUKIBETSU_NENREI.csv')
p x.shape
(107, 6)
Out[4]:
(107, 6)
In [ ]: