# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .r
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Ruby 2.4.1
#     language: ruby
#     name: ruby
# ---

# # IRuby and matplotlib (through PyCall) integration example
#
# ## Install matplotlib
#
# You can install matplotlib by `gem install --pre matplotlib`.
# matplotlib.gem depends on pycall.gem so you don't need to install pycall explicitly.
#
# ## How to use matplotlib in IRuby
#
# You should call `Matplotlib::IRuby.activate` method defined in `matplotlib/iruby` to prepare the integration between IRuby and matplotlib.
#
# This method defines `Matplotlib::Pyplot` module that has singleton methods connected to functions defined in `matplotlib.pyplot` module in Python-side.
#
# Also, this method defines the way to display matplotlib's figure as an output of execution. When you display the current figure, you can call `Matplotlib::Pyplot.gcf` method at the end of the code cell.
#
# ## Example code

require 'matplotlib/iruby'
Matplotlib::IRuby.activate
plt = Matplotlib::Pyplot

plt.plot([1, 2, 3, 4, 5], [1, 2, 3, 1, 2])

# Multiple plots in a figure
plt.plot([1, 2, 3, 4, 5], [1, 2, 3, 1, 2])
plt.plot([10, 20, 30, 40, 50], [1, 2, 3, 1, 2])

# +
# Multiple figures
plt.figure()
plt.plot([1, 2, 3, 4, 5], [1, 2, 3, 1, 2])

plt.figure()
plt.plot([10, 20, 30, 40, 50], [1, 2, 3, 1, 2])
# -



StarcoderdataJupyterScriptsDedupFiltered