Skip to content

Latest commit

 

History

History
206 lines (147 loc) · 7.83 KB

README.md

File metadata and controls

206 lines (147 loc) · 7.83 KB

GR.rb

Gem Version CI Gitter Chat Docs Latest

rdatasets-1 stem histogram barplot scatter3 volume griddata 2darray 2dpolararray hexbin rdatasets-2 rdatasets-3 surface face shade

📊 GR framework - powerful visualization library - for Ruby

Installation

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"

Quick Start

👉 Wiki -plotting functions

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.

API Overview

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.

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 GKS_WSTYPEto 100.

export GKS_WSTYPE=100

Documentation

GR Installation

Installing an official release (recommended)

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.

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 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"

Windows - MSYS2

If you are using Rubyinstaller, pacman will automatically install mingw-w64-gr when the gem is installed.

Contributing

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.

Acknowledgements

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.