Skip to content

Commit 2d3d01a

Browse files
committed
updated comments to yard doc format
1 parent 4f3a981 commit 2d3d01a

1 file changed

Lines changed: 55 additions & 91 deletions

File tree

lib/unicode_plot/stairs.rb

Lines changed: 55 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -1,102 +1,66 @@
11
# coding: utf-8
2-
=begin
3-
stairs(x, y; kwargs...)
4-
5-
Description
6-
============
7-
8-
Draws a staircase plot on a new canvas.
9-
10-
The first (optional) vector `x` should contain the horizontal
11-
positions for all the points. The second vector `y` should then
12-
contain the corresponding vertical positions respectively. This
13-
means that the two vectors must be of the same length and
14-
ordering.
15-
16-
Usage
17-
======
18-
19-
stairs(x, y; style = :post, name = "", title = "", xlabel = "", ylabel = "", labels = true, border = :solid, margin = 3, padding = 1, color = :auto, width = 40, height = 15, xlim = (0, 0), ylim = (0, 0), canvas = BrailleCanvas, grid = true)
20-
21-
Arguments
22-
==========
23-
24-
- **`x`** : The horizontal position for each point.
25-
26-
- **`y`** : The vertical position for each point.
27-
28-
- **`style`** : Specifies where the transition of the stair takes
29-
plays. Can be either `:pre` or `:post`.
30-
31-
- **`name`** : Annotation of the current drawing to be displayed
32-
on the right.
33-
34-
$DOC_PLOT_PARAMS
35-
36-
- **`height`** : Number of character rows that should be used
37-
for plotting.
38-
39-
- **`xlim`** : Plotting range for the x axis.
40-
`(0, 0)` stands for automatic.
41-
42-
- **`ylim`** : Plotting range for the y axis.
43-
`(0, 0)` stands for automatic.
44-
45-
- **`canvas`** : The type of canvas that should be used for drawing.
46-
47-
- **`grid`** : If `true`, draws grid-lines at the origin.
48-
49-
Returns
50-
========
51-
52-
A plot object of type `Plot{T<:Canvas}`
53-
54-
Author(s)
55-
==========
56-
57-
- Christof Stocker (Github: https://github.com/Evizero)
58-
- Dominique (Github: https://github.com/dpo)
59-
60-
Examples
61-
=========
62-
63-
```julia-repl
64-
julia> stairs([1, 2, 4, 7, 8], [1, 3, 4, 2, 7], style = :post, title = "My Staircase Plot")
65-
My Staircase Plot
66-
┌────────────────────────────────────────┐
67-
7 │⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸│
68-
│⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸│
69-
│⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸│
70-
│⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸│
71-
│⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸│
72-
│⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸│
73-
│⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸│
74-
│⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡤⠤⠤⠤⠤⠤⠤⠤⠤⠤⠤⠤⠤⠤⠤⠤⠤⡄⠀⠀⠀⠀⢸│
75-
│⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇⠀⠀⠀⠀⢸│
76-
│⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇⠀⠀⠀⠀⢸│
77-
│⠀⠀⠀⠀⠀⢸⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇⠀⠀⠀⠀⢸│
78-
│⠀⠀⠀⠀⠀⢸⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇⠀⠀⠀⠀⢸│
79-
│⠀⠀⠀⠀⠀⢸⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠧⠤⠤⠤⠤⠼│
80-
│⠀⠀⠀⠀⠀⢸⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀│
81-
1 │⣀⣀⣀⣀⣀⣸⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀│
82-
└────────────────────────────────────────┘
83-
1 8
84-
```
85-
86-
See also
87-
=========
88-
89-
[`Plot`](@ref), [`scatterplot`](@ref), [`lineplot`](@ref),
90-
[`BrailleCanvas`](@ref), [`BlockCanvas`](@ref),
91-
[`AsciiCanvas`](@ref), [`DotCanvas`](@ref)
92-
=end
932
module UnicodePlot
943

4+
5+
# ==Description
6+
#
7+
# Draws a staircase plot on a new canvas.
8+
#
9+
# The first vector `x` should contain the horizontal
10+
# positions for all the points. The second vector `y` should then
11+
# contain the corresponding vertical positions respectively. This
12+
# means that the two vectors must be of the same length and
13+
# ordering.
14+
#
15+
# ==Usage
16+
#
17+
# UnicodePlot.stairs(x, y, style: :post, name: "", title: "", xlabel: "", ylabel: "", labels: true, border: :solid, margin: 3, padding: 1, color: :auto, width: 40, height: 15, xlim: [0, 0], ylim: [0, 0], canvas: :braille, grid: true)
18+
#
19+
# @param x [Array<Numeric>] The horizontal position for each point.
20+
# @param y [Array<Numeric>] The vertical position for each point.
21+
# @param style [Symbol] Specifies where the transition of the stair takes place. Can be either `:pre` or `:post`.
22+
# @param name [String] Annotation of the current drawing to be displayed on the right.
23+
# @param height [Integer] Number of character rows that should be used for plotting.
24+
# @param xlim [Array<Numeric>] Plotting range for the x axis. `[0, 0]` stands for automatic.
25+
# @param ylim [Array<Numeric>] Plotting range for the y axis. `[0, 0]` stands for automatic.
26+
# @param canvas [Symbol] The type of canvas that should be used for drawing.
27+
# @param grid [Boolean] If `true`, draws grid-lines at the origin.
28+
#
29+
# @return [Plot] A plot object
30+
#
31+
# @example
32+
# UnicodePlot.stairs([1, 2, 4, 7, 8], [1, 3, 4, 2, 7], style: :post, title: "My Staircase Plot")
33+
#
34+
#
35+
# ┌────────────────────────────────────────┐
36+
# 7 │⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸│
37+
# │⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸│
38+
# │⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸│
39+
# │⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸│
40+
# │⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸│
41+
# │⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸│
42+
# │⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸│
43+
# │⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡤⠤⠤⠤⠤⠤⠤⠤⠤⠤⠤⠤⠤⠤⠤⠤⠤⡄⠀⠀⠀⠀⢸│
44+
# │⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇⠀⠀⠀⠀⢸│
45+
# │⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇⠀⠀⠀⠀⢸│
46+
# │⠀⠀⠀⠀⠀⢸⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇⠀⠀⠀⠀⢸│
47+
# │⠀⠀⠀⠀⠀⢸⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇⠀⠀⠀⠀⢸│
48+
# │⠀⠀⠀⠀⠀⢸⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠧⠤⠤⠤⠤⠼│
49+
# │⠀⠀⠀⠀⠀⢸⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀│
50+
# 1 │⣀⣀⣀⣀⣀⣸⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀│
51+
# └────────────────────────────────────────┘
52+
# 1 8
53+
#
54+
# @see Plot
55+
# @see scatterplot
56+
# @see lineplot
57+
#
9558
module_function def stairs(xvec, yvec, style: :post, **kw)
9659
x_vex, y_vex = compute_stair_lines(xvec, yvec, style: style)
9760
lineplot(x_vex, y_vex, **kw)
9861
end
9962

63+
# Similar to stairs, but takes an existing plot object as a first argument.
10064
module_function def stairs!(plot, xvec, yvec, style: :post, **kw)
10165
x_vex, y_vex = compute_stair_lines(xvec, yvec, style: style)
10266
lineplot!(plot, x_vex, y_vex, **kw)

0 commit comments

Comments
 (0)