Skip to content

jheinen/GR.jl

master
Switch branches/tags
Code

The GR module for Julia

The MIT License GitHub tag GR Downloads DOI Binder Join the chat at https://gitter.im/jheinen/GR.jl

Screenshots

This module provides a Julia interface to GR, a framework for visualisation applications.

Installation

From the Julia REPL an up to date version can be installed with:

Pkg.add("GR")

or in the Pkg REPL-mode:

add GR

The Julia package manager will download and install a pre-compiled run-time (for your hardware architecture), if the GR software is not already installed in the recommended locations.

Getting started

In Julia simply type using GR and begin calling functions in the GR framework API.

Let's start with a simple example. We generate 10,000 random numbers and create a histogram. The histogram function automatically chooses an appropriate number of bins to cover the range of values in x and show the shape of the underlying distribution.

using GR
histogram(randn(10000))

Using GR as backend for Plots.jl

Plots is a powerful wrapper around other Julia visualization "backends", where GR seems to be one of the favorite ones. To get an impression how complex visualizations may become easier with Plots, take a look at these examples.

Plots is great on its own, but the real power comes from the ecosystem surrounding it. You can find more information here.

Alternatives

Besides GR and Plots there is a nice package called GRUtils which provides a user-friendly interface to the low-level GR subsytem, but in a more "Julian" and modular style. Newcomers are recommended to use this package. A detailed documentation can be found here.

GR and GRUtils are currently still being developed in parallel - but there are plans to merge the two modules in the future.

Run-time environment

GR.jl is a wrapper for the GR Framework. Therefore, the GR run-time libraries are required to use the software. These are provided via the GR_jll.jl package, which is an autogenerated package constructed using BinaryBuilder. This is the default setting.

Another alternative is the use of binaries from GR tarballs, which are provided directly by the GR developers as stand-alone distributions for selected platforms - regardless of the programming language. In this case, only one GR runtime environment is required for different language environments (Julia, Python, C/C++), whose installation path can be specified by the environment variable GRDIR.

ENV["JULIA_DEBUG"] = "GR" # Turn on debug statements for the GR package
ENV["GRDIR"] = "<path of you GR installation>" # e.g. "/usr/local/gr"
using GR

For more information about setting up a local GR installation, see the GR Framework website.

However, if you want to permanently use your own GR run-time, you have to set the environment variable GRDIR accordingly before starting Julia, e.g.

  • macOS or Linux: export GRDIR=/usr/local/gr
  • Windows: set GRDIR=C:\gr

Please note that with the method shown here, GR_jll is not imported.

About

Plotting for Julia based on GR, a framework for visualisation applications

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages