π GR framework - powerful visualization library - for Ruby
First, install GR. Then install gr-plot
gem.
gem install gr-plot
pkg-config will detect the location of the shared library. Otherwise, you need to specify the environment variable.
export GRDIR="/your/path/to/gr"
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.
plot
step
plot3
polar
scatter
scatter3
stem
barplot
histogram
polarhistogram
hexbin
contour
contourf
tricont
surface
trisurf
wireframe
volume
heatmap
polarheatmap
shade
imshow
isosurface
See GR.rb Wiki for details. Some GR module methods are overwritten. Code has been moved to gr-plot.
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)
Complex 3D scenes.
require 'gr3'
# For example
GR3.cameralookat(-3, 2, -2, 0, 0, 0, 0, 0, -1)
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 GKS_WSTYPE
to 100
.
export GKS_WSTYPE=100
- GR.rb Wiki
- GR.rb API Documentation - Yard documents.
- GR Framework - The official GR reference.
Download the latest release and place it where you want. Then set environment variable GRDIR
.
export GRDIR="your/path/to/gr"
macOS : See "How to open apps from un-notarized or unidentified developers" in the Apple documentation.
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.
brew install libgr
export GKS_WSTYPE=411 # Set the workstation type to gksqt (recommended)
GR releases are also available from the openSUSE Build service for CentOS, Debian, Fedora openSUSE and Ubuntu. Obtain a packaged release here.
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`
export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:/usr/gr/lib/pkgconfig"
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.
We would like to thank Josef Heinen, the creator of GR and GR.jl, Florian Rhiem, the creator of python-gr, and all GR developers.