Skip to content
kojix2 edited this page Feb 23, 2023 · 14 revisions

There are two different approaches to plotting with GR.rb. One way is to call Matlab-like APIs. The other is to call GR/GR3 native functions.

GR::Plot - A simple, Matlab-style API.

require 'gr/plot'
GR.plot(x, y)

List of available functions.

plot step plot3 polar scatter scatter3 stem barplot histogram polarhistogram hexbin contour contourf tricont surface trisurf wireframe volume heatmap polarheatmap shade imshow isosurface

Note: When you do require 'gr/plot', Matlab-style methods are added to the GR module. And some native functions of GR modules will be overwritten by these methods. Keep in mind that these changes is not available in the yard document at the moment.

GR - A module for calling native GR functions.

2-D Plots and common 3-D Plots.

require 'gr'

# For example
GR.setviewport(0.1, 0.9, 0.1, 0.9)
GR.setwindow(0.0, 20.0, 0.0, 20.0)

Note: The GR module does not depend on numo-narray. So even if you cannot compile native extensions for some reason, you can still use GR module. In that case, edit the gemspec and remove the numo-narray from the dependency.

GR3 - A module for calling native GR3 functions.

Complex 3D scenes.

require 'gr3'

# For example
GR3.cameralookat(-3, 2, -2, 0, 0, 0, 0, 0, -1)

GRM

under development.