package

github.com/naqvis/cryplot

0.2.1 / published Dec 24, 2025 / repository

Crystal plotting library powered by gnuplot. Create 2D/3D plots, scatter charts, heatmaps, bar charts, box plots, and more with an expressive DSL. Supports dual Y-axis, log scales, annotations, date/time axes, color mapping, and extensive customization options.

Crystal Plotting Shard

Cryplot is Crystal plotting library powered by gnuplot. The goal of the Cryplot is to enable you, Crystal programmer, to conveniently plot beautiful graphs as easy as in other high-level programming languages.

The only external runtime dependencies is gnuplot executable and it need to be in your system path.

gnuplot-palettes color palettes are downloaded at shard installation and made available to your use via simply invoking the plot#palette and passing in any available palette enum Cryplot::Palette.

Installation

  1. Add the dependency to your shard.yml:

    dependencies:
      cryplot:
        github: naqvis/cryplot
  2. Run shards install

Example 1

require "cryplot"

# Create a vector with values from 0 to 5 divived into 100 uniform intervals
x = Cryplot.linspace(0.0, 5.0, 100)

# Create a plot object
Cryplot.plot {
  # set color palette
  palette(:set2)

  # Draw a sine graph putting x on the x-axis and sin(x) on the y-axis
  draw_curve(x, x.map { |v| Math.sin(v) }).label("sin(x)").line_width(4)

  # Draw a cosine graph putting x on the x-axis and cos(x) on the y-axis
  draw_curve(x, x.map { |v| Math.cos(v) }).label("cos(x)").line_width(4)

  # Show the plot in a pop-up window
  show

  # Save the plot a PDF file
  save("plot.pdf")
}

Running above sample code will produce and show you following plot:

Refer to specs or examples folder for further samples.

Available Color Palettes

Do you want to change the colors?

All available color palettes and their names can be found here.

Development

To run all tests:

crystal spec

Contributing

  1. Fork it (https://github.com/naqvis/cryplot/fork)
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Contributors

API

  • Cryplot

    Crystal plotting library powered by gnuplot