WIP
This commit is contained in:
@@ -304,7 +304,6 @@ current_figure()
|
|||||||
|
|
||||||
### Text (`annotations`)
|
### Text (`annotations`)
|
||||||
|
|
||||||
|
|
||||||
Text can be placed at a point, as a marker is. To place text, the desired text and a position need to be specified along with any adjustments to the default attributes.
|
Text can be placed at a point, as a marker is. To place text, the desired text and a position need to be specified along with any adjustments to the default attributes.
|
||||||
|
|
||||||
|
|
||||||
@@ -315,25 +314,43 @@ For example:
|
|||||||
xs = 1:5
|
xs = 1:5
|
||||||
pts = Point2.(xs, xs)
|
pts = Point2.(xs, xs)
|
||||||
scatter(pts)
|
scatter(pts)
|
||||||
annotations!("Point " .* string.(xs), pts;
|
annotation!(pts;
|
||||||
fontsize = 50 .- 2*xs,
|
text = "Point " .* string.(xs),
|
||||||
rotation = 2pi ./ xs)
|
fontsize = 30 .- 5*xs)
|
||||||
|
|
||||||
current_figure()
|
current_figure()
|
||||||
```
|
```
|
||||||
|
|
||||||
The graphic shows that `fontsize` adjusts the displayed size and `rotation` adjusts the orientation. (The graphic also shows a need to manually override the limits of the `y` axis, as the `Point 5` is chopped off; the `ylims!` function to do so will be shown later.)
|
The graphic shows that `fontsize` adjusts the displayed size.
|
||||||
|
|
||||||
|
|
||||||
Attributes for `text`, among many others, include:
|
Attributes for `text`, among many others, include:
|
||||||
|
|
||||||
|
|
||||||
* `align` Specify the text alignment through `(:pos, :pos)`, where `:pos` can be `:left`, `:center`, or `:right`.
|
* `align` Specify the text alignment through `(:pos, :pos)`, where `:pos` can be `:left`, `:center`, or `:right`.
|
||||||
* `rotation` to indicate how the text is to be rotated
|
|
||||||
* `fontsize` the font point size for the text
|
* `fontsize` the font point size for the text
|
||||||
* `font` to indicate the desired font
|
* `font` to indicate the desired font
|
||||||
|
|
||||||
|
|
||||||
|
Annotations with an arrow can be useful to highlight a feature of a graph. This example is modified from the documentation and utilizes some interval functions to draw an arrow with an arc:
|
||||||
|
|
||||||
|
```{julia}
|
||||||
|
g(x) = cos(6x) * exp(x)
|
||||||
|
xs = 0:0.01:4
|
||||||
|
|
||||||
|
_, ax, _ = lines(xs, g.(xs); axis = (; xgridvisible = false, ygridvisible = false))
|
||||||
|
|
||||||
|
annotation!(ax, 1, 20, 2.1, g(2.1),
|
||||||
|
text = "A relative maximum",
|
||||||
|
path = Ann.Paths.Arc(0.3),
|
||||||
|
style = Ann.Styles.LineArrow(),
|
||||||
|
labelspace = :data
|
||||||
|
)
|
||||||
|
|
||||||
|
current_figure()
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
#### Line attributes
|
#### Line attributes
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user