├── .github
└── workflows
│ └── ci.yml
├── .gitignore
├── LICENSE
├── Makefile
├── README.md
├── etc
├── examples
│ ├── 1.cr
│ ├── 1.png
│ ├── 2.cr
│ ├── 2.png
│ ├── 3.cr
│ ├── 3.png
│ ├── 4.cr
│ ├── 4.png
│ ├── 4.yml
│ ├── 5.cr
│ ├── 5.png
│ ├── 5.yml
│ ├── 6.cr
│ ├── 6.png
│ ├── 7.cr
│ └── 7.png
└── palettes
│ ├── hot.pal
│ ├── inferno.pal
│ ├── jet.pal
│ ├── magma.pal
│ ├── plasma.pal
│ └── viridis.pal
├── shard.yml
├── spec
├── ishi
│ ├── chart_spec.cr
│ ├── gnuplot_spec.cr
│ └── term_spec.cr
├── ishi_spec.cr
└── spec_helper.cr
└── src
├── ishi.cr
└── ishi
├── base.cr
├── gnuplot.cr
├── html.cr
├── iterm2.cr
├── png.cr
├── term.cr
└── text.cr
/.github/workflows/ci.yml:
--------------------------------------------------------------------------------
1 | name: build
2 | on:
3 | push:
4 | pull_request:
5 | branches: [main]
6 | schedule:
7 | - cron: '0 6 * * 6'
8 | jobs:
9 | test:
10 | strategy:
11 | fail-fast: false
12 | matrix:
13 | os: [ubuntu-latest, macos-latest]
14 | crystal: [latest]
15 | runs-on: ${{ matrix.os }}
16 | steps:
17 | - name: Download source
18 | uses: actions/checkout@v2
19 | - name: Install Crystal
20 | uses: crystal-lang/install-crystal@31648d0e69d6c8eaccb0b483bb2283515b1153ae
21 | with:
22 | crystal: ${{ matrix.crystal }}
23 | - name: Install shards
24 | run: shards update
25 | - name: Run tests
26 | run: crystal spec
27 | - name: Build docs
28 | run: crystal docs
29 | - name: Deploy docs
30 | if: github.event_name == 'push' && github.ref == 'refs/heads/main'
31 | uses: oprypin/push-to-gh-pages@b16c4c1926875f4d9fce26ffc60a623b003231d2
32 | with:
33 | publish_dir: ./docs
34 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | /docs/
2 | /lib/
3 | /bin/
4 | /.shards/
5 | /shard.lock
6 | *.dwarf
7 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright 2020 Todd Sundsted
2 |
3 | Licensed under the Apache License, Version 2.0 (the "License");
4 | you may not use this file except in compliance with the License.
5 | You may obtain a copy of the License at
6 |
7 | http://www.apache.org/licenses/LICENSE-2.0
8 |
9 | Unless required by applicable law or agreed to in writing, software
10 | distributed under the License is distributed on an "AS IS" BASIS,
11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | See the License for the specific language governing permissions and
13 | limitations under the License.
14 |
--------------------------------------------------------------------------------
/Makefile:
--------------------------------------------------------------------------------
1 | .SUFFIXES: .cr .png
2 |
3 | PNGS = etc/examples/1.png etc/examples/2.png \
4 | etc/examples/3.png etc/examples/4.png \
5 | etc/examples/5.png
6 |
7 | .cr.png:
8 | crystal run --define png $< > $@
9 |
10 | default: $(PNGS)
11 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # 石の上にも三年
2 |
3 | [](https://github.com/toddsundsted/ishi/releases)
4 | [](https://github.com/toddsundsted/ishi/actions)
5 | [](https://toddsundsted.github.io/ishi/)
6 |
7 | Graph plotting package with a small API and sensible defaults powered by gnuplot.
8 |
9 | Requires [gnuplot](http://www.gnuplot.info/).
10 |
11 | ## Installation
12 |
13 | 1. Add the dependency to your `shard.yml`:
14 |
15 | ```yaml
16 | dependencies:
17 | ishi:
18 | github: toddsundsted/ishi
19 | ```
20 |
21 | 2. Run `shards install`
22 |
23 | ## Usage
24 |
25 | To display a line chart of the data points in `xdata` (the x values)
26 | and `ydata` (the corresponding y values):
27 |
28 | ```crystal
29 | require "ishi"
30 |
31 | ishi = Ishi.new
32 | ishi.plot(xdata, ydata)
33 | ishi.show
34 | ```
35 |
36 | Or, if you prefer command-style syntax:
37 |
38 | ```crystal
39 | require "ishi"
40 |
41 | Ishi.new do
42 | plot(xdata, ydata)
43 | end
44 | ```
45 |
46 | A chart can display multiple plots. The following code displays two
47 | plots in one chart: one derived from discrete data points and the
48 | other from the equation of a line.
49 |
50 | ```crystal
51 | require "ishi"
52 |
53 | Ishi.new do
54 | plot([1, 2, 3, 4, 5], [1.0, 1.4, 1.9, 2.4, 2.6], "ko", title: "data")
55 | plot("0.4 * x + 0.7", "b--")
56 | end
57 | ```
58 |
59 | 
60 |
61 | The [etc/examples](https://github.com/toddsundsted/ishi/tree/main/etc/examples) directory contains examples of usage.
62 |
63 | ### plot
64 |
65 | `plot` plots points and lines. It takes data in several formats:
66 | * `plot(ydata)` - y values in *ydata* with x values ranging from `0` to `ydata.size - 1`
67 | * `plot(xdata, ydata)` - x values in *xdata* and corresponding y values in *ydata*
68 | * `plot(xdata, ydata, zdata)` - x values in *xdata*, y values in *ydata*, and z values in *zdata*
69 | * `plot(expression)` - any gnuplot-supported mathematical expression
70 |
71 | *xdata*, *ydata* and *zdata* may be any type that implements
72 | `Indexable(Number)`. Chart dimensionality (2D or 3D) is inferred from
73 | the data.
74 |
75 | All `plot` methods/commands accept the optional named arguments
76 | *title*, *style*, *dashtype* (*dt*), *linecolor* (*lc*), *linewidth*
77 | (*lw*), *pointsize* (*ps*), *pointtype* (*pt*), *linestyle* (*ls*),
78 | *fillstyle* (*fs*) and *format*.
79 |
80 | *title* specifies the title of the plot in the chart key.
81 |
82 | *style* explicitly specifies the style of the plot (`:lines`,
83 | `:points`, etc.). Ishi will try to infer the style from the data and
84 | the other named arguments (for example, if both *linewidth* and
85 | *pointsize* are provided, the style will be `:linespoints`).
86 |
87 | By default, plots are rendered with solid lines. *dashtype* (*dt*)
88 | specifies the pattern of dashes to use instead. *dashtype* may be an
89 | array of pairs of numbers that specify the length of a solid line
90 | followed by the length of an empty space (e.g. `[2, 3, 5, 7]`), or it
91 | may be a string composed of . (dot), - (hyphen), \_ (underscore) and
92 | (space), which is then converted into an array as follows: each "."
93 | becomes `[2, 5]`, "-" becomes `[10, 10]`, "\_" becomes `[20, 10]` and
94 | " " adds 10 to the previous empty value.
95 |
96 | *linecolor* specifies the color to use for lines and points. Colors
97 | may be specified by name (e.g. "red", "blue", or "green") or by
98 | hexadecimal color value (e.g. "#AARRGGBB" or "#RRGGBB").
99 |
100 | *linewidth* and *pointsize* scale the width of lines and the size of
101 | points, respectively. A value of 2.0 is twice as big as the default
102 | width or size.
103 |
104 | The following code demonstrates the use of *dashtype*, *linecolor* and
105 | *linewidth*:
106 |
107 | ```crystal
108 | require "ishi"
109 |
110 | Ishi.new do
111 | plot("x + 4.0", dashtype: "-", linewidth: 2)
112 | plot("x + 3.0", dashtype: "_", linewidth: 2)
113 | plot("x + 2.0", dashtype: ".", linewidth: 2)
114 | plot("x + 1.0", dashtype: "..._", linewidth: 2)
115 | plot("x + 0.0", dashtype: [30, 10, 50, 10], linewidth: 2, linecolor: "#88001100")
116 | end
117 | ```
118 |
119 | 
120 |
121 | *pointtype* selects the type of point to render. Available types
122 | depend on the gnuplot terminal device used, but commonly supported
123 | values are . (dot), + (plus sign), x (multiplication sign), *
124 | (asterisk), s (square), o (circle), ^ (up triangle), and v (down
125 | triangle) and d (diamond).
126 |
127 | The following code demonstrates the use of *pointtype* and
128 | *pointsize*:
129 |
130 | ```crystal
131 | require "ishi"
132 |
133 | Ishi.new do
134 | plot([1, 2, 3, 4], [5, 6, 7, 8], pointtype: 1, pointsize: 2)
135 | plot([1, 2, 3, 4], [4, 5, 6, 7], pointtype: "o", pointsize: 2)
136 | plot([1, 2, 3, 4], [3, 4, 5, 6], pointtype: "s", pointsize: 2)
137 | plot([1, 2, 3, 4], [2, 3, 4, 5], pointtype: "^", pointsize: 2)
138 | plot([1, 2, 3, 4], [1, 2, 3, 4], pointtype: "v", pointsize: 2, linecolor: "#88001100")
139 | end
140 | ```
141 |
142 | 
143 |
144 | The *format* argument is a short string used to specify color, point
145 | and line, simultaneously.
146 |
147 | Color is a letter from the set b (blue), g (green), r (red), c (cyan),
148 | m (magenta), y (yellow), k (black) or w (white). Point is a letter
149 | from the set . (dot), + (plus sign), x (multiplication sign), *
150 | (asterisk), s (square), c (circle), ^ (up triangle), v (down triangle)
151 | or d (diamond). Line may be - (solid line), -- (dashed line), !
152 | (dash-dot line) and : (dotted line).
153 |
154 | Given these rules, the format string "b" is a solid blue line, "or" is
155 | red circles, "^k:" is black triangles connected by dotted black lines,
156 | "g-" is a solid green line and "--" is a dashed line.
157 |
158 | *format* may also be a single word color name or hexadecimal color
159 | value, in which case point and line may not be specified.
160 |
161 | Returning to the first example, the code uses *format* to customize
162 | the plots:
163 |
164 | ```crystal
165 | require "ishi"
166 |
167 | Ishi.new do
168 | plot([1, 2, 3, 4, 5], [1.0, 1.4, 1.9, 2.4, 2.6], "ko", title: "data")
169 | plot("0.4 * x + 0.7", "b--")
170 | end
171 | ```
172 |
173 | The *format* "ko" could also be expressed explicitly (and much more
174 | verbosely) with the named arguments `linecolor: "black", pointtype: 7`,
175 | and the *format* "b--" with `linecolor: "blue", dashtype: 2`.
176 |
177 | ### scatter
178 |
179 | `scatter` draws scatter plots. It takes data in several formats:
180 | * `scatter(xdata, ydata)` - x values in *xdata* and corresponding y values in *ydata*
181 | * `scatter(xdata, ydata, zdata)` - x values in *xdata*, y values in *ydata*, and z values in *zdata*
182 |
183 | Chart dimensionality (2D or 3D) is inferred from the data. By default,
184 | `scatter` places a . (dot) at each point.
185 |
186 | All `scatter` methods/commands accept the optional named arguments
187 | *title*, *style*, *dashtype* (*dt*), *linecolor* (*lc*), *linewidth*
188 | (*lw*), *pointsize* (*ps*), *pointtype* (*pt*), *linestyle* (*ls*) and
189 | *format*.
190 |
191 | The following code demonstrates the use of *scatter*:
192 |
193 | ```crystal
194 | require "ishi"
195 |
196 | Ishi.new do
197 | scatter(xdata, zdata, lc: "#4b03a1")
198 | scatter(ydata, zdata, lc: "#b5367a")
199 | end
200 | ```
201 |
202 | 
203 |
204 | ### imshow
205 |
206 | `imshow` displays data as a pseudocolor, heatmapped image:
207 | * `imshow(data)` - *data* is two-dimensional scalar data, which will be rendered as an image
208 |
209 | The following code demonstrates the use of *imshow*:
210 |
211 | ```crystal
212 | require "ishi"
213 |
214 | Ishi.new do
215 | palette(:inferno)
216 | imshow(data)
217 | margin(0, 0, 0, 0)
218 | show_colorbox(false)
219 | show_border(false)
220 | show_xtics(false)
221 | show_ytics(false)
222 | show_key(false)
223 | end
224 | ```
225 |
226 | 
227 |
228 | ### charts
229 |
230 | `charts` changes the number of charts in the figure:
231 | * `charts(rows, cols)` - *rows* and *cols* are the number of rows and columns in the figure
232 |
233 | By default a figure has one chart. This call changes the number of
234 | charts in the figure. The original chart is preserved and becomes the
235 | chart in the first row, first column of the new layout.
236 |
237 | When called without a block, `charts` returns the charts in the
238 | figure.
239 |
240 | ```crystal
241 | require "ishi"
242 |
243 | figure = Ishi.new
244 | charts = figure.charts(2, 2)
245 | charts[0].plot([1, 2, 3, 4])
246 | charts[1].plot([1, 1, 3, 2])
247 | charts[2].plot([1, 1, 1, 1])
248 | charts[3].plot([4, 3, 2, 1])
249 | figure.show
250 | ```
251 |
252 | When called with a block, `charts` Yields each chart as the default
253 | receiver of the supplied block. Block arguments are *i* (the i-th
254 | chart in the figure), *row* and *col* (the row and column of the
255 | chart).
256 |
257 | ```crystal
258 | require "ishi"
259 |
260 | figure = Ishi.new
261 | figure.charts(2, 2) do |i, row, col|
262 | plot([1, 2, 3, 4].rotate(i), title: "#{row},#{col}")
263 | end
264 | figure.show
265 | ```
266 |
267 | ### Non-numeric labels on the x-axis
268 |
269 | `xtics` sets non-numeric labels for positions on the x-axis.
270 |
271 | The following code demonstrates the use of *xtics*:
272 |
273 | ```crystal
274 | require "ishi"
275 |
276 | Ishi.new do
277 | x = [1, 2, 3]
278 | y = [65, 30, 5]
279 | plot(x, y, title: "Visits", style: :boxes, fs: 0.25)
280 | .boxwidth(0.5)
281 | .ylabel("Visits (%)")
282 | .xlabel("Device")
283 | .xtics({
284 | 1.0 => "mobile",
285 | 2.0 => "desktop",
286 | 3.0 => "tablet"
287 | })
288 | end
289 | ```
290 |
291 | 
292 |
293 | ### MXNet::NDArray
294 |
295 | `MXNet::NDArray` is an indexable, multi-dimensional array that
296 | efficiently supports numerical operations (transposition, matrix
297 | multiplication, etc.).
298 |
299 | All appropriate methods/commands accept instances of `MXNet::NDArray`
300 | with the correct shape (1-dimensional vectors for x-values, for
301 | example).
302 |
303 | ```crystal
304 | require "ishi"
305 | require "mxnet"
306 |
307 | m = MXNet::NDArray.array(
308 | [[0, 0, 1, 1],
309 | [1, 2, 3, 4],
310 | [1, 1, 2, 2]]
311 | )
312 |
313 | figure = Ishi.new
314 | charts = figure.charts(1, 2)
315 | charts[0].plot(m[0], m[1], m[2])
316 | charts[1].plot(m[.., 0], m[.., 1], m[.., 2])
317 | figure.show
318 | ```
319 |
320 | See [MXNet.cr](https://github.com/toddsundsted/mxnet.cr) for more
321 | information on the complete library.
322 |
323 | ### Extensions
324 |
325 | By default, Ishi pops open a window to display charts. However, Ishi
326 | comes with extensions that render charts as text, HTML, PNG or inline
327 | images in the terminal; or that write to other `IO` destinations.
328 | Note: terminal image display only works with
329 | [ITerm2](https://www.iterm2.com/).
330 |
331 | To plot the *sin(x)* function as text:
332 |
333 | ```crystal
334 | require "ishi/text" # or "ishi/html" or "ishi/iterm2"
335 |
336 | Ishi.new do
337 | plot("sin(x)")
338 | end
339 | ```
340 |
341 | This produces:
342 |
343 | ```
344 | 1 +--------------------------------------------------------------------+
345 | | * * + * ** + * * |
346 | 0.8 |-+ * * * * sin(x* *******-|
347 | | * * * * * * |
348 | 0.6 |-+ * * * * * * +-|
349 | | * * * * * * |
350 | 0.4 |*+ * * * * * *+-|
351 | |* * * * * * * |
352 | 0.2 |*+ * * * * * *+-|
353 | | * * * * * * * |
354 | 0 |-* * * * * * *-|
355 | | * * * * * * *|
356 | -0.2 |-+* * * * * * +*|
357 | | * * * * * * *|
358 | -0.4 |-+* * * * * * +*|
359 | | * * * * * * |
360 | -0.6 |-+ * * * * * * +-|
361 | | * * * * * * |
362 | -0.8 |-+ * * * * * * +-|
363 | | * * + ** * + * * |
364 | -1 +--------------------------------------------------------------------+
365 | -10 -5 0 5 10
366 | ```
367 |
368 | You can pass in an `IO` instance. Chart data will be written to the
369 | `IO` instance instead of `STDOUT`.
370 |
371 | ```crystal
372 | require "ishi/text" # or "ishi/html" or "ishi/png"
373 |
374 | io = IO::Memory.new
375 |
376 | Ishi.new(io) do
377 | plot("sin(x)")
378 | end
379 | ```
380 |
381 | ## Contributors
382 |
383 | - [Todd Sundsted](https://github.com/toddsundsted) - creator and maintainer
384 | - [lbarasti](https://github.com/lbarasti) - contributor
385 |
--------------------------------------------------------------------------------
/etc/examples/1.cr:
--------------------------------------------------------------------------------
1 | {% if flag?(:png) %}
2 | require "../../src/ishi/png"
3 | {% else %}
4 | require "../../src/ishi"
5 | {% end %}
6 |
7 | # Plot data points and the equation of a line.
8 | #
9 | Ishi.new do
10 | canvas_size(480, 360)
11 | plot([1, 2, 3, 4, 5], [1.0, 1.4, 1.9, 2.4, 2.6], "ko", title: "data")
12 | plot("0.4 * x + 0.7", "b--")
13 | end
14 |
--------------------------------------------------------------------------------
/etc/examples/1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/toddsundsted/ishi/130ce4e27f38b60808d422a944c8dcc948e9fb2b/etc/examples/1.png
--------------------------------------------------------------------------------
/etc/examples/2.cr:
--------------------------------------------------------------------------------
1 | {% if flag?(:png) %}
2 | require "../../src/ishi/png"
3 | {% else %}
4 | require "../../src/ishi"
5 | {% end %}
6 |
7 | # Various types of lines.
8 | #
9 | Ishi.new do
10 | canvas_size(480, 360)
11 | show_key(false)
12 | xrange(0..5)
13 | yrange(0..9)
14 | plot("x + 4.0", dashtype: "-", linewidth: 2)
15 | plot("x + 3.0", dashtype: "_", linewidth: 2)
16 | plot("x + 2.0", dashtype: ".", linewidth: 2)
17 | plot("x + 1.0", dashtype: "..._", linewidth: 2)
18 | plot("x + 0.0", dashtype: [30, 10, 50, 10], linewidth: 2, linecolor: "#88001100")
19 | end
20 |
--------------------------------------------------------------------------------
/etc/examples/2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/toddsundsted/ishi/130ce4e27f38b60808d422a944c8dcc948e9fb2b/etc/examples/2.png
--------------------------------------------------------------------------------
/etc/examples/3.cr:
--------------------------------------------------------------------------------
1 | {% if flag?(:png) %}
2 | require "../../src/ishi/png"
3 | {% else %}
4 | require "../../src/ishi"
5 | {% end %}
6 |
7 | # Various types of points.
8 | #
9 | Ishi.new do
10 | canvas_size(480, 360)
11 | show_key(false)
12 | xrange(0..5)
13 | yrange(0..9)
14 | plot([1, 2, 3, 4], [5, 6, 7, 8], pointtype: 1, pointsize: 2)
15 | plot([1, 2, 3, 4], [4, 5, 6, 7], pointtype: "o", pointsize: 2)
16 | plot([1, 2, 3, 4], [3, 4, 5, 6], pointtype: "s", pointsize: 2)
17 | plot([1, 2, 3, 4], [2, 3, 4, 5], pointtype: "^", pointsize: 2)
18 | plot([1, 2, 3, 4], [1, 2, 3, 4], pointtype: "v", pointsize: 2, linecolor: "#88001100")
19 | end
20 |
--------------------------------------------------------------------------------
/etc/examples/3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/toddsundsted/ishi/130ce4e27f38b60808d422a944c8dcc948e9fb2b/etc/examples/3.png
--------------------------------------------------------------------------------
/etc/examples/4.cr:
--------------------------------------------------------------------------------
1 | {% if flag?(:png) %}
2 | require "../../src/ishi/png"
3 | {% else %}
4 | require "../../src/ishi"
5 | {% end %}
6 | require "yaml"
7 |
8 | class Points
9 | YAML.mapping(
10 | x: Array(Float32),
11 | y: Array(Float32),
12 | z: Array(Float32)
13 | )
14 | end
15 |
16 | # Scatter plot.
17 | #
18 | Ishi.new do
19 | canvas_size(820, 300)
20 | File.open(File.join(__DIR__, "4.yml")) do |file|
21 | points = Points.from_yaml(file)
22 | plots = charts(1, 2)
23 | plots[0].scatter(points.x, points.z, lc: "#4b03a1")
24 | plots[1].scatter(points.y, points.z, lc: "#b5367a")
25 | end
26 | end
27 |
--------------------------------------------------------------------------------
/etc/examples/4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/toddsundsted/ishi/130ce4e27f38b60808d422a944c8dcc948e9fb2b/etc/examples/4.png
--------------------------------------------------------------------------------
/etc/examples/5.cr:
--------------------------------------------------------------------------------
1 | {% if flag?(:png) %}
2 | require "../../src/ishi/png"
3 | {% else %}
4 | require "../../src/ishi"
5 | {% end %}
6 | require "yaml"
7 |
8 | class Data
9 | YAML.mapping(
10 | d: Array(Array(Float32))
11 | )
12 | end
13 |
14 | # Heatmap.
15 | #
16 | Ishi.new do
17 | canvas_size(480, 360)
18 | palette(:inferno)
19 | File.open(File.join(__DIR__, "5.yml")) do |file|
20 | data = Data.from_yaml(file)
21 | imshow(data.d)
22 | end
23 | margin(0, 0, 0, 0)
24 | show_colorbox(false)
25 | show_border(false)
26 | show_xtics(false)
27 | show_ytics(false)
28 | show_key(false)
29 | end
30 |
--------------------------------------------------------------------------------
/etc/examples/5.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/toddsundsted/ishi/130ce4e27f38b60808d422a944c8dcc948e9fb2b/etc/examples/5.png
--------------------------------------------------------------------------------
/etc/examples/5.yml:
--------------------------------------------------------------------------------
1 | ---
2 | d:
3 | - - 0.0
4 | - 1.0
5 | - 2.0
6 | - 3.0
7 | - 4.0
8 | - 5.0
9 | - 6.0
10 | - 7.0
11 | - 8.0
12 | - 9.0
13 | - 10.0
14 | - 11.0
15 | - 12.0
16 | - 13.0
17 | - 14.0
18 | - 15.0
19 | - - 16.0
20 | - 17.0
21 | - 18.0
22 | - 19.0
23 | - 20.0
24 | - 21.0
25 | - 22.0
26 | - 23.0
27 | - 24.0
28 | - 25.0
29 | - 26.0
30 | - 27.0
31 | - 28.0
32 | - 29.0
33 | - 30.0
34 | - 31.0
35 | - - 32.0
36 | - 33.0
37 | - 34.0
38 | - 35.0
39 | - 36.0
40 | - 37.0
41 | - 38.0
42 | - 39.0
43 | - 40.0
44 | - 41.0
45 | - 42.0
46 | - 43.0
47 | - 44.0
48 | - 45.0
49 | - 46.0
50 | - 47.0
51 | - - 48.0
52 | - 49.0
53 | - 50.0
54 | - 51.0
55 | - 52.0
56 | - 53.0
57 | - 54.0
58 | - 55.0
59 | - 56.0
60 | - 57.0
61 | - 58.0
62 | - 59.0
63 | - 60.0
64 | - 61.0
65 | - 62.0
66 | - 63.0
67 | - - 64.0
68 | - 65.0
69 | - 66.0
70 | - 67.0
71 | - 68.0
72 | - 69.0
73 | - 70.0
74 | - 71.0
75 | - 72.0
76 | - 73.0
77 | - 74.0
78 | - 75.0
79 | - 76.0
80 | - 77.0
81 | - 78.0
82 | - 79.0
83 | - - 80.0
84 | - 81.0
85 | - 82.0
86 | - 83.0
87 | - 84.0
88 | - 85.0
89 | - 86.0
90 | - 87.0
91 | - 88.0
92 | - 89.0
93 | - 90.0
94 | - 91.0
95 | - 92.0
96 | - 93.0
97 | - 94.0
98 | - 95.0
99 | - - 96.0
100 | - 97.0
101 | - 98.0
102 | - 99.0
103 | - 100.0
104 | - 101.0
105 | - 102.0
106 | - 103.0
107 | - 104.0
108 | - 105.0
109 | - 106.0
110 | - 107.0
111 | - 108.0
112 | - 109.0
113 | - 110.0
114 | - 111.0
115 | - - 112.0
116 | - 113.0
117 | - 114.0
118 | - 115.0
119 | - 116.0
120 | - 117.0
121 | - 118.0
122 | - 119.0
123 | - 120.0
124 | - 121.0
125 | - 122.0
126 | - 123.0
127 | - 124.0
128 | - 125.0
129 | - 126.0
130 | - 127.0
131 | - - 128.0
132 | - 129.0
133 | - 130.0
134 | - 131.0
135 | - 132.0
136 | - 133.0
137 | - 134.0
138 | - 135.0
139 | - 136.0
140 | - 137.0
141 | - 138.0
142 | - 139.0
143 | - 140.0
144 | - 141.0
145 | - 142.0
146 | - 143.0
147 | - - 144.0
148 | - 145.0
149 | - 146.0
150 | - 147.0
151 | - 148.0
152 | - 149.0
153 | - 150.0
154 | - 151.0
155 | - 152.0
156 | - 153.0
157 | - 154.0
158 | - 155.0
159 | - 156.0
160 | - 157.0
161 | - 158.0
162 | - 159.0
163 | - - 160.0
164 | - 161.0
165 | - 162.0
166 | - 163.0
167 | - 164.0
168 | - 165.0
169 | - 166.0
170 | - 167.0
171 | - 168.0
172 | - 169.0
173 | - 170.0
174 | - 171.0
175 | - 172.0
176 | - 173.0
177 | - 174.0
178 | - 175.0
179 | - - 176.0
180 | - 177.0
181 | - 178.0
182 | - 179.0
183 | - 180.0
184 | - 181.0
185 | - 182.0
186 | - 183.0
187 | - 184.0
188 | - 185.0
189 | - 186.0
190 | - 187.0
191 | - 188.0
192 | - 189.0
193 | - 190.0
194 | - 191.0
195 | - - 192.0
196 | - 193.0
197 | - 194.0
198 | - 195.0
199 | - 196.0
200 | - 197.0
201 | - 198.0
202 | - 199.0
203 | - 200.0
204 | - 201.0
205 | - 202.0
206 | - 203.0
207 | - 204.0
208 | - 205.0
209 | - 206.0
210 | - 207.0
211 | - - 208.0
212 | - 209.0
213 | - 210.0
214 | - 211.0
215 | - 212.0
216 | - 213.0
217 | - 214.0
218 | - 215.0
219 | - 216.0
220 | - 217.0
221 | - 218.0
222 | - 219.0
223 | - 220.0
224 | - 221.0
225 | - 222.0
226 | - 223.0
227 | - - 224.0
228 | - 225.0
229 | - 226.0
230 | - 227.0
231 | - 228.0
232 | - 229.0
233 | - 230.0
234 | - 231.0
235 | - 232.0
236 | - 233.0
237 | - 234.0
238 | - 235.0
239 | - 236.0
240 | - 237.0
241 | - 238.0
242 | - 239.0
243 | - - 240.0
244 | - 241.0
245 | - 242.0
246 | - 243.0
247 | - 244.0
248 | - 245.0
249 | - 246.0
250 | - 247.0
251 | - 248.0
252 | - 249.0
253 | - 250.0
254 | - 251.0
255 | - 252.0
256 | - 253.0
257 | - 254.0
258 | - 255.0
259 |
--------------------------------------------------------------------------------
/etc/examples/6.cr:
--------------------------------------------------------------------------------
1 | {% if flag?(:png) %}
2 | require "../../src/ishi/png"
3 | {% else %}
4 | require "../../src/ishi"
5 | {% end %}
6 |
7 | # Bar chart with fixed box width and custom fill style
8 | Ishi.new do
9 | canvas_size(480, 360)
10 | min = 1.2
11 | step = 0.5
12 | n = 25
13 | x = (1..n).map { |i| min + i * step }
14 | y = (1..n).map { rand }
15 | plot(x, y,
16 | title: "a box plot!",
17 | style: :boxes,
18 | fs: 0.25
19 | ).boxwidth(step).show_border(true)
20 | end
21 |
--------------------------------------------------------------------------------
/etc/examples/6.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/toddsundsted/ishi/130ce4e27f38b60808d422a944c8dcc948e9fb2b/etc/examples/6.png
--------------------------------------------------------------------------------
/etc/examples/7.cr:
--------------------------------------------------------------------------------
1 | {% if flag?(:png) %}
2 | require "../../src/ishi/png"
3 | {% else %}
4 | require "../../src/ishi"
5 | {% end %}
6 |
7 | # Bar chart with non-numeric x-axis labels
8 | Ishi.new do
9 | canvas_size(480, 360)
10 |
11 | x = [1, 2, 3]
12 | y = [65, 30, 5]
13 | plot(x, y, title: "Visits", style: :boxes, fs: 0.25)
14 | .boxwidth(0.5)
15 | .ylabel("Visits (%)")
16 | .xlabel("Device")
17 | .xtics({1.0 => "mobile", 2.0 => "desktop", 3.0 => "tablet"})
18 | end
19 |
--------------------------------------------------------------------------------
/etc/examples/7.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/toddsundsted/ishi/130ce4e27f38b60808d422a944c8dcc948e9fb2b/etc/examples/7.png
--------------------------------------------------------------------------------
/etc/palettes/hot.pal:
--------------------------------------------------------------------------------
1 | set palette rgb 21,22,23
2 | set style line 1 palette fraction 0.1
3 | set style line 2 palette fraction 0.2
4 | set style line 3 palette fraction 0.3
5 | set style line 4 palette fraction 0.4
6 | set style line 5 palette fraction 0.5
7 | set style line 6 palette fraction 0.6
8 | set style line 7 palette fraction 0.7
9 | set style line 8 palette fraction 0.8
10 | set style line 9 palette fraction 0.9
11 |
--------------------------------------------------------------------------------
/etc/palettes/inferno.pal:
--------------------------------------------------------------------------------
1 | # New matplotlib colormaps by Nathaniel J. Smith, Stefan van der Walt,
2 | # and (in the case of viridis) Eric Firing.
3 | #
4 | # This file and the colormaps in it are released under the CC0 license /
5 | # public domain dedication. We would appreciate credit if you use or
6 | # redistribute these colormaps, but do not impose any legal restrictions.
7 | #
8 | # To the extent possible under law, the persons who associated CC0 with
9 | # mpl-colormaps have waived all copyright and related or neighboring rights
10 | # to mpl-colormaps.
11 | #
12 | # You should have received a copy of the CC0 legalcode along with this
13 | # work. If not, see .
14 |
15 | #https://github.com/BIDS/colormap/blob/master/colormaps.py
16 |
17 |
18 | # line styles
19 | set style line 1 lt 1 lc rgb '#000004' # black
20 | set style line 2 lt 1 lc rgb '#1f0c48' # dark purple
21 | set style line 3 lt 1 lc rgb '#550f6d' # dark purple
22 | set style line 4 lt 1 lc rgb '#88226a' # purple
23 | set style line 5 lt 1 lc rgb '#a83655' # red-magenta
24 | set style line 6 lt 1 lc rgb '#e35933' # red
25 | set style line 7 lt 1 lc rgb '#f9950a' # orange
26 | set style line 8 lt 1 lc rgb '#f8c932' # yellow-orange
27 | set style line 9 lt 1 lc rgb '#fcffa4' # light yellow
28 |
29 |
30 | # palette
31 | set palette defined (\
32 | 0 0.001462 0.000466 0.013866,\
33 | 1 0.002267 0.001270 0.018570,\
34 | 2 0.003299 0.002249 0.024239,\
35 | 3 0.004547 0.003392 0.030909,\
36 | 4 0.006006 0.004692 0.038558,\
37 | 5 0.007676 0.006136 0.046836,\
38 | 6 0.009561 0.007713 0.055143,\
39 | 7 0.011663 0.009417 0.063460,\
40 | 8 0.013995 0.011225 0.071862,\
41 | 9 0.016561 0.013136 0.080282,\
42 | 10 0.019373 0.015133 0.088767,\
43 | 11 0.022447 0.017199 0.097327,\
44 | 12 0.025793 0.019331 0.105930,\
45 | 13 0.029432 0.021503 0.114621,\
46 | 14 0.033385 0.023702 0.123397,\
47 | 15 0.037668 0.025921 0.132232,\
48 | 16 0.042253 0.028139 0.141141,\
49 | 17 0.046915 0.030324 0.150164,\
50 | 18 0.051644 0.032474 0.159254,\
51 | 19 0.056449 0.034569 0.168414,\
52 | 20 0.061340 0.036590 0.177642,\
53 | 21 0.066331 0.038504 0.186962,\
54 | 22 0.071429 0.040294 0.196354,\
55 | 23 0.076637 0.041905 0.205799,\
56 | 24 0.081962 0.043328 0.215289,\
57 | 25 0.087411 0.044556 0.224813,\
58 | 26 0.092990 0.045583 0.234358,\
59 | 27 0.098702 0.046402 0.243904,\
60 | 28 0.104551 0.047008 0.253430,\
61 | 29 0.110536 0.047399 0.262912,\
62 | 30 0.116656 0.047574 0.272321,\
63 | 31 0.122908 0.047536 0.281624,\
64 | 32 0.129285 0.047293 0.290788,\
65 | 33 0.135778 0.046856 0.299776,\
66 | 34 0.142378 0.046242 0.308553,\
67 | 35 0.149073 0.045468 0.317085,\
68 | 36 0.155850 0.044559 0.325338,\
69 | 37 0.162689 0.043554 0.333277,\
70 | 38 0.169575 0.042489 0.340874,\
71 | 39 0.176493 0.041402 0.348111,\
72 | 40 0.183429 0.040329 0.354971,\
73 | 41 0.190367 0.039309 0.361447,\
74 | 42 0.197297 0.038400 0.367535,\
75 | 43 0.204209 0.037632 0.373238,\
76 | 44 0.211095 0.037030 0.378563,\
77 | 45 0.217949 0.036615 0.383522,\
78 | 46 0.224763 0.036405 0.388129,\
79 | 47 0.231538 0.036405 0.392400,\
80 | 48 0.238273 0.036621 0.396353,\
81 | 49 0.244967 0.037055 0.400007,\
82 | 50 0.251620 0.037705 0.403378,\
83 | 51 0.258234 0.038571 0.406485,\
84 | 52 0.264810 0.039647 0.409345,\
85 | 53 0.271347 0.040922 0.411976,\
86 | 54 0.277850 0.042353 0.414392,\
87 | 55 0.284321 0.043933 0.416608,\
88 | 56 0.290763 0.045644 0.418637,\
89 | 57 0.297178 0.047470 0.420491,\
90 | 58 0.303568 0.049396 0.422182,\
91 | 59 0.309935 0.051407 0.423721,\
92 | 60 0.316282 0.053490 0.425116,\
93 | 61 0.322610 0.055634 0.426377,\
94 | 62 0.328921 0.057827 0.427511,\
95 | 63 0.335217 0.060060 0.428524,\
96 | 64 0.341500 0.062325 0.429425,\
97 | 65 0.347771 0.064616 0.430217,\
98 | 66 0.354032 0.066925 0.430906,\
99 | 67 0.360284 0.069247 0.431497,\
100 | 68 0.366529 0.071579 0.431994,\
101 | 69 0.372768 0.073915 0.432400,\
102 | 70 0.379001 0.076253 0.432719,\
103 | 71 0.385228 0.078591 0.432955,\
104 | 72 0.391453 0.080927 0.433109,\
105 | 73 0.397674 0.083257 0.433183,\
106 | 74 0.403894 0.085580 0.433179,\
107 | 75 0.410113 0.087896 0.433098,\
108 | 76 0.416331 0.090203 0.432943,\
109 | 77 0.422549 0.092501 0.432714,\
110 | 78 0.428768 0.094790 0.432412,\
111 | 79 0.434987 0.097069 0.432039,\
112 | 80 0.441207 0.099338 0.431594,\
113 | 81 0.447428 0.101597 0.431080,\
114 | 82 0.453651 0.103848 0.430498,\
115 | 83 0.459875 0.106089 0.429846,\
116 | 84 0.466100 0.108322 0.429125,\
117 | 85 0.472328 0.110547 0.428334,\
118 | 86 0.478558 0.112764 0.427475,\
119 | 87 0.484789 0.114974 0.426548,\
120 | 88 0.491022 0.117179 0.425552,\
121 | 89 0.497257 0.119379 0.424488,\
122 | 90 0.503493 0.121575 0.423356,\
123 | 91 0.509730 0.123769 0.422156,\
124 | 92 0.515967 0.125960 0.420887,\
125 | 93 0.522206 0.128150 0.419549,\
126 | 94 0.528444 0.130341 0.418142,\
127 | 95 0.534683 0.132534 0.416667,\
128 | 96 0.540920 0.134729 0.415123,\
129 | 97 0.547157 0.136929 0.413511,\
130 | 98 0.553392 0.139134 0.411829,\
131 | 99 0.559624 0.141346 0.410078,\
132 | 100 0.565854 0.143567 0.408258,\
133 | 101 0.572081 0.145797 0.406369,\
134 | 102 0.578304 0.148039 0.404411,\
135 | 103 0.584521 0.150294 0.402385,\
136 | 104 0.590734 0.152563 0.400290,\
137 | 105 0.596940 0.154848 0.398125,\
138 | 106 0.603139 0.157151 0.395891,\
139 | 107 0.609330 0.159474 0.393589,\
140 | 108 0.615513 0.161817 0.391219,\
141 | 109 0.621685 0.164184 0.388781,\
142 | 110 0.627847 0.166575 0.386276,\
143 | 111 0.633998 0.168992 0.383704,\
144 | 112 0.640135 0.171438 0.381065,\
145 | 113 0.646260 0.173914 0.378359,\
146 | 114 0.652369 0.176421 0.375586,\
147 | 115 0.658463 0.178962 0.372748,\
148 | 116 0.664540 0.181539 0.369846,\
149 | 117 0.670599 0.184153 0.366879,\
150 | 118 0.676638 0.186807 0.363849,\
151 | 119 0.682656 0.189501 0.360757,\
152 | 120 0.688653 0.192239 0.357603,\
153 | 121 0.694627 0.195021 0.354388,\
154 | 122 0.700576 0.197851 0.351113,\
155 | 123 0.706500 0.200728 0.347777,\
156 | 124 0.712396 0.203656 0.344383,\
157 | 125 0.718264 0.206636 0.340931,\
158 | 126 0.724103 0.209670 0.337424,\
159 | 127 0.729909 0.212759 0.333861,\
160 | 128 0.735683 0.215906 0.330245,\
161 | 129 0.741423 0.219112 0.326576,\
162 | 130 0.747127 0.222378 0.322856,\
163 | 131 0.752794 0.225706 0.319085,\
164 | 132 0.758422 0.229097 0.315266,\
165 | 133 0.764010 0.232554 0.311399,\
166 | 134 0.769556 0.236077 0.307485,\
167 | 135 0.775059 0.239667 0.303526,\
168 | 136 0.780517 0.243327 0.299523,\
169 | 137 0.785929 0.247056 0.295477,\
170 | 138 0.791293 0.250856 0.291390,\
171 | 139 0.796607 0.254728 0.287264,\
172 | 140 0.801871 0.258674 0.283099,\
173 | 141 0.807082 0.262692 0.278898,\
174 | 142 0.812239 0.266786 0.274661,\
175 | 143 0.817341 0.270954 0.270390,\
176 | 144 0.822386 0.275197 0.266085,\
177 | 145 0.827372 0.279517 0.261750,\
178 | 146 0.832299 0.283913 0.257383,\
179 | 147 0.837165 0.288385 0.252988,\
180 | 148 0.841969 0.292933 0.248564,\
181 | 149 0.846709 0.297559 0.244113,\
182 | 150 0.851384 0.302260 0.239636,\
183 | 151 0.855992 0.307038 0.235133,\
184 | 152 0.860533 0.311892 0.230606,\
185 | 153 0.865006 0.316822 0.226055,\
186 | 154 0.869409 0.321827 0.221482,\
187 | 155 0.873741 0.326906 0.216886,\
188 | 156 0.878001 0.332060 0.212268,\
189 | 157 0.882188 0.337287 0.207628,\
190 | 158 0.886302 0.342586 0.202968,\
191 | 159 0.890341 0.347957 0.198286,\
192 | 160 0.894305 0.353399 0.193584,\
193 | 161 0.898192 0.358911 0.188860,\
194 | 162 0.902003 0.364492 0.184116,\
195 | 163 0.905735 0.370140 0.179350,\
196 | 164 0.909390 0.375856 0.174563,\
197 | 165 0.912966 0.381636 0.169755,\
198 | 166 0.916462 0.387481 0.164924,\
199 | 167 0.919879 0.393389 0.160070,\
200 | 168 0.923215 0.399359 0.155193,\
201 | 169 0.926470 0.405389 0.150292,\
202 | 170 0.929644 0.411479 0.145367,\
203 | 171 0.932737 0.417627 0.140417,\
204 | 172 0.935747 0.423831 0.135440,\
205 | 173 0.938675 0.430091 0.130438,\
206 | 174 0.941521 0.436405 0.125409,\
207 | 175 0.944285 0.442772 0.120354,\
208 | 176 0.946965 0.449191 0.115272,\
209 | 177 0.949562 0.455660 0.110164,\
210 | 178 0.952075 0.462178 0.105031,\
211 | 179 0.954506 0.468744 0.099874,\
212 | 180 0.956852 0.475356 0.094695,\
213 | 181 0.959114 0.482014 0.089499,\
214 | 182 0.961293 0.488716 0.084289,\
215 | 183 0.963387 0.495462 0.079073,\
216 | 184 0.965397 0.502249 0.073859,\
217 | 185 0.967322 0.509078 0.068659,\
218 | 186 0.969163 0.515946 0.063488,\
219 | 187 0.970919 0.522853 0.058367,\
220 | 188 0.972590 0.529798 0.053324,\
221 | 189 0.974176 0.536780 0.048392,\
222 | 190 0.975677 0.543798 0.043618,\
223 | 191 0.977092 0.550850 0.039050,\
224 | 192 0.978422 0.557937 0.034931,\
225 | 193 0.979666 0.565057 0.031409,\
226 | 194 0.980824 0.572209 0.028508,\
227 | 195 0.981895 0.579392 0.026250,\
228 | 196 0.982881 0.586606 0.024661,\
229 | 197 0.983779 0.593849 0.023770,\
230 | 198 0.984591 0.601122 0.023606,\
231 | 199 0.985315 0.608422 0.024202,\
232 | 200 0.985952 0.615750 0.025592,\
233 | 201 0.986502 0.623105 0.027814,\
234 | 202 0.986964 0.630485 0.030908,\
235 | 203 0.987337 0.637890 0.034916,\
236 | 204 0.987622 0.645320 0.039886,\
237 | 205 0.987819 0.652773 0.045581,\
238 | 206 0.987926 0.660250 0.051750,\
239 | 207 0.987945 0.667748 0.058329,\
240 | 208 0.987874 0.675267 0.065257,\
241 | 209 0.987714 0.682807 0.072489,\
242 | 210 0.987464 0.690366 0.079990,\
243 | 211 0.987124 0.697944 0.087731,\
244 | 212 0.986694 0.705540 0.095694,\
245 | 213 0.986175 0.713153 0.103863,\
246 | 214 0.985566 0.720782 0.112229,\
247 | 215 0.984865 0.728427 0.120785,\
248 | 216 0.984075 0.736087 0.129527,\
249 | 217 0.983196 0.743758 0.138453,\
250 | 218 0.982228 0.751442 0.147565,\
251 | 219 0.981173 0.759135 0.156863,\
252 | 220 0.980032 0.766837 0.166353,\
253 | 221 0.978806 0.774545 0.176037,\
254 | 222 0.977497 0.782258 0.185923,\
255 | 223 0.976108 0.789974 0.196018,\
256 | 224 0.974638 0.797692 0.206332,\
257 | 225 0.973088 0.805409 0.216877,\
258 | 226 0.971468 0.813122 0.227658,\
259 | 227 0.969783 0.820825 0.238686,\
260 | 228 0.968041 0.828515 0.249972,\
261 | 229 0.966243 0.836191 0.261534,\
262 | 230 0.964394 0.843848 0.273391,\
263 | 231 0.962517 0.851476 0.285546,\
264 | 232 0.960626 0.859069 0.298010,\
265 | 233 0.958720 0.866624 0.310820,\
266 | 234 0.956834 0.874129 0.323974,\
267 | 235 0.954997 0.881569 0.337475,\
268 | 236 0.953215 0.888942 0.351369,\
269 | 237 0.951546 0.896226 0.365627,\
270 | 238 0.950018 0.903409 0.380271,\
271 | 239 0.948683 0.910473 0.395289,\
272 | 240 0.947594 0.917399 0.410665,\
273 | 241 0.946809 0.924168 0.426373,\
274 | 242 0.946392 0.930761 0.442367,\
275 | 243 0.946403 0.937159 0.458592,\
276 | 244 0.946903 0.943348 0.474970,\
277 | 245 0.947937 0.949318 0.491426,\
278 | 246 0.949545 0.955063 0.507860,\
279 | 247 0.951740 0.960587 0.524203,\
280 | 248 0.954529 0.965896 0.540361,\
281 | 249 0.957896 0.971003 0.556275,\
282 | 250 0.961812 0.975924 0.571925,\
283 | 251 0.966249 0.980678 0.587206,\
284 | 252 0.971162 0.985282 0.602154,\
285 | 253 0.976511 0.989753 0.616760,\
286 | 254 0.982257 0.994109 0.631017,\
287 | 255 0.988362 0.998364 0.644924)
288 |
--------------------------------------------------------------------------------
/etc/palettes/jet.pal:
--------------------------------------------------------------------------------
1 | # MATLAB jet color pallete
2 |
3 | # line styles
4 | set style line 1 lt 1 lc rgb '#000080'
5 | set style line 2 lt 1 lc rgb '#0000ff'
6 | set style line 3 lt 1 lc rgb '#0080ff'
7 | set style line 4 lt 1 lc rgb '#00ffff'
8 | set style line 5 lt 1 lc rgb '#80ff80'
9 | set style line 6 lt 1 lc rgb '#ffff00'
10 | set style line 7 lt 1 lc rgb '#ff8000'
11 | set style line 8 lt 1 lc rgb '#ff0000'
12 | set style line 9 lt 1 lc rgb '#800000'
13 |
14 | # palette
15 | set palette defined (0 0.0 0.0 0.5, \
16 | 1 0.0 0.0 1.0, \
17 | 2 0.0 0.5 1.0, \
18 | 3 0.0 1.0 1.0, \
19 | 4 0.5 1.0 0.5, \
20 | 5 1.0 1.0 0.0, \
21 | 6 1.0 0.5 0.0, \
22 | 7 1.0 0.0 0.0, \
23 | 8 0.5 0.0 0.0 )
24 |
--------------------------------------------------------------------------------
/etc/palettes/magma.pal:
--------------------------------------------------------------------------------
1 |
2 | # New matplotlib colormaps by Nathaniel J. Smith, Stefan van der Walt,
3 | # and (in the case of viridis) Eric Firing.
4 | #
5 | # This file and the colormaps in it are released under the CC0 license /
6 | # public domain dedication. We would appreciate credit if you use or
7 | # redistribute these colormaps, but do not impose any legal restrictions.
8 | #
9 | # To the extent possible under law, the persons who associated CC0 with
10 | # mpl-colormaps have waived all copyright and related or neighboring rights
11 | # to mpl-colormaps.
12 | #
13 | # You should have received a copy of the CC0 legalcode along with this
14 | # work. If not, see .
15 |
16 | #https://github.com/BIDS/colormap/blob/master/colormaps.py
17 |
18 |
19 | # line styles
20 | set style line 1 lt 1 lc rgb '#000004' # black
21 | set style line 2 lt 1 lc rgb '#1c1044' # dark blue
22 | set style line 3 lt 1 lc rgb '#4f127b' # dark purple
23 | set style line 4 lt 1 lc rgb '#812581' # purple
24 | set style line 5 lt 1 lc rgb '#b5367a' # magenta
25 | set style line 6 lt 1 lc rgb '#e55964' # light red
26 | set style line 7 lt 1 lc rgb '#fb8761' # orange
27 | set style line 8 lt 1 lc rgb '#fec287' # light orange
28 | set style line 9 lt 1 lc rgb '#fbfdbf' # light yellow
29 |
30 |
31 | # palette
32 | set palette defined (\
33 | 0 0.001462 0.000466 0.013866,\
34 | 1 0.002258 0.001295 0.018331,\
35 | 2 0.003279 0.002305 0.023708,\
36 | 3 0.004512 0.003490 0.029965,\
37 | 4 0.005950 0.004843 0.037130,\
38 | 5 0.007588 0.006356 0.044973,\
39 | 6 0.009426 0.008022 0.052844,\
40 | 7 0.011465 0.009828 0.060750,\
41 | 8 0.013708 0.011771 0.068667,\
42 | 9 0.016156 0.013840 0.076603,\
43 | 10 0.018815 0.016026 0.084584,\
44 | 11 0.021692 0.018320 0.092610,\
45 | 12 0.024792 0.020715 0.100676,\
46 | 13 0.028123 0.023201 0.108787,\
47 | 14 0.031696 0.025765 0.116965,\
48 | 15 0.035520 0.028397 0.125209,\
49 | 16 0.039608 0.031090 0.133515,\
50 | 17 0.043830 0.033830 0.141886,\
51 | 18 0.048062 0.036607 0.150327,\
52 | 19 0.052320 0.039407 0.158841,\
53 | 20 0.056615 0.042160 0.167446,\
54 | 21 0.060949 0.044794 0.176129,\
55 | 22 0.065330 0.047318 0.184892,\
56 | 23 0.069764 0.049726 0.193735,\
57 | 24 0.074257 0.052017 0.202660,\
58 | 25 0.078815 0.054184 0.211667,\
59 | 26 0.083446 0.056225 0.220755,\
60 | 27 0.088155 0.058133 0.229922,\
61 | 28 0.092949 0.059904 0.239164,\
62 | 29 0.097833 0.061531 0.248477,\
63 | 30 0.102815 0.063010 0.257854,\
64 | 31 0.107899 0.064335 0.267289,\
65 | 32 0.113094 0.065492 0.276784,\
66 | 33 0.118405 0.066479 0.286321,\
67 | 34 0.123833 0.067295 0.295879,\
68 | 35 0.129380 0.067935 0.305443,\
69 | 36 0.135053 0.068391 0.315000,\
70 | 37 0.140858 0.068654 0.324538,\
71 | 38 0.146785 0.068738 0.334011,\
72 | 39 0.152839 0.068637 0.343404,\
73 | 40 0.159018 0.068354 0.352688,\
74 | 41 0.165308 0.067911 0.361816,\
75 | 42 0.171713 0.067305 0.370771,\
76 | 43 0.178212 0.066576 0.379497,\
77 | 44 0.184801 0.065732 0.387973,\
78 | 45 0.191460 0.064818 0.396152,\
79 | 46 0.198177 0.063862 0.404009,\
80 | 47 0.204935 0.062907 0.411514,\
81 | 48 0.211718 0.061992 0.418647,\
82 | 49 0.218512 0.061158 0.425392,\
83 | 50 0.225302 0.060445 0.431742,\
84 | 51 0.232077 0.059889 0.437695,\
85 | 52 0.238826 0.059517 0.443256,\
86 | 53 0.245543 0.059352 0.448436,\
87 | 54 0.252220 0.059415 0.453248,\
88 | 55 0.258857 0.059706 0.457710,\
89 | 56 0.265447 0.060237 0.461840,\
90 | 57 0.271994 0.060994 0.465660,\
91 | 58 0.278493 0.061978 0.469190,\
92 | 59 0.284951 0.063168 0.472451,\
93 | 60 0.291366 0.064553 0.475462,\
94 | 61 0.297740 0.066117 0.478243,\
95 | 62 0.304081 0.067835 0.480812,\
96 | 63 0.310382 0.069702 0.483186,\
97 | 64 0.316654 0.071690 0.485380,\
98 | 65 0.322899 0.073782 0.487408,\
99 | 66 0.329114 0.075972 0.489287,\
100 | 67 0.335308 0.078236 0.491024,\
101 | 68 0.341482 0.080564 0.492631,\
102 | 69 0.347636 0.082946 0.494121,\
103 | 70 0.353773 0.085373 0.495501,\
104 | 71 0.359898 0.087831 0.496778,\
105 | 72 0.366012 0.090314 0.497960,\
106 | 73 0.372116 0.092816 0.499053,\
107 | 74 0.378211 0.095332 0.500067,\
108 | 75 0.384299 0.097855 0.501002,\
109 | 76 0.390384 0.100379 0.501864,\
110 | 77 0.396467 0.102902 0.502658,\
111 | 78 0.402548 0.105420 0.503386,\
112 | 79 0.408629 0.107930 0.504052,\
113 | 80 0.414709 0.110431 0.504662,\
114 | 81 0.420791 0.112920 0.505215,\
115 | 82 0.426877 0.115395 0.505714,\
116 | 83 0.432967 0.117855 0.506160,\
117 | 84 0.439062 0.120298 0.506555,\
118 | 85 0.445163 0.122724 0.506901,\
119 | 86 0.451271 0.125132 0.507198,\
120 | 87 0.457386 0.127522 0.507448,\
121 | 88 0.463508 0.129893 0.507652,\
122 | 89 0.469640 0.132245 0.507809,\
123 | 90 0.475780 0.134577 0.507921,\
124 | 91 0.481929 0.136891 0.507989,\
125 | 92 0.488088 0.139186 0.508011,\
126 | 93 0.494258 0.141462 0.507988,\
127 | 94 0.500438 0.143719 0.507920,\
128 | 95 0.506629 0.145958 0.507806,\
129 | 96 0.512831 0.148179 0.507648,\
130 | 97 0.519045 0.150383 0.507443,\
131 | 98 0.525270 0.152569 0.507192,\
132 | 99 0.531507 0.154739 0.506895,\
133 | 100 0.537755 0.156894 0.506551,\
134 | 101 0.544015 0.159033 0.506159,\
135 | 102 0.550287 0.161158 0.505719,\
136 | 103 0.556571 0.163269 0.505230,\
137 | 104 0.562866 0.165368 0.504692,\
138 | 105 0.569172 0.167454 0.504105,\
139 | 106 0.575490 0.169530 0.503466,\
140 | 107 0.581819 0.171596 0.502777,\
141 | 108 0.588158 0.173652 0.502035,\
142 | 109 0.594508 0.175701 0.501241,\
143 | 110 0.600868 0.177743 0.500394,\
144 | 111 0.607238 0.179779 0.499492,\
145 | 112 0.613617 0.181811 0.498536,\
146 | 113 0.620005 0.183840 0.497524,\
147 | 114 0.626401 0.185867 0.496456,\
148 | 115 0.632805 0.187893 0.495332,\
149 | 116 0.639216 0.189921 0.494150,\
150 | 117 0.645633 0.191952 0.492910,\
151 | 118 0.652056 0.193986 0.491611,\
152 | 119 0.658483 0.196027 0.490253,\
153 | 120 0.664915 0.198075 0.488836,\
154 | 121 0.671349 0.200133 0.487358,\
155 | 122 0.677786 0.202203 0.485819,\
156 | 123 0.684224 0.204286 0.484219,\
157 | 124 0.690661 0.206384 0.482558,\
158 | 125 0.697098 0.208501 0.480835,\
159 | 126 0.703532 0.210638 0.479049,\
160 | 127 0.709962 0.212797 0.477201,\
161 | 128 0.716387 0.214982 0.475290,\
162 | 129 0.722805 0.217194 0.473316,\
163 | 130 0.729216 0.219437 0.471279,\
164 | 131 0.735616 0.221713 0.469180,\
165 | 132 0.742004 0.224025 0.467018,\
166 | 133 0.748378 0.226377 0.464794,\
167 | 134 0.754737 0.228772 0.462509,\
168 | 135 0.761077 0.231214 0.460162,\
169 | 136 0.767398 0.233705 0.457755,\
170 | 137 0.773695 0.236249 0.455289,\
171 | 138 0.779968 0.238851 0.452765,\
172 | 139 0.786212 0.241514 0.450184,\
173 | 140 0.792427 0.244242 0.447543,\
174 | 141 0.798608 0.247040 0.444848,\
175 | 142 0.804752 0.249911 0.442102,\
176 | 143 0.810855 0.252861 0.439305,\
177 | 144 0.816914 0.255895 0.436461,\
178 | 145 0.822926 0.259016 0.433573,\
179 | 146 0.828886 0.262229 0.430644,\
180 | 147 0.834791 0.265540 0.427671,\
181 | 148 0.840636 0.268953 0.424666,\
182 | 149 0.846416 0.272473 0.421631,\
183 | 150 0.852126 0.276106 0.418573,\
184 | 151 0.857763 0.279857 0.415496,\
185 | 152 0.863320 0.283729 0.412403,\
186 | 153 0.868793 0.287728 0.409303,\
187 | 154 0.874176 0.291859 0.406205,\
188 | 155 0.879464 0.296125 0.403118,\
189 | 156 0.884651 0.300530 0.400047,\
190 | 157 0.889731 0.305079 0.397002,\
191 | 158 0.894700 0.309773 0.393995,\
192 | 159 0.899552 0.314616 0.391037,\
193 | 160 0.904281 0.319610 0.388137,\
194 | 161 0.908884 0.324755 0.385308,\
195 | 162 0.913354 0.330052 0.382563,\
196 | 163 0.917689 0.335500 0.379915,\
197 | 164 0.921884 0.341098 0.377376,\
198 | 165 0.925937 0.346844 0.374959,\
199 | 166 0.929845 0.352734 0.372677,\
200 | 167 0.933606 0.358764 0.370541,\
201 | 168 0.937221 0.364929 0.368567,\
202 | 169 0.940687 0.371224 0.366762,\
203 | 170 0.944006 0.377643 0.365136,\
204 | 171 0.947180 0.384178 0.363701,\
205 | 172 0.950210 0.390820 0.362468,\
206 | 173 0.953099 0.397563 0.361438,\
207 | 174 0.955849 0.404400 0.360619,\
208 | 175 0.958464 0.411324 0.360014,\
209 | 176 0.960949 0.418323 0.359630,\
210 | 177 0.963310 0.425390 0.359469,\
211 | 178 0.965549 0.432519 0.359529,\
212 | 179 0.967671 0.439703 0.359810,\
213 | 180 0.969680 0.446936 0.360311,\
214 | 181 0.971582 0.454210 0.361030,\
215 | 182 0.973381 0.461520 0.361965,\
216 | 183 0.975082 0.468861 0.363111,\
217 | 184 0.976690 0.476226 0.364466,\
218 | 185 0.978210 0.483612 0.366025,\
219 | 186 0.979645 0.491014 0.367783,\
220 | 187 0.981000 0.498428 0.369734,\
221 | 188 0.982279 0.505851 0.371874,\
222 | 189 0.983485 0.513280 0.374198,\
223 | 190 0.984622 0.520713 0.376698,\
224 | 191 0.985693 0.528148 0.379371,\
225 | 192 0.986700 0.535582 0.382210,\
226 | 193 0.987646 0.543015 0.385210,\
227 | 194 0.988533 0.550446 0.388365,\
228 | 195 0.989363 0.557873 0.391671,\
229 | 196 0.990138 0.565296 0.395122,\
230 | 197 0.990871 0.572706 0.398714,\
231 | 198 0.991558 0.580107 0.402441,\
232 | 199 0.992196 0.587502 0.406299,\
233 | 200 0.992785 0.594891 0.410283,\
234 | 201 0.993326 0.602275 0.414390,\
235 | 202 0.993834 0.609644 0.418613,\
236 | 203 0.994309 0.616999 0.422950,\
237 | 204 0.994738 0.624350 0.427397,\
238 | 205 0.995122 0.631696 0.431951,\
239 | 206 0.995480 0.639027 0.436607,\
240 | 207 0.995810 0.646344 0.441361,\
241 | 208 0.996096 0.653659 0.446213,\
242 | 209 0.996341 0.660969 0.451160,\
243 | 210 0.996580 0.668256 0.456192,\
244 | 211 0.996775 0.675541 0.461314,\
245 | 212 0.996925 0.682828 0.466526,\
246 | 213 0.997077 0.690088 0.471811,\
247 | 214 0.997186 0.697349 0.477182,\
248 | 215 0.997254 0.704611 0.482635,\
249 | 216 0.997325 0.711848 0.488154,\
250 | 217 0.997351 0.719089 0.493755,\
251 | 218 0.997351 0.726324 0.499428,\
252 | 219 0.997341 0.733545 0.505167,\
253 | 220 0.997285 0.740772 0.510983,\
254 | 221 0.997228 0.747981 0.516859,\
255 | 222 0.997138 0.755190 0.522806,\
256 | 223 0.997019 0.762398 0.528821,\
257 | 224 0.996898 0.769591 0.534892,\
258 | 225 0.996727 0.776795 0.541039,\
259 | 226 0.996571 0.783977 0.547233,\
260 | 227 0.996369 0.791167 0.553499,\
261 | 228 0.996162 0.798348 0.559820,\
262 | 229 0.995932 0.805527 0.566202,\
263 | 230 0.995680 0.812706 0.572645,\
264 | 231 0.995424 0.819875 0.579140,\
265 | 232 0.995131 0.827052 0.585701,\
266 | 233 0.994851 0.834213 0.592307,\
267 | 234 0.994524 0.841387 0.598983,\
268 | 235 0.994222 0.848540 0.605696,\
269 | 236 0.993866 0.855711 0.612482,\
270 | 237 0.993545 0.862859 0.619299,\
271 | 238 0.993170 0.870024 0.626189,\
272 | 239 0.992831 0.877168 0.633109,\
273 | 240 0.992440 0.884330 0.640099,\
274 | 241 0.992089 0.891470 0.647116,\
275 | 242 0.991688 0.898627 0.654202,\
276 | 243 0.991332 0.905763 0.661309,\
277 | 244 0.990930 0.912915 0.668481,\
278 | 245 0.990570 0.920049 0.675675,\
279 | 246 0.990175 0.927196 0.682926,\
280 | 247 0.989815 0.934329 0.690198,\
281 | 248 0.989434 0.941470 0.697519,\
282 | 249 0.989077 0.948604 0.704863,\
283 | 250 0.988717 0.955742 0.712242,\
284 | 251 0.988367 0.962878 0.719649,\
285 | 252 0.988033 0.970012 0.727077,\
286 | 253 0.987691 0.977154 0.734536,\
287 | 254 0.987387 0.984288 0.742002,\
288 | 255 0.987053 0.991438 0.749504)
289 |
--------------------------------------------------------------------------------
/etc/palettes/plasma.pal:
--------------------------------------------------------------------------------
1 | # New matplotlib colormaps by Nathaniel J. Smith, Stefan van der Walt,
2 | # and (in the case of viridis) Eric Firing.
3 | #
4 | # This file and the colormaps in it are released under the CC0 license /
5 | # public domain dedication. We would appreciate credit if you use or
6 | # redistribute these colormaps, but do not impose any legal restrictions.
7 | #
8 | # To the extent possible under law, the persons who associated CC0 with
9 | # mpl-colormaps have waived all copyright and related or neighboring rights
10 | # to mpl-colormaps.
11 | #
12 | # You should have received a copy of the CC0 legalcode along with this
13 | # work. If not, see .
14 |
15 | #https://github.com/BIDS/colormap/blob/master/colormaps.py
16 |
17 |
18 | # line styles
19 | set style line 1 lt 1 lc rgb '#0c0887' # blue
20 | set style line 2 lt 1 lc rgb '#4b03a1' # purple-blue
21 | set style line 3 lt 1 lc rgb '#7d03a8' # purple
22 | set style line 4 lt 1 lc rgb '#a82296' # purple
23 | set style line 5 lt 1 lc rgb '#cb4679' # magenta
24 | set style line 6 lt 1 lc rgb '#e56b5d' # red
25 | set style line 7 lt 1 lc rgb '#f89441' # orange
26 | set style line 8 lt 1 lc rgb '#fdc328' # orange
27 | set style line 9 lt 1 lc rgb '#f0f921' # yellow
28 |
29 |
30 | # palette
31 | set palette defined (\
32 | 0 0.050383 0.029803 0.527975,\
33 | 1 0.063536 0.028426 0.533124,\
34 | 2 0.075353 0.027206 0.538007,\
35 | 3 0.086222 0.026125 0.542658,\
36 | 4 0.096379 0.025165 0.547103,\
37 | 5 0.105980 0.024309 0.551368,\
38 | 6 0.115124 0.023556 0.555468,\
39 | 7 0.123903 0.022878 0.559423,\
40 | 8 0.132381 0.022258 0.563250,\
41 | 9 0.140603 0.021687 0.566959,\
42 | 10 0.148607 0.021154 0.570562,\
43 | 11 0.156421 0.020651 0.574065,\
44 | 12 0.164070 0.020171 0.577478,\
45 | 13 0.171574 0.019706 0.580806,\
46 | 14 0.178950 0.019252 0.584054,\
47 | 15 0.186213 0.018803 0.587228,\
48 | 16 0.193374 0.018354 0.590330,\
49 | 17 0.200445 0.017902 0.593364,\
50 | 18 0.207435 0.017442 0.596333,\
51 | 19 0.214350 0.016973 0.599239,\
52 | 20 0.221197 0.016497 0.602083,\
53 | 21 0.227983 0.016007 0.604867,\
54 | 22 0.234715 0.015502 0.607592,\
55 | 23 0.241396 0.014979 0.610259,\
56 | 24 0.248032 0.014439 0.612868,\
57 | 25 0.254627 0.013882 0.615419,\
58 | 26 0.261183 0.013308 0.617911,\
59 | 27 0.267703 0.012716 0.620346,\
60 | 28 0.274191 0.012109 0.622722,\
61 | 29 0.280648 0.011488 0.625038,\
62 | 30 0.287076 0.010855 0.627295,\
63 | 31 0.293478 0.010213 0.629490,\
64 | 32 0.299855 0.009561 0.631624,\
65 | 33 0.306210 0.008902 0.633694,\
66 | 34 0.312543 0.008239 0.635700,\
67 | 35 0.318856 0.007576 0.637640,\
68 | 36 0.325150 0.006915 0.639512,\
69 | 37 0.331426 0.006261 0.641316,\
70 | 38 0.337683 0.005618 0.643049,\
71 | 39 0.343925 0.004991 0.644710,\
72 | 40 0.350150 0.004382 0.646298,\
73 | 41 0.356359 0.003798 0.647810,\
74 | 42 0.362553 0.003243 0.649245,\
75 | 43 0.368733 0.002724 0.650601,\
76 | 44 0.374897 0.002245 0.651876,\
77 | 45 0.381047 0.001814 0.653068,\
78 | 46 0.387183 0.001434 0.654177,\
79 | 47 0.393304 0.001114 0.655199,\
80 | 48 0.399411 0.000859 0.656133,\
81 | 49 0.405503 0.000678 0.656977,\
82 | 50 0.411580 0.000577 0.657730,\
83 | 51 0.417642 0.000564 0.658390,\
84 | 52 0.423689 0.000646 0.658956,\
85 | 53 0.429719 0.000831 0.659425,\
86 | 54 0.435734 0.001127 0.659797,\
87 | 55 0.441732 0.001540 0.660069,\
88 | 56 0.447714 0.002080 0.660240,\
89 | 57 0.453677 0.002755 0.660310,\
90 | 58 0.459623 0.003574 0.660277,\
91 | 59 0.465550 0.004545 0.660139,\
92 | 60 0.471457 0.005678 0.659897,\
93 | 61 0.477344 0.006980 0.659549,\
94 | 62 0.483210 0.008460 0.659095,\
95 | 63 0.489055 0.010127 0.658534,\
96 | 64 0.494877 0.011990 0.657865,\
97 | 65 0.500678 0.014055 0.657088,\
98 | 66 0.506454 0.016333 0.656202,\
99 | 67 0.512206 0.018833 0.655209,\
100 | 68 0.517933 0.021563 0.654109,\
101 | 69 0.523633 0.024532 0.652901,\
102 | 70 0.529306 0.027747 0.651586,\
103 | 71 0.534952 0.031217 0.650165,\
104 | 72 0.540570 0.034950 0.648640,\
105 | 73 0.546157 0.038954 0.647010,\
106 | 74 0.551715 0.043136 0.645277,\
107 | 75 0.557243 0.047331 0.643443,\
108 | 76 0.562738 0.051545 0.641509,\
109 | 77 0.568201 0.055778 0.639477,\
110 | 78 0.573632 0.060028 0.637349,\
111 | 79 0.579029 0.064296 0.635126,\
112 | 80 0.584391 0.068579 0.632812,\
113 | 81 0.589719 0.072878 0.630408,\
114 | 82 0.595011 0.077190 0.627917,\
115 | 83 0.600266 0.081516 0.625342,\
116 | 84 0.605485 0.085854 0.622686,\
117 | 85 0.610667 0.090204 0.619951,\
118 | 86 0.615812 0.094564 0.617140,\
119 | 87 0.620919 0.098934 0.614257,\
120 | 88 0.625987 0.103312 0.611305,\
121 | 89 0.631017 0.107699 0.608287,\
122 | 90 0.636008 0.112092 0.605205,\
123 | 91 0.640959 0.116492 0.602065,\
124 | 92 0.645872 0.120898 0.598867,\
125 | 93 0.650746 0.125309 0.595617,\
126 | 94 0.655580 0.129725 0.592317,\
127 | 95 0.660374 0.134144 0.588971,\
128 | 96 0.665129 0.138566 0.585582,\
129 | 97 0.669845 0.142992 0.582154,\
130 | 98 0.674522 0.147419 0.578688,\
131 | 99 0.679160 0.151848 0.575189,\
132 | 100 0.683758 0.156278 0.571660,\
133 | 101 0.688318 0.160709 0.568103,\
134 | 102 0.692840 0.165141 0.564522,\
135 | 103 0.697324 0.169573 0.560919,\
136 | 104 0.701769 0.174005 0.557296,\
137 | 105 0.706178 0.178437 0.553657,\
138 | 106 0.710549 0.182868 0.550004,\
139 | 107 0.714883 0.187299 0.546338,\
140 | 108 0.719181 0.191729 0.542663,\
141 | 109 0.723444 0.196158 0.538981,\
142 | 110 0.727670 0.200586 0.535293,\
143 | 111 0.731862 0.205013 0.531601,\
144 | 112 0.736019 0.209439 0.527908,\
145 | 113 0.740143 0.213864 0.524216,\
146 | 114 0.744232 0.218288 0.520524,\
147 | 115 0.748289 0.222711 0.516834,\
148 | 116 0.752312 0.227133 0.513149,\
149 | 117 0.756304 0.231555 0.509468,\
150 | 118 0.760264 0.235976 0.505794,\
151 | 119 0.764193 0.240396 0.502126,\
152 | 120 0.768090 0.244817 0.498465,\
153 | 121 0.771958 0.249237 0.494813,\
154 | 122 0.775796 0.253658 0.491171,\
155 | 123 0.779604 0.258078 0.487539,\
156 | 124 0.783383 0.262500 0.483918,\
157 | 125 0.787133 0.266922 0.480307,\
158 | 126 0.790855 0.271345 0.476706,\
159 | 127 0.794549 0.275770 0.473117,\
160 | 128 0.798216 0.280197 0.469538,\
161 | 129 0.801855 0.284626 0.465971,\
162 | 130 0.805467 0.289057 0.462415,\
163 | 131 0.809052 0.293491 0.458870,\
164 | 132 0.812612 0.297928 0.455338,\
165 | 133 0.816144 0.302368 0.451816,\
166 | 134 0.819651 0.306812 0.448306,\
167 | 135 0.823132 0.311261 0.444806,\
168 | 136 0.826588 0.315714 0.441316,\
169 | 137 0.830018 0.320172 0.437836,\
170 | 138 0.833422 0.324635 0.434366,\
171 | 139 0.836801 0.329105 0.430905,\
172 | 140 0.840155 0.333580 0.427455,\
173 | 141 0.843484 0.338062 0.424013,\
174 | 142 0.846788 0.342551 0.420579,\
175 | 143 0.850066 0.347048 0.417153,\
176 | 144 0.853319 0.351553 0.413734,\
177 | 145 0.856547 0.356066 0.410322,\
178 | 146 0.859750 0.360588 0.406917,\
179 | 147 0.862927 0.365119 0.403519,\
180 | 148 0.866078 0.369660 0.400126,\
181 | 149 0.869203 0.374212 0.396738,\
182 | 150 0.872303 0.378774 0.393355,\
183 | 151 0.875376 0.383347 0.389976,\
184 | 152 0.878423 0.387932 0.386600,\
185 | 153 0.881443 0.392529 0.383229,\
186 | 154 0.884436 0.397139 0.379860,\
187 | 155 0.887402 0.401762 0.376494,\
188 | 156 0.890340 0.406398 0.373130,\
189 | 157 0.893250 0.411048 0.369768,\
190 | 158 0.896131 0.415712 0.366407,\
191 | 159 0.898984 0.420392 0.363047,\
192 | 160 0.901807 0.425087 0.359688,\
193 | 161 0.904601 0.429797 0.356329,\
194 | 162 0.907365 0.434524 0.352970,\
195 | 163 0.910098 0.439268 0.349610,\
196 | 164 0.912800 0.444029 0.346251,\
197 | 165 0.915471 0.448807 0.342890,\
198 | 166 0.918109 0.453603 0.339529,\
199 | 167 0.920714 0.458417 0.336166,\
200 | 168 0.923287 0.463251 0.332801,\
201 | 169 0.925825 0.468103 0.329435,\
202 | 170 0.928329 0.472975 0.326067,\
203 | 171 0.930798 0.477867 0.322697,\
204 | 172 0.933232 0.482780 0.319325,\
205 | 173 0.935630 0.487712 0.315952,\
206 | 174 0.937990 0.492667 0.312575,\
207 | 175 0.940313 0.497642 0.309197,\
208 | 176 0.942598 0.502639 0.305816,\
209 | 177 0.944844 0.507658 0.302433,\
210 | 178 0.947051 0.512699 0.299049,\
211 | 179 0.949217 0.517763 0.295662,\
212 | 180 0.951344 0.522850 0.292275,\
213 | 181 0.953428 0.527960 0.288883,\
214 | 182 0.955470 0.533093 0.285490,\
215 | 183 0.957469 0.538250 0.282096,\
216 | 184 0.959424 0.543431 0.278701,\
217 | 185 0.961336 0.548636 0.275305,\
218 | 186 0.963203 0.553865 0.271909,\
219 | 187 0.965024 0.559118 0.268513,\
220 | 188 0.966798 0.564396 0.265118,\
221 | 189 0.968526 0.569700 0.261721,\
222 | 190 0.970205 0.575028 0.258325,\
223 | 191 0.971835 0.580382 0.254931,\
224 | 192 0.973416 0.585761 0.251540,\
225 | 193 0.974947 0.591165 0.248151,\
226 | 194 0.976428 0.596595 0.244767,\
227 | 195 0.977856 0.602051 0.241387,\
228 | 196 0.979233 0.607532 0.238013,\
229 | 197 0.980556 0.613039 0.234646,\
230 | 198 0.981826 0.618572 0.231287,\
231 | 199 0.983041 0.624131 0.227937,\
232 | 200 0.984199 0.629718 0.224595,\
233 | 201 0.985301 0.635330 0.221265,\
234 | 202 0.986345 0.640969 0.217948,\
235 | 203 0.987332 0.646633 0.214648,\
236 | 204 0.988260 0.652325 0.211364,\
237 | 205 0.989128 0.658043 0.208100,\
238 | 206 0.989935 0.663787 0.204859,\
239 | 207 0.990681 0.669558 0.201642,\
240 | 208 0.991365 0.675355 0.198453,\
241 | 209 0.991985 0.681179 0.195295,\
242 | 210 0.992541 0.687030 0.192170,\
243 | 211 0.993032 0.692907 0.189084,\
244 | 212 0.993456 0.698810 0.186041,\
245 | 213 0.993814 0.704741 0.183043,\
246 | 214 0.994103 0.710698 0.180097,\
247 | 215 0.994324 0.716681 0.177208,\
248 | 216 0.994474 0.722691 0.174381,\
249 | 217 0.994553 0.728728 0.171622,\
250 | 218 0.994561 0.734791 0.168938,\
251 | 219 0.994495 0.740880 0.166335,\
252 | 220 0.994355 0.746995 0.163821,\
253 | 221 0.994141 0.753137 0.161404,\
254 | 222 0.993851 0.759304 0.159092,\
255 | 223 0.993482 0.765499 0.156891,\
256 | 224 0.993033 0.771720 0.154808,\
257 | 225 0.992505 0.777967 0.152855,\
258 | 226 0.991897 0.784239 0.151042,\
259 | 227 0.991209 0.790537 0.149377,\
260 | 228 0.990439 0.796859 0.147870,\
261 | 229 0.989587 0.803205 0.146529,\
262 | 230 0.988648 0.809579 0.145357,\
263 | 231 0.987621 0.815978 0.144363,\
264 | 232 0.986509 0.822401 0.143557,\
265 | 233 0.985314 0.828846 0.142945,\
266 | 234 0.984031 0.835315 0.142528,\
267 | 235 0.982653 0.841812 0.142303,\
268 | 236 0.981190 0.848329 0.142279,\
269 | 237 0.979644 0.854866 0.142453,\
270 | 238 0.977995 0.861432 0.142808,\
271 | 239 0.976265 0.868016 0.143351,\
272 | 240 0.974443 0.874622 0.144061,\
273 | 241 0.972530 0.881250 0.144923,\
274 | 242 0.970533 0.887896 0.145919,\
275 | 243 0.968443 0.894564 0.147014,\
276 | 244 0.966271 0.901249 0.148180,\
277 | 245 0.964021 0.907950 0.149370,\
278 | 246 0.961681 0.914672 0.150520,\
279 | 247 0.959276 0.921407 0.151566,\
280 | 248 0.956808 0.928152 0.152409,\
281 | 249 0.954287 0.934908 0.152921,\
282 | 250 0.951726 0.941671 0.152925,\
283 | 251 0.949151 0.948435 0.152178,\
284 | 252 0.946602 0.955190 0.150328,\
285 | 253 0.944152 0.961916 0.146861,\
286 | 254 0.941896 0.968590 0.140956,\
287 | 255 0.940015 0.975158 0.131326)
288 |
--------------------------------------------------------------------------------
/etc/palettes/viridis.pal:
--------------------------------------------------------------------------------
1 | # New matplotlib colormaps by Nathaniel J. Smith, Stefan van der Walt,
2 | # and (in the case of viridis) Eric Firing.
3 | #
4 | # This file and the colormaps in it are released under the CC0 license /
5 | # public domain dedication. We would appreciate credit if you use or
6 | # redistribute these colormaps, but do not impose any legal restrictions.
7 | #
8 | # To the extent possible under law, the persons who associated CC0 with
9 | # mpl-colormaps have waived all copyright and related or neighboring rights
10 | # to mpl-colormaps.
11 | #
12 | # You should have received a copy of the CC0 legalcode along with this
13 | # work. If not, see .
14 |
15 | #https://github.com/BIDS/colormap/blob/master/colormaps.py
16 |
17 |
18 | # line styles
19 | set style line 1 lt 1 lc rgb '#440154' # dark purple
20 | set style line 2 lt 1 lc rgb '#472c7a' # purple
21 | set style line 3 lt 1 lc rgb '#3b518b' # blue
22 | set style line 4 lt 1 lc rgb '#2c718e' # blue
23 | set style line 5 lt 1 lc rgb '#21908d' # blue-green
24 | set style line 6 lt 1 lc rgb '#27ad81' # green
25 | set style line 7 lt 1 lc rgb '#5cc863' # green
26 | set style line 8 lt 1 lc rgb '#aadc32' # lime green
27 | set style line 9 lt 1 lc rgb '#fde725' # yellow
28 |
29 |
30 | # palette
31 | set palette defined (\
32 | 0 0.267004 0.004874 0.329415,\
33 | 1 0.268510 0.009605 0.335427,\
34 | 2 0.269944 0.014625 0.341379,\
35 | 3 0.271305 0.019942 0.347269,\
36 | 4 0.272594 0.025563 0.353093,\
37 | 5 0.273809 0.031497 0.358853,\
38 | 6 0.274952 0.037752 0.364543,\
39 | 7 0.276022 0.044167 0.370164,\
40 | 8 0.277018 0.050344 0.375715,\
41 | 9 0.277941 0.056324 0.381191,\
42 | 10 0.278791 0.062145 0.386592,\
43 | 11 0.279566 0.067836 0.391917,\
44 | 12 0.280267 0.073417 0.397163,\
45 | 13 0.280894 0.078907 0.402329,\
46 | 14 0.281446 0.084320 0.407414,\
47 | 15 0.281924 0.089666 0.412415,\
48 | 16 0.282327 0.094955 0.417331,\
49 | 17 0.282656 0.100196 0.422160,\
50 | 18 0.282910 0.105393 0.426902,\
51 | 19 0.283091 0.110553 0.431554,\
52 | 20 0.283197 0.115680 0.436115,\
53 | 21 0.283229 0.120777 0.440584,\
54 | 22 0.283187 0.125848 0.444960,\
55 | 23 0.283072 0.130895 0.449241,\
56 | 24 0.282884 0.135920 0.453427,\
57 | 25 0.282623 0.140926 0.457517,\
58 | 26 0.282290 0.145912 0.461510,\
59 | 27 0.281887 0.150881 0.465405,\
60 | 28 0.281412 0.155834 0.469201,\
61 | 29 0.280868 0.160771 0.472899,\
62 | 30 0.280255 0.165693 0.476498,\
63 | 31 0.279574 0.170599 0.479997,\
64 | 32 0.278826 0.175490 0.483397,\
65 | 33 0.278012 0.180367 0.486697,\
66 | 34 0.277134 0.185228 0.489898,\
67 | 35 0.276194 0.190074 0.493001,\
68 | 36 0.275191 0.194905 0.496005,\
69 | 37 0.274128 0.199721 0.498911,\
70 | 38 0.273006 0.204520 0.501721,\
71 | 39 0.271828 0.209303 0.504434,\
72 | 40 0.270595 0.214069 0.507052,\
73 | 41 0.269308 0.218818 0.509577,\
74 | 42 0.267968 0.223549 0.512008,\
75 | 43 0.266580 0.228262 0.514349,\
76 | 44 0.265145 0.232956 0.516599,\
77 | 45 0.263663 0.237631 0.518762,\
78 | 46 0.262138 0.242286 0.520837,\
79 | 47 0.260571 0.246922 0.522828,\
80 | 48 0.258965 0.251537 0.524736,\
81 | 49 0.257322 0.256130 0.526563,\
82 | 50 0.255645 0.260703 0.528312,\
83 | 51 0.253935 0.265254 0.529983,\
84 | 52 0.252194 0.269783 0.531579,\
85 | 53 0.250425 0.274290 0.533103,\
86 | 54 0.248629 0.278775 0.534556,\
87 | 55 0.246811 0.283237 0.535941,\
88 | 56 0.244972 0.287675 0.537260,\
89 | 57 0.243113 0.292092 0.538516,\
90 | 58 0.241237 0.296485 0.539709,\
91 | 59 0.239346 0.300855 0.540844,\
92 | 60 0.237441 0.305202 0.541921,\
93 | 61 0.235526 0.309527 0.542944,\
94 | 62 0.233603 0.313828 0.543914,\
95 | 63 0.231674 0.318106 0.544834,\
96 | 64 0.229739 0.322361 0.545706,\
97 | 65 0.227802 0.326594 0.546532,\
98 | 66 0.225863 0.330805 0.547314,\
99 | 67 0.223925 0.334994 0.548053,\
100 | 68 0.221989 0.339161 0.548752,\
101 | 69 0.220057 0.343307 0.549413,\
102 | 70 0.218130 0.347432 0.550038,\
103 | 71 0.216210 0.351535 0.550627,\
104 | 72 0.214298 0.355619 0.551184,\
105 | 73 0.212395 0.359683 0.551710,\
106 | 74 0.210503 0.363727 0.552206,\
107 | 75 0.208623 0.367752 0.552675,\
108 | 76 0.206756 0.371758 0.553117,\
109 | 77 0.204903 0.375746 0.553533,\
110 | 78 0.203063 0.379716 0.553925,\
111 | 79 0.201239 0.383670 0.554294,\
112 | 80 0.199430 0.387607 0.554642,\
113 | 81 0.197636 0.391528 0.554969,\
114 | 82 0.195860 0.395433 0.555276,\
115 | 83 0.194100 0.399323 0.555565,\
116 | 84 0.192357 0.403199 0.555836,\
117 | 85 0.190631 0.407061 0.556089,\
118 | 86 0.188923 0.410910 0.556326,\
119 | 87 0.187231 0.414746 0.556547,\
120 | 88 0.185556 0.418570 0.556753,\
121 | 89 0.183898 0.422383 0.556944,\
122 | 90 0.182256 0.426184 0.557120,\
123 | 91 0.180629 0.429975 0.557282,\
124 | 92 0.179019 0.433756 0.557430,\
125 | 93 0.177423 0.437527 0.557565,\
126 | 94 0.175841 0.441290 0.557685,\
127 | 95 0.174274 0.445044 0.557792,\
128 | 96 0.172719 0.448791 0.557885,\
129 | 97 0.171176 0.452530 0.557965,\
130 | 98 0.169646 0.456262 0.558030,\
131 | 99 0.168126 0.459988 0.558082,\
132 | 100 0.166617 0.463708 0.558119,\
133 | 101 0.165117 0.467423 0.558141,\
134 | 102 0.163625 0.471133 0.558148,\
135 | 103 0.162142 0.474838 0.558140,\
136 | 104 0.160665 0.478540 0.558115,\
137 | 105 0.159194 0.482237 0.558073,\
138 | 106 0.157729 0.485932 0.558013,\
139 | 107 0.156270 0.489624 0.557936,\
140 | 108 0.154815 0.493313 0.557840,\
141 | 109 0.153364 0.497000 0.557724,\
142 | 110 0.151918 0.500685 0.557587,\
143 | 111 0.150476 0.504369 0.557430,\
144 | 112 0.149039 0.508051 0.557250,\
145 | 113 0.147607 0.511733 0.557049,\
146 | 114 0.146180 0.515413 0.556823,\
147 | 115 0.144759 0.519093 0.556572,\
148 | 116 0.143343 0.522773 0.556295,\
149 | 117 0.141935 0.526453 0.555991,\
150 | 118 0.140536 0.530132 0.555659,\
151 | 119 0.139147 0.533812 0.555298,\
152 | 120 0.137770 0.537492 0.554906,\
153 | 121 0.136408 0.541173 0.554483,\
154 | 122 0.135066 0.544853 0.554029,\
155 | 123 0.133743 0.548535 0.553541,\
156 | 124 0.132444 0.552216 0.553018,\
157 | 125 0.131172 0.555899 0.552459,\
158 | 126 0.129933 0.559582 0.551864,\
159 | 127 0.128729 0.563265 0.551229,\
160 | 128 0.127568 0.566949 0.550556,\
161 | 129 0.126453 0.570633 0.549841,\
162 | 130 0.125394 0.574318 0.549086,\
163 | 131 0.124395 0.578002 0.548287,\
164 | 132 0.123463 0.581687 0.547445,\
165 | 133 0.122606 0.585371 0.546557,\
166 | 134 0.121831 0.589055 0.545623,\
167 | 135 0.121148 0.592739 0.544641,\
168 | 136 0.120565 0.596422 0.543611,\
169 | 137 0.120092 0.600104 0.542530,\
170 | 138 0.119738 0.603785 0.541400,\
171 | 139 0.119512 0.607464 0.540218,\
172 | 140 0.119423 0.611141 0.538982,\
173 | 141 0.119483 0.614817 0.537692,\
174 | 142 0.119699 0.618490 0.536347,\
175 | 143 0.120081 0.622161 0.534946,\
176 | 144 0.120638 0.625828 0.533488,\
177 | 145 0.121380 0.629492 0.531973,\
178 | 146 0.122312 0.633153 0.530398,\
179 | 147 0.123444 0.636809 0.528763,\
180 | 148 0.124780 0.640461 0.527068,\
181 | 149 0.126326 0.644107 0.525311,\
182 | 150 0.128087 0.647749 0.523491,\
183 | 151 0.130067 0.651384 0.521608,\
184 | 152 0.132268 0.655014 0.519661,\
185 | 153 0.134692 0.658636 0.517649,\
186 | 154 0.137339 0.662252 0.515571,\
187 | 155 0.140210 0.665859 0.513427,\
188 | 156 0.143303 0.669459 0.511215,\
189 | 157 0.146616 0.673050 0.508936,\
190 | 158 0.150148 0.676631 0.506589,\
191 | 159 0.153894 0.680203 0.504172,\
192 | 160 0.157851 0.683765 0.501686,\
193 | 161 0.162016 0.687316 0.499129,\
194 | 162 0.166383 0.690856 0.496502,\
195 | 163 0.170948 0.694384 0.493803,\
196 | 164 0.175707 0.697900 0.491033,\
197 | 165 0.180653 0.701402 0.488189,\
198 | 166 0.185783 0.704891 0.485273,\
199 | 167 0.191090 0.708366 0.482284,\
200 | 168 0.196571 0.711827 0.479221,\
201 | 169 0.202219 0.715272 0.476084,\
202 | 170 0.208030 0.718701 0.472873,\
203 | 171 0.214000 0.722114 0.469588,\
204 | 172 0.220124 0.725509 0.466226,\
205 | 173 0.226397 0.728888 0.462789,\
206 | 174 0.232815 0.732247 0.459277,\
207 | 175 0.239374 0.735588 0.455688,\
208 | 176 0.246070 0.738910 0.452024,\
209 | 177 0.252899 0.742211 0.448284,\
210 | 178 0.259857 0.745492 0.444467,\
211 | 179 0.266941 0.748751 0.440573,\
212 | 180 0.274149 0.751988 0.436601,\
213 | 181 0.281477 0.755203 0.432552,\
214 | 182 0.288921 0.758394 0.428426,\
215 | 183 0.296479 0.761561 0.424223,\
216 | 184 0.304148 0.764704 0.419943,\
217 | 185 0.311925 0.767822 0.415586,\
218 | 186 0.319809 0.770914 0.411152,\
219 | 187 0.327796 0.773980 0.406640,\
220 | 188 0.335885 0.777018 0.402049,\
221 | 189 0.344074 0.780029 0.397381,\
222 | 190 0.352360 0.783011 0.392636,\
223 | 191 0.360741 0.785964 0.387814,\
224 | 192 0.369214 0.788888 0.382914,\
225 | 193 0.377779 0.791781 0.377939,\
226 | 194 0.386433 0.794644 0.372886,\
227 | 195 0.395174 0.797475 0.367757,\
228 | 196 0.404001 0.800275 0.362552,\
229 | 197 0.412913 0.803041 0.357269,\
230 | 198 0.421908 0.805774 0.351910,\
231 | 199 0.430983 0.808473 0.346476,\
232 | 200 0.440137 0.811138 0.340967,\
233 | 201 0.449368 0.813768 0.335384,\
234 | 202 0.458674 0.816363 0.329727,\
235 | 203 0.468053 0.818921 0.323998,\
236 | 204 0.477504 0.821444 0.318195,\
237 | 205 0.487026 0.823929 0.312321,\
238 | 206 0.496615 0.826376 0.306377,\
239 | 207 0.506271 0.828786 0.300362,\
240 | 208 0.515992 0.831158 0.294279,\
241 | 209 0.525776 0.833491 0.288127,\
242 | 210 0.535621 0.835785 0.281908,\
243 | 211 0.545524 0.838039 0.275626,\
244 | 212 0.555484 0.840254 0.269281,\
245 | 213 0.565498 0.842430 0.262877,\
246 | 214 0.575563 0.844566 0.256415,\
247 | 215 0.585678 0.846661 0.249897,\
248 | 216 0.595839 0.848717 0.243329,\
249 | 217 0.606045 0.850733 0.236712,\
250 | 218 0.616293 0.852709 0.230052,\
251 | 219 0.626579 0.854645 0.223353,\
252 | 220 0.636902 0.856542 0.216620,\
253 | 221 0.647257 0.858400 0.209861,\
254 | 222 0.657642 0.860219 0.203082,\
255 | 223 0.668054 0.861999 0.196293,\
256 | 224 0.678489 0.863742 0.189503,\
257 | 225 0.688944 0.865448 0.182725,\
258 | 226 0.699415 0.867117 0.175971,\
259 | 227 0.709898 0.868751 0.169257,\
260 | 228 0.720391 0.870350 0.162603,\
261 | 229 0.730889 0.871916 0.156029,\
262 | 230 0.741388 0.873449 0.149561,\
263 | 231 0.751884 0.874951 0.143228,\
264 | 232 0.762373 0.876424 0.137064,\
265 | 233 0.772852 0.877868 0.131109,\
266 | 234 0.783315 0.879285 0.125405,\
267 | 235 0.793760 0.880678 0.120005,\
268 | 236 0.804182 0.882046 0.114965,\
269 | 237 0.814576 0.883393 0.110347,\
270 | 238 0.824940 0.884720 0.106217,\
271 | 239 0.835270 0.886029 0.102646,\
272 | 240 0.845561 0.887322 0.099702,\
273 | 241 0.855810 0.888601 0.097452,\
274 | 242 0.866013 0.889868 0.095953,\
275 | 243 0.876168 0.891125 0.095250,\
276 | 244 0.886271 0.892374 0.095374,\
277 | 245 0.896320 0.893616 0.096335,\
278 | 246 0.906311 0.894855 0.098125,\
279 | 247 0.916242 0.896091 0.100717,\
280 | 248 0.926106 0.897330 0.104071,\
281 | 249 0.935904 0.898570 0.108131,\
282 | 250 0.945636 0.899815 0.112838,\
283 | 251 0.955300 0.901065 0.118128,\
284 | 252 0.964894 0.902323 0.123941,\
285 | 253 0.974417 0.903590 0.130215,\
286 | 254 0.983868 0.904867 0.136897,\
287 | 255 0.993248 0.906157 0.143936)
288 |
--------------------------------------------------------------------------------
/shard.yml:
--------------------------------------------------------------------------------
1 | name: ishi
2 | version: 0.7.5
3 |
4 | description: |
5 | Graph plotting package with a small API and sensible defaults powered by gnuplot.
6 |
7 | authors:
8 | - Todd Sundsted
9 |
10 | development_dependencies:
11 | spectator:
12 | gitlab: arctic-fox/spectator
13 | iterm2:
14 | github: toddsundsted/iterm2
15 |
16 | crystal: ">= 0.34.0, < 2.0.0"
17 |
18 | license: Apache License, Version 2.0
19 |
--------------------------------------------------------------------------------
/spec/ishi/chart_spec.cr:
--------------------------------------------------------------------------------
1 | require "../spec_helper"
2 |
3 | Spectator.describe Ishi::Gnuplot::Chart do
4 | subject { described_class.new }
5 |
6 | describe "#plot" do
7 | context "given a mathematical expression" do
8 | it "adds a mathematical expression plot to the chart" do
9 | subject.plot(Ishi::Gnuplot::PlotExp.new("sin(x)"))
10 | expect(subject.size).to eq(1)
11 | end
12 | end
13 |
14 | context "given one array of data" do
15 | it "adds a 2D plot to the chart" do
16 | subject.plot(Ishi::Gnuplot::PlotY.new([1, 2, 3, 4]))
17 | expect(subject.size).to eq(1)
18 | expect(subject.dim).to eq(2)
19 | end
20 | end
21 |
22 | context "given two arrays of data" do
23 | it "adds a 2D plot to the chart" do
24 | subject.plot(Ishi::Gnuplot::PlotXY.new([1, 2, 3, 4], [0, 1, 2, 3]))
25 | expect(subject.size).to eq(1)
26 | expect(subject.dim).to eq(2)
27 | end
28 | end
29 |
30 | context "given three arrays of data" do
31 | it "adds a 3D plot to the chart" do
32 | subject.plot(Ishi::Gnuplot::PlotXYZ.new([1, 2, 3, 4], [0, 1, 2, 3], [0, 0, 1, 1]))
33 | expect(subject.size).to eq(1)
34 | expect(subject.dim).to eq(3)
35 | end
36 | end
37 |
38 | context "given two plots" do
39 | it "adds two plots to the chart" do
40 | subject.plot(Ishi::Gnuplot::PlotY.new([1, 2, 3, 4])).plot(Ishi::Gnuplot::PlotExp.new("cos(x)"))
41 | expect(subject.size).to eq(2)
42 | end
43 | end
44 | end
45 |
46 | describe "#clear" do
47 | it "clears the chart" do
48 | subject.plot(Ishi::Gnuplot::PlotExp.new("2 * x + 1")).clear
49 | expect(subject.size).to eq(0)
50 | end
51 | end
52 | end
53 |
--------------------------------------------------------------------------------
/spec/ishi/gnuplot_spec.cr:
--------------------------------------------------------------------------------
1 | require "../spec_helper"
2 |
3 | Spectator.describe Ishi::Gnuplot do
4 | subject { described_class.new(Ishi::SpecHelper.new, ["set term dumb"]) }
5 | let(:chart) { Ishi::Gnuplot::Chart.new }
6 |
7 | describe "#plot" do
8 | EXAMPLES = [
9 | { {title: "foobar"}, /title 'foobar'/ }, # sets title
10 | { {style: :lines}, /with lines/ }, # sets style
11 | { {dashtype: [2, 2]}, /dt \(2,2\)/ }, # sets dashtype
12 | { {dashtype: "-- "}, /dt "-- "/ }, # sets dashtype
13 | { {linecolor: "red"}, /lc rgb "red"/ }, # sets linecolor
14 | { {linewidth: 2.3}, /lw 2.3/ }, # sets linewidth
15 | { {linestyle: 1}, /ls 1/ }, # sets linestyle
16 | { {pointsize: 1.3}, /ps 1.3/ }, # sets pointsize
17 | { {pointtype: 1}, /pt 1/ }, # sets pointtype
18 | { {pointtype: "+"}, /pt 1/ }, # sets pointtype
19 | { {style: :points, dashtype: ".. "}, /with linespoints/ }, # infers linespoints
20 | { {style: :points, linewidth: 1.3}, /with linespoints/ }, # infers linespoints
21 | { {style: :lines, pointsize: 1.3}, /with linespoints/ }, # infers linespoints
22 | { {style: :lines, pointtype: 1}, /with linespoints/ }, # infers linespoints
23 | { {pointsize: 1.3}, /with linespoints/ }, # infers linespoints
24 | { {pointtype: 1}, /with linespoints/ }, # infers linespoints
25 | { {format: "red"}, /lc rgb "red"/ }, # sets linecolor
26 | { {format: "#ff0000"}, /lc rgb "#ff0000"/ }, # sets linecolor
27 | { {format: "r"}, /lc rgb "red"/ }, # sets linecolor
28 | { {format: "+"}, /pt 1/ }, # sets pointtype
29 | { {format: ":"}, /dt 3/ }, # sets dashtype
30 | { {dt: 1}, /dt 1/ }, # sets dashtype
31 | { {lc: "#80ff00ee"}, /lc rgb "#80ff00ee"/ }, # sets linecolor
32 | { {lw: 3}, /lw 3/ }, # sets linewidth
33 | { {ls: 1}, /ls 1/ }, # sets linestyle
34 | { {ps: 2}, /ps 2/ }, # sets pointsize
35 | { {pt: 2}, /pt 2/ }, # sets pointtype
36 | { {fs: 2}, /fs pattern 2/ }, # sets fillstyle
37 | { {fs: 0.1}, /fs solid 0.1/ } # sets fillstyle
38 | ]
39 |
40 | context "given a mathematical expression" do
41 | it "invokes 'plot'" do
42 | commands = subject.show(chart.plot(Ishi::Gnuplot::PlotExp.new("sin(x)")))
43 | expect(commands).to have(/^plot sin\(x\)/)
44 | end
45 |
46 | {% for example in EXAMPLES %}
47 | it "generates commands" do
48 | commands = subject.show(chart.plot(Ishi::Gnuplot::PlotExp.new("sin(x)", **{{example[0]}})))
49 | expect(commands).to have({{example[1]}})
50 | end
51 | {% end %}
52 | end
53 |
54 | context "given one array of data" do
55 | it "invokes 'plot'" do
56 | output = subject.show(chart.plot(Ishi::Gnuplot::PlotY.new([1, 2, 3, 4])))
57 | expect(output).to have(/^plot '-'/)
58 | end
59 |
60 | {% for example in EXAMPLES %}
61 | it "generates commands" do
62 | commands = subject.show(chart.plot(Ishi::Gnuplot::PlotY.new([1, 2], **{{example[0]}})))
63 | expect(commands).to have({{example[1]}})
64 | end
65 | {% end %}
66 | end
67 |
68 | context "given two arrays of data" do
69 | it "invokes 'plot'" do
70 | output = subject.show(chart.plot(Ishi::Gnuplot::PlotXY.new([1, 2, 3, 4], [0, 1, 2, 3])))
71 | expect(output).to have(/^plot '-'/)
72 | end
73 |
74 | {% for example in EXAMPLES %}
75 | it "generates commands" do
76 | commands = subject.show(chart.plot(Ishi::Gnuplot::PlotXY.new([1, 2], [0, 1], **{{example[0]}})))
77 | expect(commands).to have({{example[1]}})
78 | end
79 | {% end %}
80 | end
81 |
82 | context "given three arrays of data" do
83 | it "invokes 'splot'" do
84 | output = subject.show(chart.plot(Ishi::Gnuplot::PlotXYZ.new([1, 2, 3, 4], [0, 1, 2, 3], [0, 0, 1, 1])))
85 | expect(output).to have(/^splot '-'/)
86 | end
87 |
88 | {% for example in EXAMPLES %}
89 | it "generates commands" do
90 | commands = subject.show(chart.plot(Ishi::Gnuplot::PlotXYZ.new([1, 2], [0, 1], [0, 0], **{{example[0]}})))
91 | expect(commands).to have({{example[1]}})
92 | end
93 | {% end %}
94 | end
95 |
96 | context "given an array of values" do
97 | it "invokes 'splot...matrix'" do
98 | output = subject.show(chart.plot(Ishi::Gnuplot::Plot2D.new([[1, 2], [3, 4]])))
99 | expect(output).to have(/^splot '-' matrix/)
100 | end
101 |
102 | {% for example in EXAMPLES %}
103 | it "generates commands" do
104 | commands = subject.show(chart.plot(Ishi::Gnuplot::Plot2D.new([[1, 2], [3, 4]], **{{example[0]}})))
105 | expect(commands).to have({{example[1]}})
106 | end
107 | {% end %}
108 | end
109 | end
110 |
111 | describe "#xlabel" do
112 | it "adds a label to the x axis" do
113 | output = subject.show(chart.xlabel("foobar"))
114 | expect(output).to have("set xlabel 'foobar'")
115 | end
116 | end
117 |
118 | describe "#ylabel" do
119 | it "adds a label to the y axis" do
120 | output = subject.show(chart.ylabel("foobar"))
121 | expect(output).to have("set ylabel 'foobar'")
122 | end
123 | end
124 |
125 | describe "#zlabel" do
126 | it "adds a label to the z axis" do
127 | output = subject.show(chart.zlabel("foobar"))
128 | expect(output).to have("set zlabel 'foobar'")
129 | end
130 | end
131 |
132 | describe "#xrange" do
133 | it "sets the range of the x axis" do
134 | output = subject.show(chart.xrange(-1..1))
135 | expect(output).to have("set xrange[-1:1]")
136 | end
137 | end
138 |
139 | describe "#yrange" do
140 | it "sets the range of the y axis" do
141 | output = subject.show(chart.yrange(-1..1))
142 | expect(output).to have("set yrange[-1:1]")
143 | end
144 | end
145 |
146 | describe "#zrange" do
147 | it "sets the range of the z axis" do
148 | output = subject.show(chart.zrange(-1..1))
149 | expect(output).to have("set zrange[-1:1]")
150 | end
151 | end
152 |
153 | describe "#boxwidth" do
154 | it "sets the default width of boxes" do
155 | output = subject.show(chart.boxwidth(1.55))
156 | expect(output).to have("set boxwidth 1.55")
157 | end
158 | end
159 |
160 | describe "#xtics" do
161 | it "sets non-numeric tic labels on the x-axis" do
162 | output = subject.show(chart.xtics({1.0 => "A", 3.0 => "C"}))
163 | expect(output).to have("set xtics (\"A\" 1.0, \"C\" 3.0)")
164 | end
165 | end
166 |
167 | describe "#view" do
168 | it "sets the viewing angle for 3D charts" do
169 | output = subject.show(chart.view(60, 30))
170 | expect(output).to have("set view 60,30")
171 | end
172 | end
173 |
174 | describe "#margin" do
175 | it "sets the margin" do
176 | output = subject.show(chart.margin(left: 6, right: 6, top: true, bottom: false))
177 | expect(output).to have("set lmargin 6", "set rmargin 6", "set tmargin -1")
178 | end
179 | end
180 |
181 | describe "#palette" do
182 | it "sets the palette" do
183 | output = subject.show(chart.palette(:gray))
184 | expect(output).to have("set palette gray")
185 | end
186 |
187 | it "hides the colorbox" do
188 | output = subject.show(chart.palette(:gray, colorbox: false))
189 | expect(output).to have("unset colorbox")
190 | end
191 | end
192 |
193 | describe "#show_colorbox" do
194 | it "shows the colorbox" do
195 | output = subject.show(chart.show_colorbox(true))
196 | expect(output).to have("set colorbox")
197 | end
198 |
199 | it "hides the colorbox" do
200 | output = subject.show(chart.show_colorbox(false))
201 | expect(output).to have("unset colorbox")
202 | end
203 | end
204 |
205 | describe "#show_border" do
206 | it "shows the border" do
207 | output = subject.show(chart.show_border(true))
208 | expect(output).to have("set border 31")
209 | end
210 |
211 | it "hides the border" do
212 | output = subject.show(chart.show_border(false))
213 | expect(output).to have("unset border")
214 | end
215 | end
216 |
217 | describe "#show_xtics" do
218 | it "shows the xtics" do
219 | output = subject.show(chart.show_xtics(true))
220 | expect(output).to have("set xtics")
221 | end
222 |
223 | it "hides the xtics" do
224 | output = subject.show(chart.show_xtics(false))
225 | expect(output).to have("unset xtics")
226 | end
227 | end
228 |
229 | describe "#show_ytics" do
230 | it "shows the ytics" do
231 | output = subject.show(chart.show_ytics(true))
232 | expect(output).to have("set ytics")
233 | end
234 |
235 | it "hides the ytics" do
236 | output = subject.show(chart.show_ytics(false))
237 | expect(output).to have("unset ytics")
238 | end
239 | end
240 |
241 | describe "#show_key" do
242 | it "shows the key" do
243 | output = subject.show(chart.show_key(true))
244 | expect(output).to have("set key")
245 | end
246 |
247 | it "hides the key" do
248 | output = subject.show(chart.show_key(false))
249 | expect(output).to have("unset key")
250 | end
251 | end
252 |
253 | describe "#show" do
254 | it "displays the chart" do
255 | output = subject.show(chart.plot(Ishi::Gnuplot::PlotExp.new("2 * x + 1")))
256 | expect(output).to have("plot 2 * x + 1")
257 | end
258 |
259 | it "displays the charts" do
260 | chart1 = Ishi::Gnuplot::Chart.new.plot(Ishi::Gnuplot::PlotExp.new("sin(x)"))
261 | chart2 = Ishi::Gnuplot::Chart.new.plot(Ishi::Gnuplot::PlotExp.new("cos(x)"))
262 | output = subject.show([chart1, chart2], 2, 1)
263 | expect(output).to have("plot sin(x)", "plot cos(x)")
264 | end
265 |
266 | it "clears the chart" do
267 | subject.show(chart.plot(Ishi::Gnuplot::PlotExp.new("x")))
268 | expect(chart.size).to eq(0)
269 | end
270 | end
271 | end
272 |
--------------------------------------------------------------------------------
/spec/ishi/term_spec.cr:
--------------------------------------------------------------------------------
1 | require "../spec_helper"
2 | require "../../src/ishi/term"
3 |
4 | # Subclass `Ishi::Term` to discard `abstract`.
5 |
6 | class FooBar < Ishi::Term
7 | def initialize(io : IO = STDOUT)
8 | super("foo bar", io)
9 | end
10 |
11 | def show(**options)
12 | super(**options).tap do |lines|
13 | lines.each do |line|
14 | io.puts line
15 | end
16 | end
17 | end
18 | end
19 |
20 | Spectator.describe Ishi::Term do
21 | let(io) { IO::Memory.new }
22 | subject { FooBar.new(io) }
23 |
24 | describe "#show" do
25 | it "sets up the terminal" do
26 | subject.show
27 | expect(io.to_s).to match(/set term foo bar/)
28 | end
29 |
30 | it "sets the size of the terminal canvas" do
31 | subject.canvas_size(20, 20)
32 | subject.show
33 | expect(io.to_s).to match(/set term foo bar size 20,20/)
34 | end
35 |
36 | it "engages multiplot mode" do
37 | subject.charts(2, 2)
38 | subject.show
39 | expect(io.to_s).to match(/set multiplot layout 2,2/)
40 | end
41 | end
42 | end
43 |
--------------------------------------------------------------------------------
/spec/ishi_spec.cr:
--------------------------------------------------------------------------------
1 | require "./spec_helper"
2 |
3 | Spectator.describe Ishi do
4 | describe "::VERSION" do
5 | it "should return the version" do
6 | version = YAML.parse(File.read(File.join(__DIR__, "..", "shard.yml")))["version"].as_s
7 | expect(Ishi::VERSION).to eq(version)
8 | end
9 | end
10 |
11 | describe ".new" do
12 | it "creates a new instance" do
13 | described_class.new
14 | end
15 |
16 | it "takes a block and yields a new instance" do
17 | described_class.new do
18 | end
19 | end
20 | end
21 |
22 | describe "#charts" do
23 | subject { described_class.new }
24 |
25 | it "creates multiple subcharts" do
26 | expect(subject.charts(2, 1).size).to eq(2)
27 | end
28 |
29 | it "engages multiplot mode" do
30 | subject.charts(2, 1)
31 | expect(subject.show).to have("set multiplot layout 2,1", "unset multiplot")
32 | end
33 |
34 | it "extends subcharts" do
35 | plots = ["sin(x)", "cos(x)"]
36 | subject.charts(2, 1) do
37 | plot(plots.shift)
38 | end
39 | subject.charts(3, 1)
40 | expect(subject.show).to have("plot sin(x)", "plot cos(x)")
41 | expect(subject.size).to eq(3)
42 | end
43 |
44 | it "truncates subcharts" do
45 | plots = ["sin(x)", "cos(x)", "tan(x)"]
46 | subject.charts(3, 1) do
47 | plot(plots.shift)
48 | end
49 | subject.charts(2, 1)
50 | expect(subject.show).to have("plot sin(x)", "plot cos(x)")
51 | expect(subject.size).to eq(2)
52 | end
53 |
54 | it "forbids invoking #charts on a subchart" do
55 | chart = subject.charts(1, 1).first
56 | expect{chart.charts(1, 1)}.to raise_error(NotImplementedError)
57 | end
58 |
59 | it "forbids invoking #show on a subchart" do
60 | chart = subject.charts(1, 1).first
61 | expect{chart.show}.to raise_error(NotImplementedError)
62 | end
63 | end
64 |
65 | describe "#plot" do
66 | subject { described_class.new }
67 |
68 | it "plots y values" do
69 | expect(subject.plot([1, 2, 3]).show).to have(/^plot .* with lines$/, "0 1", "1 2", "2 3")
70 | end
71 |
72 | it "plots x and y values" do
73 | expect(subject.plot([1, 2, 3], [1, 2, 3]).show).to have(/^plot .* with points$/, "1 1", "2 2", "3 3")
74 | end
75 |
76 | it "plots x, y and z values" do
77 | expect(subject.plot([0, 1, 2], [1, 2, 3], [0, 1, 0]).show).to have(/^splot .* with points$/, "0 1 0", "1 2 1", "2 3 0")
78 | end
79 |
80 | it "accepts arrays of numbers of different types" do
81 | subject.plot([1, 2, 3], [3, 2, 1], [1.0, 2.0, 3.0]).show
82 | subject.plot([1, 2, 3], [1.0, 2.0, 3.0]).show
83 | end
84 | end
85 |
86 | describe "#scatter" do
87 | subject { described_class.new }
88 |
89 | it "scatter plots x and y values" do
90 | expect(subject.scatter([1, 2, 3], [1, 2, 3]).show).to have(/^plot .* with dots$/, "1 1", "2 2", "3 3")
91 | end
92 |
93 | it "scatter plots x, y and z values" do
94 | expect(subject.scatter([0, 1, 2], [1, 2, 3], [0, 1, 0]).show).to have(/^splot .* with dots$/, "0 1 0", "1 2 1", "2 3 0")
95 | end
96 | end
97 |
98 | describe "#imshow" do
99 | subject { described_class.new }
100 |
101 | it "displays an image" do
102 | expect(subject.imshow([[1, 2], [3, 4]]).show).to have(/^plot .* matrix with image$/, "1 2", "3 4")
103 | end
104 | end
105 |
106 | describe "#canvas_size" do
107 | subject { described_class.new }
108 |
109 | it "sets the size of the chart canvas" do
110 | expect(subject.canvas_size(320, 200).show).to have(/size 320,200/)
111 | end
112 | end
113 | end
114 |
--------------------------------------------------------------------------------
/spec/spec_helper.cr:
--------------------------------------------------------------------------------
1 | require "../src/*"
2 | require "spectator"
3 | require "yaml"
4 |
5 | module Ishi
6 | class SpecHelper < Term
7 | def initialize(**ignored)
8 | super("dumb")
9 | end
10 | end
11 |
12 | class Gnuplot
13 | def run(commands : Enumerable(String))
14 | commands
15 | end
16 | end
17 |
18 | @@default = SpecHelper
19 | end
20 |
--------------------------------------------------------------------------------
/src/ishi.cr:
--------------------------------------------------------------------------------
1 | require "./ishi/gnuplot"
2 | require "./ishi/term"
3 |
4 | # Graph plotting package with a small API powered by gnuplot.
5 | #
6 | # See `Base` for documentation on supported methods.
7 | #
8 | module Ishi
9 | # :nodoc:
10 | VERSION = {{ `shards version "#{__DIR__}"`.chomp.stringify }}
11 |
12 | # :nodoc:
13 | class Qt < Term
14 | def initialize(**ignored)
15 | super("qt persist")
16 | end
17 | end
18 |
19 | # :nodoc:
20 | @@default = Qt
21 |
22 | # Creates a new instance. An `IO` for output may be specified.
23 | #
24 | # ```
25 | # ishi = Ishi.new
26 | # ishi.plot([1, 2, 3, 4])
27 | # ishi.show
28 | # ```
29 | #
30 | def self.new(io : IO = STDOUT)
31 | @@default.new(io: io)
32 | end
33 |
34 | # Creates a new instance.
35 | #
36 | # Yields to the supplied block with the new instance as the implicit
37 | # receiver. Automatically invokes `#show` before returning. An `IO`
38 | # for output may be specified. Any *options* are passed to `#show`.
39 | #
40 | # ```
41 | # Ishi.new do
42 | # plot([1, 2, 3, 4])
43 | # end
44 | # ```
45 | #
46 | def self.new(io : IO = STDOUT, **options)
47 | @@default.new(io: io).tap do |instance|
48 | with instance yield
49 | instance.show(**options)
50 | end
51 | end
52 | end
53 |
--------------------------------------------------------------------------------
/src/ishi/base.cr:
--------------------------------------------------------------------------------
1 | module Ishi
2 | # Supported methods.
3 | #
4 | abstract class Base
5 | # :nodoc:
6 | class Proxy < Base
7 | def initialize
8 | super
9 | end
10 |
11 | def initialize(chart : Ishi::Gnuplot::Chart)
12 | @charts = [chart]
13 | end
14 |
15 | def charts(rows : Int32, cols : Int32)
16 | raise NotImplementedError.new("not supported on proxies")
17 | end
18 |
19 | def show(**options)
20 | raise NotImplementedError.new("not supported on proxies")
21 | end
22 | end
23 |
24 | # :nodoc:
25 | def initialize
26 | @charts = [Ishi::Gnuplot::Chart.new]
27 | end
28 |
29 | # Changes the number of charts in the figure.
30 | #
31 | # By default a figure has one chart. This call changes the number
32 | # of charts in the figure. The original chart is preserved and
33 | # becomes the chart in the first row, first column of the new
34 | # layout.
35 | #
36 | # Returns the charts.
37 | #
38 | # figure = Ishi.new
39 | # charts = figure.charts(2, 2)
40 | # charts[0].plot([1, 2, 3, 4])
41 | # charts[1].plot([2, 3, 4, 1])
42 | # ...
43 | # figure.show
44 | #
45 | def charts(rows : Int32, cols : Int32)
46 | raise ArgumentError.new("rows must be greater than zero") if rows < 1
47 | raise ArgumentError.new("cols must be greater than zero") if cols < 1
48 | if (delta = rows * cols - @charts.size) > 0
49 | delta.times { @charts << Ishi::Gnuplot::Chart.new }
50 | elsif delta < 0
51 | @charts = @charts[0..delta - 1]
52 | end
53 | @rows = rows
54 | @cols = cols
55 | @charts.map do |chart|
56 | Proxy.new(chart)
57 | end
58 | end
59 |
60 | # Changes the number of charts in the figure.
61 | #
62 | # By default a figure has one chart. This call changes the number
63 | # of charts in the figure. The original chart is preserved and
64 | # becomes the chart in the first row, first column of the new
65 | # layout.
66 | #
67 | # Yields each chart as the default receiver of the supplied
68 | # block. Block arguments are *i* (the i-th chart in the figure),
69 | # *row* and *col* (the row and column of the chart).
70 | #
71 | # figure = Ishi.new
72 | # figure.charts(2, 2) do |i|
73 | # plot([1, 2, 3, 4].rotate(i))
74 | # ...
75 | # end
76 | # figure.show
77 | #
78 | def charts(rows : Int32, cols : Int32)
79 | temp = charts(rows, cols)
80 | i = 0
81 | rows.times do |r|
82 | cols.times do |c|
83 | with temp[i] yield i, r, c
84 | i += 1
85 | end
86 | end
87 | end
88 |
89 | # Returns the number of charts in the figure.
90 | #
91 | def size
92 | @charts.size
93 | end
94 |
95 | # Plots a mathematical expression.
96 | #
97 | # plot("sin(x) * cos(x)")
98 | # plot("3.5 * x + 1.5")
99 | #
100 | # For information on gnuplot mathematical expressions, see:
101 | # [Expressions](http://www.gnuplot.info/docs_5.2/Gnuplot_5.2.pdf#section*.27).
102 | #
103 | # *title* is the title of the plot. *style* is the drawing
104 | # style. Supported styles include `:lines` and `:points`.
105 | #
106 | def plot(expression : String, format : String? = nil, *, title : String? = nil, style : Symbol? = nil, **options)
107 | @charts.first.plot(Ishi::Gnuplot::PlotExp.new(expression, title, style, format, **options))
108 | self
109 | end
110 |
111 | # compatible extensions
112 | private SUPPORTED = [
113 | "MXNet::NDArray"
114 | ]
115 |
116 | # Plots `y` using `x` ranging from `0` to `N-1`.
117 | #
118 | # *title* is the title of the plot. *style* is the drawing
119 | # style. Supported styles include `:boxes`, `:lines`, `:points`,
120 | # `:linespoints` and `:dots`.
121 | #
122 | def plot(ydata : Indexable(Y), format : String? = nil, *, title : String? = nil, style : Symbol = :lines, **options) forall Y
123 | {% raise "type must be numeric" unless [Y].all? { |a| SUPPORTED.includes?(a.stringify) || a < Number } %}
124 | @charts.first.plot(Ishi::Gnuplot::PlotY.new(ydata, title, style, format, **options))
125 | self
126 | end
127 |
128 | # Plots `x` and `y`.
129 | #
130 | # *title* is the title of the plot. *style* is the drawing
131 | # style. Supported styles include `:boxes`, `:lines`, `:points`,
132 | # `:linespoints` and `:dots`.
133 | #
134 | def plot(xdata : Indexable(M), ydata : Indexable(N), format : String? = nil, *, title : String? = nil, style : Symbol = :points, **options) forall M, N
135 | {% raise "type must be numeric" unless [M, N].all? { |a| SUPPORTED.includes?(a.stringify) || a < Number } %}
136 | @charts.first.plot(Ishi::Gnuplot::PlotXY.new(xdata, ydata, title, style, format, **options))
137 | self
138 | end
139 |
140 | # Plots `x`, `y` and `z`.
141 | #
142 | # *title* is the title of the plot. *style* is the drawing
143 | # style. Supported styles include `:surface`, `:circles`,
144 | # `:lines`, `:points` and `:dots`.
145 | #
146 | def plot(xdata : Indexable(T), ydata : Indexable(U), zdata : Indexable(V), format : String? = nil, *, title : String? = nil, style : Symbol = :points, **options) forall T, U, V
147 | {% raise "type must be numeric" unless [T, U, V].all? { |a| SUPPORTED.includes?(a.stringify) || a < Number } %}
148 | @charts.first.plot(Ishi::Gnuplot::PlotXYZ.new(xdata, ydata, zdata, title, style, format, **options))
149 | self
150 | end
151 |
152 | # Scatter plots `x` and `y`.
153 | #
154 | # *title* is the title of the plot.
155 | #
156 | def scatter(xdata : Indexable(M), ydata : Indexable(N), format : String? = nil, *, title : String? = nil, style : Symbol = :dots, **options) forall M, N
157 | {% raise "type must be numeric" unless [M, N].all? { |a| SUPPORTED.includes?(a.stringify) || a < Number } %}
158 | @charts.first.plot(Ishi::Gnuplot::PlotXY.new(xdata, ydata, title, style, format, **options))
159 | self
160 | end
161 |
162 | # Scatter plots `x`, `y` and `z`.
163 | #
164 | # *title* is the title of the plot.
165 | #
166 | def scatter(xdata : Indexable(T), ydata : Indexable(U), zdata : Indexable(V), format : String? = nil, *, title : String? = nil, style : Symbol = :dots, **options) forall T, U, V
167 | {% raise "type must be numeric" unless [T, U, V].all? { |a| SUPPORTED.includes?(a.stringify) || a < Number } %}
168 | @charts.first.plot(Ishi::Gnuplot::PlotXYZ.new(xdata, ydata, zdata, title, style, format, **options))
169 | self
170 | end
171 |
172 | # Displays an image.
173 | #
174 | # *data* is scalar image data.
175 | #
176 | # Data is visualized using a colormap.
177 | #
178 | def imshow(data : Indexable(Indexable(D)), **options) forall D
179 | {% raise "type must be numeric" unless [D].all? { |a| SUPPORTED.includes?(a.stringify) || a < Number } %}
180 | @charts.first.plot(Ishi::Gnuplot::Plot2D.new(data, **options.merge({style: :image})))
181 | self
182 | end
183 |
184 | # Sets the label of the `x` axis.
185 | #
186 | def xlabel(xlabel : String)
187 | @charts.first.xlabel(xlabel)
188 | self
189 | end
190 |
191 | # Sets the label of the `y` axis.
192 | #
193 | def ylabel(ylabel : String)
194 | @charts.first.ylabel(ylabel)
195 | self
196 | end
197 |
198 | # Sets the label of the `z` axis.
199 | #
200 | def zlabel(zlabel : String)
201 | @charts.first.zlabel(zlabel)
202 | self
203 | end
204 |
205 | # Sets the range of the `x` axis.
206 | #
207 | def xrange(xrange : Range(Float64, Float64) | Range(Int32, Int32))
208 | @charts.first.xrange(xrange)
209 | self
210 | end
211 |
212 | # Sets the range of the `y` axis.
213 | #
214 | def yrange(yrange : Range(Float64, Float64) | Range(Int32, Int32))
215 | @charts.first.yrange(yrange)
216 | self
217 | end
218 |
219 | # Sets the range of the `z` axis.
220 | #
221 | def zrange(zrange : Range(Float64, Float64) | Range(Int32, Int32))
222 | @charts.first.zrange(zrange)
223 | self
224 | end
225 |
226 | # Sets the default width of boxes in the boxes, boxerrorbars, candlesticks
227 | # and histograms styles.
228 | #
229 | # For information on setting the box width, see:
230 | # [Boxwidth](http://www.gnuplot.info/docs_5.2/Gnuplot_5.2.pdf#section*.232).
231 | #
232 | def boxwidth(boxwidth : Float64)
233 | @charts.first.boxwidth(boxwidth)
234 | self
235 | end
236 |
237 | # Sets non-numeric labels on the x-axis.
238 | #
239 | # This translates to `set xtics ({"