forked from JuliaPlots/UnicodePlots.jl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenerate_docs.jl
578 lines (425 loc) · 23.8 KB
/
generate_docs.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
using UnicodePlots
using Markdown
import Markdown: MD, Paragraph, plain
main() = begin
docs_url = "https://github.com/JuliaPlots/UnicodePlots.jl/raw/unicodeplots-docs"
ver = "2.10"
exs = (
lineplot1 = ("Basic Canvas", """
using UnicodePlots
plt = lineplot([-1, 2, 3, 7], [-1, 2, 9, 4],
title="Example Plot", name="my line", xlabel="x", ylabel="y")
"""),
lineplot2 = ("Basic Canvas", """
lineplot([-1, 2, 3, 7], [-1, 2, 9, 4],
title="Example Plot", name="my line",
xlabel="x", ylabel="y", canvas=DotCanvas, border=:ascii)
"""),
lineplot3 = ("Basic Canvas", "lineplot!(plt, [0, 4, 8], [10, 1, 10], color=:blue, name=\"other line\")"),
scatterplot1 = ("Scatterplot", "scatterplot(randn(50), randn(50), title=\"My Scatterplot\")"),
scatterplot2 = ("Scatterplot", "scatterplot(1:10, 1:10, xscale=:log10, yscale=:ln)"),
scatterplot3 = ("Scatterplot", "scatterplot(1:10, 1:10, xscale=:log10, yscale=:ln, unicode_exponent=false)"),
scatterplot4 = ("Scatterplot", """
scatterplot([1, 2, 3], [3, 4, 1],
marker=[:circle, '', "∫"], color=[:red, nothing, :yellow])
"""),
lineplot4 = ("Lineplot", "lineplot([1, 2, 7], [9, -6, 8], title=\"My Lineplot\")"),
lineplot5 = ("Lineplot", "plt = lineplot([cos, sin], -π/2, 2π)"),
lineplot6 = ("Lineplot", "lineplot!(plt, -.5, .2, name=\"line\")"),
lineplot7 = ("Lineplot", """
using Unitful
a = 1u"m/s^2"
t = (0:100) * u"s"
lineplot(a / 2 * t .^ 2, a * t, xlabel = "position", ylabel = "speed")
"""),
stairs1 = ("Staircase", """
# supported style are :pre and :post
stairs([1, 2, 4, 7, 8], [1, 3, 4, 2, 7],
color=:red, style=:post, title="My Staircase Plot")
"""),
barplot1 = ("Barplot", """
barplot(["Paris", "New York", "Moskau", "Madrid"],
[2.244, 8.406, 11.92, 3.165],
title="Population")
"""),
histogram1 = ("Histogram", "histogram(randn(1_000) .* .1, nbins=15, closed=:left)"),
histogram2 = ("Histogram", "histogram(randn(1_000) .* .1, nbins=15, closed=:right, xscale=:log10)"),
histogram3 = ("Histogram", "histogram(randn(1_000_000) .* .1, nbins=100, vertical=true)"),
boxplot1 = ("Boxplot", "boxplot([1, 3, 3, 4, 6, 10])"),
boxplot2 = ("Boxplot", """
boxplot(["one", "two"],
[[1, 2, 3, 4, 5], [2, 3, 4, 5, 6, 7, 8, 9]],
title="Grouped Boxplot", xlabel="x")
"""),
spy1 = ("Spy", "using SparseArrays\nspy(sprandn(50, 120, .05))"),
spy2 = ("Spy", "using SparseArrays\nspy(sprandn(50, 120, .9), show_zeros=true)"),
densityplot1 = ("Densityplot", """
plt = densityplot(randn(1_000), randn(1_000))
densityplot!(plt, randn(1_000) .+ 2, randn(1_000) .+ 2)
"""),
contourplot1 = ("Contourplot", "contourplot(-3:.01:3, -7:.01:3, (x, y) -> exp(-(x / 2)^2 - ((y + 2) / 4)^2))"),
polarplot1 = ("Polarplot", "polarplot(range(0, 2π, length = 20), range(0, 2, length = 20))"),
heatmap1 = ("Heatmap", "heatmap(repeat(collect(0:10)', outer=(11, 1)), zlabel=\"z\")"),
heatmap2 = ("Heatmap", "heatmap(collect(0:30) * collect(0:30)', xfact=.1, yfact=.1, xoffset=-1.5, colormap=:inferno)"),
surfaceplot1 = ("Surfaceplot", """
sombrero(x, y) = 15sinc(√(x^2 + y^2) / π)
surfaceplot(-8:.5:8, -8:.5:8, sombrero, colormap=:jet)
"""),
surfaceplot2 = ("Surfaceplot", """
surfaceplot(
-2:2, -2:2, (x, y) -> 15sinc(√(x^2 + y^2) / π),
zscale=z -> 0, lines=true, colormap=:jet
)
"""),
isosurface = ("Isosurface", """
torus(x, y, z, r=0.2, R=0.5) = (√(x^2 + y^2) - R)^2 + z^2 - r^2
isosurface(-1:.1:1, -1:.1:1, -1:.1:1, torus, cull=true, zoom=2, elevation=50)
"""),
width = ("Width", "lineplot(sin, 1:.5:20, width=60)"),
height = ("Height", "lineplot(sin, 1:.5:20, height=18)"),
labels = ("Labels", "lineplot(sin, 1:.5:20, labels=false)"),
border_dashed = ("Border", "lineplot([-1., 2, 3, 7], [1.,2, 9, 4], canvas=DotCanvas, border=:dashed)"),
border_ascii = ("Border", "lineplot([-1., 2, 3, 7], [1.,2, 9, 4], canvas=DotCanvas, border=:ascii)"),
border_bold = ("Border", "lineplot([-1., 2, 3, 7], [1.,2, 9, 4], canvas=DotCanvas, border=:bold)"),
border_dotted = ("Border", "lineplot([-1., 2, 3, 7], [1.,2, 9, 4], border=:dotted)"),
border_none = ("Border", "lineplot([-1., 2, 3, 7], [1.,2, 9, 4], border=:none)"),
decorate = ("Decorate", """
x = y = collect(1:10)
plt = lineplot(x, y, canvas=DotCanvas, width=30, height=10)
lineplot!(plt, x, reverse(y))
title!(plt, "Plot Title")
for loc in (:tl, :t, :tr, :bl, :b, :br)
label!(plt, loc, string(':', loc))
end
label!(plt, :l, ":l")
label!(plt, :r, ":r")
for i in 1:10
label!(plt, :l, i, string(i))
label!(plt, :r, i, string(i))
end
plt
"""),
canvas = ("Canvas", """
canvas = BrailleCanvas(40, 15, # number of columns and rows (characters)
origin_x=0., origin_y=0., # position in virtual space
width=1., height=1.) # size of the virtual space
lines!(canvas, 0., 0., 1., 1., :blue) # virtual space
points!(canvas, rand(50), rand(50), :red) # virtual space
lines!(canvas, 0., 1., .5, 0., :yellow) # virtual space
pixel!(canvas, 5, 8, :red) # pixel space
Plot(canvas)
"""),
blending = ("Blending", """
canvas = BrailleCanvas(40, 15, origin_x=0., origin_y=0., width=1., height=1.)
lines!(canvas, 0., 0., 1., 1., :blue)
lines!(canvas, .25, 1., .5, 0., :yellow)
lines!(canvas, .2, .8, 1., 0., :red)
Plot(canvas)
"""),
)
plain_md_par(x) = x |> Paragraph |> MD |> plain
examples = NamedTuple{keys(exs)}(
(plain_md_par("```julia\n$(rstrip(e[2]))\n```\n![$(e[1])]($docs_url/$ver/$k.png)") for (k, e) in pairs(exs))
)
tab = ' '^2
indent(x, n) = repeat(tab, n) * join(split(x, '\n'), '\n' * repeat(tab, n))
desc_ex(k, d, n=2) = (
if k == :border
join((
d,
indent(examples.border_dashed, n),
indent(examples.border_ascii, n),
indent(examples.border_bold, n),
indent(examples.border_dotted, n),
indent(examples.border_none, n),
), '\n')
elseif k in (:width, :height, :labels)
join((d, indent(getindex(examples, k), n)), '\n')
else
d
end
)
anchor(name) = replace(lowercase(name), ' ' => '-')
summary(name) = "<summary><a name=$(anchor(name))></a><b>$(name)</b></summary>" # named anchor + formatting
methods = plain_md_par("""
- `title!(plot::Plot, title::String)`
- `title` the string to write in the top center of the plot window. If the title is empty the whole line of the title will not be drawn
- `xlabel!(plot::Plot, xlabel::String)`
- `xlabel` the string to display on the bottom of the plot window. If the title is empty the whole line of the label will not be drawn
- `ylabel!(plot::Plot, xlabel::String)`
- `ylabel` the string to display on the far left of the plot window.
The method `label!` is responsible for the setting all the textual decorations of a plot. It has two functions:
- `label!(plot::Plot, where::Symbol, value::String)`
- `where` can be any of: `:tl` (top-left), `:t` (top-center), `:tr` (top-right), `:bl` (bottom-left), `:b` (bottom-center), `:br` (bottom-right), `:l` (left), `:r` (right)
- `label!(plot::Plot, where::Symbol, row::Int, value::String)`
- `where` can be any of: `:l` (left), `:r` (right)
- `row` can be between 1 and the number of character rows of the canvas
$(plain_md_par(indent(examples.decorate, 2)))
- `annotate!(plot::Plot, x::Number, y::Number, text::AbstractString; kw...)`
- `text` arbitrary annotation at position (x, y)
""")
low_level_interface = plain_md_par("""
The primary structures that do all the heavy lifting behind the curtain are subtypes of `Canvas`. A canvas is a graphics object for rasterized plotting. Basically, it uses Unicode characters to represent pixel.
Here is a simple example:
$(examples.canvas)
You can access the height and width of the canvas (in characters) with `nrows(canvas)` and `ncols(canvas)` respectively. You can use those functions in combination with `printrow` to embed the canvas anywhere you wish. For example, `printrow(STDOUT, canvas, 3)` writes the third character row of the canvas to the standard output.
As you can see, one issue that arises when multiple pixel are represented by one character is that it is hard to assign color. That is because each of the "pixel" of a character could belong to a different color group (each character can only have a single color). This package deals with this using a color-blend for the whole group. You can disable canvas color blending / mixing by passing `blend=false` to any function.
$(examples.blending)
The following types of `Canvas` are implemented:
- **BrailleCanvas**:
This type of canvas is probably the one with the highest resolution for `Unicode` plotting. It essentially uses the Unicode characters of the [Braille](https://en.wikipedia.org/wiki/Braille) symbols as pixels. This effectively turns every character into eight pixels that can individually be manipulated using binary operations.
- **BlockCanvas**:
This canvas is also `Unicode` based. It has half the resolution of the BrailleCanvas. In contrast to `BrailleCanvas`, the pixels don't have visible spacing between them. This canvas effectively turns every character into four pixels that can individually be manipulated using binary operations.
- **HeatmapCanvas**:
This canvas is also `Unicode` based. It has half the resolution of the `BlockCanvas`. This canvas effectively turns every character into two color pixels, using the foreground and background terminal colors. As such, the number of rows of the canvas is half the number of `y` coordinates being displayed.
- **AsciiCanvas** and **DotCanvas**:
These two canvas utilizes only standard `ASCII` character for drawing. Naturally, it doesn't look quite as nice as the Unicode-based ones. However, in some situations it might yield better results. Printing plots to a file is one of those situations.
- **DensityCanvas**:
Unlike the `BrailleCanvas`, the density canvas does not simply mark a "pixel" as set. Instead it increments a counter per character that keeps track of the frequency of pixels drawn in that character. Together with a variable that keeps track of the maximum frequency, the canvas can thus draw the density of datapoints.
- **BarplotGraphics**:
This graphics area is special in that it does not support any pixel manipulation. It is essentially the barplot without decorations but the numbers. It does only support one method `addrow!` which allows the user to add additional bars to the graphics object.
""")
kw_description = plain_md_par("""
All plots support the set (or a subset) of the following named parameters:
$(join(
(
"$tab- `$(UnicodePlots.default_with_type(k))`: $(desc_ex(k, d * '.'))"
for (k, d) in pairs(UnicodePlots.DESCRIPTION) if k in keys(UnicodePlots.KEYWORDS)
), '\n'
))
_Note_: If you want to print the plot into a file but have monospace issues with your font, you should probably try setting `border=:ascii` and `canvas=AsciiCanvas` (or `canvas=DotCanvas` for scatterplots).
""")
installation = plain_md_par("""
To install UnicodePlots, start up `Julia` and type the following code snippet into the `REPL` (makes use of the native `Julia` package manager `Pkg`):
```julia
julia> using Pkg
julia> Pkg.add("UnicodePlots")
```
""")
doc_update = plain_md_par("""
The following snippet:
```bash
\$ cd docs
\$ julia generate_docs.jl
\$ (cd imgs; julia gen_imgs.jl)
```
will regenerate `README.md` and the example images with root (prefix) url $(docs_url).
""")
readme = plain(md"""
# UnicodePlots
[](LICENSE.md)
[](https://juliaci.github.io/NanosoldierReports/pkgeval_badges/U/UnicodePlots.html)
[](https://github.com/JuliaPlots/UnicodePlots.jl/actions/workflows/ci.yml)
[](https://app.codecov.io/gh/JuliaPlots/UnicodePlots.jl)
[](https://juliahub.com/ui/Packages/UnicodePlots/Ctj9q?t=2)
[](https://pkgs.genieframework.com?packages=UnicodePlots)
Advanced [`Unicode`](https://en.wikipedia.org/wiki/Unicode) plotting library designed for use in `Julia`'s `REPL`.
`UnicodePlots` is integrated in [`Plots`](https://github.com/JuliaPlots/Plots.jl) as a backend, with support for [layouts](https://docs.juliaplots.org/latest/gallery/unicodeplots/generated/unicodeplots-ref17/#unicodeplots_demo_17).
Physical quantities of [`Unitful.jl`](https://github.com/PainterQubits/Unitful.jl) are supported on a subset of plotting methods.
## High-level Interface
There are a couple of ways to generate typical plots without much verbosity.
Here is a list of the main high-level functions for common scenarios:
- [`scatterplot`](https://github.com/JuliaPlots/UnicodePlots.jl#scatterplot) (Scatter Plot)
- [`lineplot`](https://github.com/JuliaPlots/UnicodePlots.jl#lineplot) (Line Plot)
- [`stairs`](https://github.com/JuliaPlots/UnicodePlots.jl#staircase-plot) (Staircase Plot)
- [`barplot`](https://github.com/JuliaPlots/UnicodePlots.jl#barplot) (Bar Plot - horizontal)
- [`histogram`](https://github.com/JuliaPlots/UnicodePlots.jl#histogram) (Histogram - horizontal / vertical)
- [`boxplot`](https://github.com/JuliaPlots/UnicodePlots.jl#boxplot) (Box Plot - horizontal)
- [`spy`](https://github.com/JuliaPlots/UnicodePlots.jl#sparsity-pattern) (Sparsity Pattern)
- [`densityplot`](https://github.com/JuliaPlots/UnicodePlots.jl#density-plot) (Density Plot)
- [`contourplot`](https://github.com/JuliaPlots/UnicodePlots.jl#contour-plot) (Contour Plot)
- [`polarplot`](https://github.com/JuliaPlots/UnicodePlots.jl#polar-plot) (Polar Plot)
- [`heatmap`](https://github.com/JuliaPlots/UnicodePlots.jl#heatmap-plot) (Heatmap Plot)
- [`surfaceplot`](https://github.com/JuliaPlots/UnicodePlots.jl#surface-plot) (Surface Plot - 3D)
- [`isosurface`](https://github.com/JuliaPlots/UnicodePlots.jl#isosurface-plot) (Isosurface Plot - 3D)
<details open>
$(summary("Introduction"))
Here is a quick hello world example of a typical use-case:
$(examples.lineplot1)
There are other types of `Canvas` available (see section [Low-level Interface](https://github.com/JuliaPlots/UnicodePlots.jl#low-level-interface)).
In some situations, such as printing to a file, using `AsciiCanvas`, `DotCanvas` or `BlockCanvas` might lead to better results:
$(examples.lineplot2)
Some plot methods have a mutating variant that ends with a exclamation mark:
$(examples.lineplot3)
</details>
<details open>
$(summary("Scatterplot"))
$(examples.scatterplot1)
Axis scaling (`xscale` and/or `yscale`) is supported: choose from (`:identity`, `:ln`, `:log2`, `:log10`) or use an arbitrary scale function:
$(examples.scatterplot2)
For the axis scale exponent, one can revert to using `ASCII` characters instead of `Unicode` ones using the keyword `unicode_exponent=false`:
$(examples.scatterplot3)
Using a `marker` is supported, choose a `Char`, a unit length `String` or a symbol name such as `:circle` (more from `keys(UnicodePlots.MARKERS)`).
One can also provide a vector of `marker`s and/or `color`s as in the following example:
$(examples.scatterplot4)
As with `lineplot`, `scatterplot` supports plotting physical `Unitful` quantities.
</details>
<details open>
$(summary("Lineplot"))
$(examples.lineplot4)
It's also possible to specify a function and a range:
$(examples.lineplot5)
You can also plot lines by specifying an intercept and slope:
$(examples.lineplot6)
Physical units are supported through `Unitful`:
$(examples.lineplot7)
</details>
<details open>
$(summary("Staircase plot"))
$(examples.stairs1)
</details>
<details open>
$(summary("Barplot"))
$(examples.barplot1)
_Note_: You can use the keyword argument `symbols` to specify the characters that should be used to plot the bars (e.g. `symbols=['#']`).
</details>
<details open>
$(summary("Histogram"))
$(examples.histogram1)
The `histogram` function also supports axis scaling using the parameter `xscale`:
$(examples.histogram2)
Vertical histograms are supported:
$(examples.histogram3)
</details>
<details open>
$(summary("Boxplot"))
$(examples.boxplot1)
$(examples.boxplot2)
</details>
<details open>
$(summary("Sparsity Pattern"))
$(examples.spy1)
Plotting the zeros pattern is also possible using `show_zeros=true`:
$(examples.spy2)
</details>
<details open>
$(summary("Density Plot"))
$(examples.densityplot1)
</details>
<details open>
$(summary("Contour Plot"))
$(examples.contourplot1)
The keyword `levels` controls the number of contour levels. One can also choose a `colormap` as with `heatmap`, and disable the colorbar using `colorbar=false`.
</details>
<details open>
$(summary("Heatmap Plot"))
$(examples.heatmap1)
The `heatmap` function also supports axis scaling using the parameters `xfact`, `yfact` and axis offsets after scaling using `xoffset` and `yoffset`.
The `colormap` parameter may be used to specify a named or custom colormap. See the `heatmap` function documentation for more details.
In addition, the `colorbar` and `colorbar_border` options may be used to toggle the colorbar and configure its border.
The `zlabel` option and `zlabel!` method may be used to set the `z` axis (colorbar) label.
$(examples.heatmap2)
</details>
<details open>
$(summary("Polar Plot"))
Plots data in polar coordinates with `θ` the angles in radians.
$(examples.polarplot1)
</details>
<details open>
$(summary("Surface Plot"))
Plots a colored surface using height values `z` above a `x-y` plane, in three dimensions (masking values using `NaN`s is supported).
$(examples.surfaceplot1)
Use `lines=true` to increase the density (underlying call to `lineplot` instead of `scatterplot`, with color interpolation).
To plot a slice in 3D, use an anonymous function which maps to a constant value: `zscale=z -> a_constant`:
$(examples.surfaceplot2)
</details>
<details open>
$(summary("Isosurface Plot"))
Uses [`MarchingCubes.jl`](https://github.com/JuliaGeometry/MarchingCubes.jl) to extract an isosurface, where `isovalue` controls the surface isovalue.
Using `centroid` enables plotting the triangulation centroids instead of the triangle vertices (better for small plots).
Back face culling (hide not visible facets) can be activated using `cull=true`.
One can use the legacy 'Marching Cubes' algorithm using `legacy=true`.
$(examples.isosurface)
</details>
## Documentation
<details>
$(summary("Installation"))
$(installation)
</details>
<details>
$(summary("Saving figures"))
Saving plots as `png` or `txt` files using the `savefig` command is supported (saving as `png` is experimental and resulting images might slightly change without warnings).
</details>
<details>
$(summary("Color mode"))
When the `COLORTERM` environment variable is set to either `24bit` or `truecolor`, `UnicodePlots` will use [24bit colors](https://en.wikipedia.org/wiki/ANSI_escape_code#24-bit) as opposed to [8bit colors](https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit) or even [4bit colors](https://en.wikipedia.org/wiki/ANSI_escape_code#3-bit_and_4-bit) for named colors.
One can force a specific colormode using either `UnicodePlots.truecolors!()` or `UnicodePlots.colors256!()`.
Named colors such as `:red` or `:light_red` will use `256` color values (rendering will be terminal dependent). In order to force named colors to use true colors instead, use `UnicodePlots.USE_LUT[]=true`.
The default color cycle can be changed to bright (high intensity) colors using `UnicodePlots.brightcolors!()` instead of the default `UnicodePlots.faintcolors!()`.
</details>
<details>
$(summary("3D plots"))
3d plots use a so-called "Model-View-Projection" transformation matrix `MVP` on input data to project 3D plots to a 2D screen
Use keywords`elevation`, `azimuth`, `up` or `zoom` to control the "View" matrix, a.k.a., camera.
The `projection` type for `MVP` can be set to either `:perspective` or `:orthographic`.
Displaying the `x`, `y`, and `z` axes can be controlled using the `axes3d` keyword.
For enhanced resolution, use a wider and/or taller `Plot` (this can be achieved using the unexported `UnicodePlots.default_size!(width=60)` for all future plots).
</details>
<details>
$(summary("Know Issues"))
Using a non `true monospace font` can lead to visual problems on a `BrailleCanvas` (border versus canvas).
Either change the font to e.g. [JuliaMono](https://juliamono.netlify.app/) or use `border=:dotted` keyword argument in the plots.
For a `Jupyter` notebook with the `IJulia` kernel see [here](https://juliamono.netlify.app/faq/#can_i_use_this_font_in_a_jupyter_notebook_and_how_do_i_do_it).
(Experimental) Terminals seem to respect a standard aspect ratio of `4:3`, hence a square matrix does not often look square in the terminal.
You can pass the experimental keyword `fix_ar=true` to `spy` or `heatmap` in order to recover a unit aspect ratio.
</details>
<details>
$(summary("Methods (API)"))
$(methods)
</details>
<details>
$(summary("Keywords description (API)"))
$(kw_description)
</details>
<details>
$(summary("Low-level Interface"))
$(low_level_interface)
</details>
<details>
$(summary("Documentation update"))
$(doc_update)
</details>
## License
This code is free to use under the terms of the MIT license.
## Acknowledgement
Inspired by [TextPlots.jl](https://github.com/sunetos/TextPlots.jl), which in turn was inspired by [Drawille](https://github.com/asciimoo/drawille).
""")
mkpath("imgs/$ver")
open("imgs/gen_imgs.jl", "w") do io
println(io, """
# WARNING: this file has been automatically generated, please update UnicodePlots/docs/generate_docs.jl instead
using UnicodePlots, StableRNGs, SparseArrays, Unitful
# UnicodePlots.brightcolors!()
include(joinpath(dirname(pathof(UnicodePlots)), "..", "test", "fixes.jl"))
main() = begin
rng = StableRNG(1337)
bb = parse(Bool, get(ENV, "BB", "false")) ? 9 : nothing
bb_glyph = parse(Bool, get(ENV, "BB_GL", "false")) ? 8 : nothing
"""
)
for (i, (k, e)) in enumerate(pairs(exs))
println(io, "# $k")
code = filter(x -> length(x) != 0 && !startswith(lstrip(x), r"using|import"), [lstrip(c) for c in split(e[2], '\n')])
code = [replace(c, r"\bsprandn\b\(" => "_stable_sprand(rng, ", r"\brandn\b\(" => "randn(rng, ", r"\brand\b\(" => "rand(rng, ") for c in code]
println(io, """
println("ex n°$i - $k")
_ex_$i(rng) = begin
$(indent(join(code, '\n'), 1))
end
plt = _ex_$i(rng)
display(plt)
savefig(plt, "$ver/$k.png"; transparent=false, bounding_box=bb, bounding_box_glyph=bb_glyph, pixelsize=16)
# savefig(plt, "$ver/$k.txt"; color=true)
"""
)
end
println(io, "\nreturn\nend\nmain()")
end
write(stdout, readme)
open("../README.md", "w") do io
write(io, "<!-- WARNING: this file has been automatically generated, please update UnicodePlots/docs/generate_docs.jl instead, and run \$ julia generate_docs.jl to render README.md !! -->\n")
write(io, readme)
end
return
end
main()