At first, we need to load libraries to be used here. We use the following libraries.
charty
for data visualizationdatasets-pandas
for loading open datasets provided by red-datasets
and using it with Pandas's data framenumo/narray
for some numerical array operationsYou can execute the following code cell by selecting the cell and then hit Shift+Enter.
require "charty"
require "datasets-pandas" # This loads "datasets" and "pandas"
require "numo/narray"
{
charty: Charty::VERSION,
datasets_pandas: DatasetsPandas::VERSION,
numo_narray: Numo::NArray::VERSION
}
In this notebook, we use plotly backend to create plots.
Charty::Backends.use(:plotly)
Datasets::Penguins
is a Ruby port of palmerpenguins dataset. This dataset includes measurements for penguin species, island in Palmer Archipelago, size (flipper length, body mass, bill dimensions), sex, and year.
We will use this dataset in this notebook.
penguins = Datasets::Penguins.new.to_pandas
And, we will use the fmri
dataset provided in seaborn for the line plot examples. red-datasets also provides this dataset.
fmri = Datasets::SeabornData.new("fmri").to_pandas
Simple scatter plot to show the relationship between bill_length_mm
and bill_depth_mm
.
Charty.scatter_plot(
data: penguins, # input table data
x: :bill_length_mm, # the column name for x-axis
y: :bill_depth_mm # the column name for y-axis
)