Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/crystal-data/gr.cr

Crystal wrapper for the GR framework
https://github.com/crystal-data/gr.cr

charts crystal data-visualization plotting

Last synced: 4 days ago
JSON representation

Crystal wrapper for the GR framework

Awesome Lists containing this project

README

        

# GR.cr

[![Join the chat at https://gitter.im/crystal-data/bottle](https://badges.gitter.im/crystal-data/bottle.svg)](https://gitter.im/crystal-data/bottle?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
[![.github/workflows/ci.yml](https://github.com/crystal-data/GR.cr/actions/workflows/ci.yml/badge.svg)](https://github.com/crystal-data/GR.cr/actions/workflows/ci.yml)

GR.rb

[Crystal](https://github.com/crystal-lang/crystal) bindings to [GR framework](https://github.com/sciapp/gr).

GR.cr has been forked from [gr-crystal](https://github.com/jmakino/gr-crystal) by [Jun Makino](https://github.com/jmakino).

## Installation

### GR Installation

#### [Official release](https://github.com/sciapp/gr/releases) - Linux, Mac, Windows

Set `GRDIR` : `export GRDIR="your/path/to/gr"`

#### [OpenSUSE build service](https://software.opensuse.org//download.html?project=science%3Agr-framework&package=gr) - Linux

Set `GRDIR` : `export GRDIR="/usr/gr"`

#### [Homebrew](https://formulae.brew.sh/formula/libgr) - Mac

`brew install libgr`

### GR.cr installation

Add the dependency to your `shard.yml`:

```yaml
dependencies:
gr:
github: crystal-data/GR.cr
```

Run `shards install`

## API Overview

* `libGR`, `libGR3`, `libGRM` : call native functions directly.
* `GR`, `GR3`, `GRM` : call module function customized for Crystal.

```
┌──────────────┐ ┌──────────────┐ ┌──────────────┐
│ GRM │ │ GR │ │ GR3 │
│ ┌──────────┐ │ │ ┌──────────┐ │ │ ┌──────────┐ │
│ │ LibGRM │ │ │ │ LibGR │ │ │ │ LibGR3 │ │
│ └──────────┘ │ │ └──────────┘ │ │ └──────────┘ │
└──────────────┘ └──────────────┘ └──────────────┘
```

GR.cr is still immature, but even in its current state, GRM can be used to create good quality figures.

## Quick Start

With the GRM module, you can easily display beautiful charts.

```crystal
require "../src/grm"

n = 1000
x = [] of Float64
y = [] of Float64
z = [] of Float64
n.times do |i|
x << i * 30.0 / n
y << Math.cos(x[i]) * x[i]
z << Math.sin(x[i]) * x[i]
end

plot_types = %w[line hexbin polar shade stem step contour
trisurf plot3 scatter scatter3]

plot_types.each do |type|
GRM.clear
args = GRM.args_new
GRM.args_push(args, "x", "nD", n, x)
GRM.args_push(args, "y", "nD", n, y)
GRM.args_push(args, "z", "nD", n, z)
GRM.args_push(args, "kind", "s", type)
GRM.args_push(args, "title", "s", type)
GRM.plot(args)
sleep 2
end
```

## Usage

Please see the example directory.

With GR and GR3 modules, you can do more serious visualization.
However, you may find that GR.cr is not fully implemented.
In that case, please send me a pull request.

## Development

Low-level bindings are automatically generated by [crystal_lib](https://github.com/crystal-lang/crystal_lib).

GR.cr is a library under development, so even small improvements like fixing typos are welcome! Please feel free to send us your PR.
The author is not familiar with Crystal, so it may be written in an inefficient way, and you may be able to fix it.

* Look at [GR.rb](https://github.com/red-data-tools/GR.rb) and implement the missing methods!
* Report bugs
* Fix bugs and submit pull requests
* Write, clarify, or fix documentation
* Suggest or add new features

```
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 @kojix2.
```

## Acknowledgements

We would like to thank Josef Heinen, the creator of [GR](https://github.com/sciapp/gr) and [GR.jl](https://github.com/jheinen/GR.jl), Florian Rhiem, the creator of [python-gr](https://github.com/sciapp/python-gr), and all [GR](https://github.com/sciapp/gr) developers.