https://github.com/kojix2/nuplot
Running Gnuplot with Crystal.
https://github.com/kojix2/nuplot
crystal gnuplot
Last synced: 9 months ago
JSON representation
Running Gnuplot with Crystal.
- Host: GitHub
- URL: https://github.com/kojix2/nuplot
- Owner: kojix2
- License: mit
- Created: 2018-02-10T13:40:28.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2018-03-17T09:51:45.000Z (almost 8 years ago)
- Last Synced: 2025-03-27T13:51:26.670Z (9 months ago)
- Topics: crystal, gnuplot
- Language: Crystal
- Homepage:
- Size: 45.9 KB
- Stars: 6
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# nuplot
This is a minimum tool for running Gnuplot with Crystal.
## Installation
Add this to your application's `shard.yml`:
```yaml
dependencies:
nuplot:
github: kojix2/nuplot
```
## Usage
```crystal
require "nuplot"
```

```crystal
Gnuplot.plot do |s|
s << "plot sin(x)"
end
```

```crystal
x = Array(Float64).new(100){ rand(10.0..20.0) }
y = Array(Float64).new(100){ rand(100.0..200.0) }
Gnuplot.plot do |s|
s << "set title 'SCATTER'"
s << "plot '-' pt 6 lt rgb 'red' t 'circle'"
s << to_gp([x, y])
end
```

```crystal
memo = 0
x = Array(Float64).new(100,0.0)
# Optimistic random walk
100.times do |i|
memo = memo + rand(-0.9..1.0)
x[i] = memo
end
Gnuplot.plot do |s|
s << "set title 'LINES'"
s << "plot '-' with lines title 'x'"
s << to_gp(x)
end
```

```crystal
x = Array(Float64).new(1000){ rand(-10.0..10.0) }
y = Array(Float64).new(1000){ rand(-10.0..10.0) }
z = Array(Float64).new(1000){ |i| x[i]**2 + y[i]**2 }
Gnuplot.plot do |s|
s << "set title 'SCATTER 3D'"
s << "splot '-' pt 6 t 'z=x^2+y^2'"
s << to_gp([x,y,z])
end
```
## Development
What I do not do
- Replacing the gnuplot idiom with a new Crystal object.
## Contributing
- bird1079s
Pull requests are always welcome.