📊 GR framework - powerful visualization library - for Ruby
GR.rb supports Ruby 2.5+.
First, install GR. Then install
gem install gr-plot
pkg-config will detect the location of the shared library. Otherwise, you need to specify the environment variable.
require 'gr/plot' x = [0, 0.2, 0.4, 0.6, 0.8, 1.0] y = [0.3, 0.5, 0.4, 0.2, 0.6, 0.7] # show the figure GR.plot(x, y) # Save the figure in PNG format. GR.savefig("figure.png")
GR.rb supports Jupyter Notebook / Lab.
require 'gr/plot' GR.plot(x, y)
List of available functions.
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)
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)
Using GR.rb non-interactively
Both APIs will by default start a Qt based window to show the result of the last call.
This behavior is caused by GR itself as it will implicitly generate output to a file or application.
If you want to use GR.rb non-interactively, eg., as part of a static site build, you can do this by setting the environment variable
Installing an official release (recommended)
Download the latest release and place it where you want. Then set environment variable
macOS : See "How to open apps from un-notarized or unidentified developers" in the Apple documentation.
Using package managers
The third party GR packages for Mac, Linux and Windows are available for advanced users. However, these packages are provided by OSS volunteers and may not be the latest version or support some features (such as video output). If you find any problem, please report the issue here.
Mac - Homebrew
brew install libgr export GKS_WSTYPE=411 # Set the workstation type to gksqt (recommended)
Linux - openSUSE Build service
GR will be installed in
/usr/gr. Set one of the following environment variables so that GR.rb can find the library.
export GRDIR="/usr/gr" # Check the location with `dpkg -L gr`
Windows - MSYS2
If you are using Rubyinstaller, pacman will automatically install mingw-w64-gr when the gem is installed.
GR.rb is a library under development, so even small improvements like fixing typos are welcome! Please feel free to send us your PR.
- Report bugs
- Fix bugs and submit pull requests
- Write, clarify, or fix documentation
- Suggest or add new features
- Update GR packages ( Homebrew, MinGW, red-data-tools )
- Create visualization tools based on GR.rb
If you are not familiar with Ruby gem development, please see I'm new to Ruby
Do you need commit rights to my repository? Do you want to get admin rights and take over the project? If so, please feel free to contact us.
I've seen a lot of OSS abandoned because no one has commit rights to the original repository anymore; the right to request commit rights for GR.rb is always open.