[go: up one dir, main page]

Skip to content

crystal-data/GR.cr

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GR.cr

Join the chat at https://gitter.im/crystal-data/bottle .github/workflows/ci.yml

GR.rb

Crystal bindings to GR framework.

GR.cr has been forked from gr-crystal by Jun Makino.

Installation

GR Installation

Official release - Linux, Mac, Windows

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

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

Homebrew - Mac

brew install libgr

GR.cr installation

Add the dependency to your shard.yml:

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.

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.

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 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 and GR.jl, Florian Rhiem, the creator of python-gr, and all GR developers.

Releases

No releases published

Sponsor this project

Packages

No packages published