From 2af5a6a213bacac16d449b8b4b87b4d1743e25e8 Mon Sep 17 00:00:00 2001 From: jverzani Date: Fri, 27 Jun 2025 19:23:48 -0400 Subject: [PATCH] WIP --- quarto/alternatives/makie_plotting.qmd | 29 ++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/quarto/alternatives/makie_plotting.qmd b/quarto/alternatives/makie_plotting.qmd index 61ed0b0..ed558e6 100644 --- a/quarto/alternatives/makie_plotting.qmd +++ b/quarto/alternatives/makie_plotting.qmd @@ -304,7 +304,6 @@ current_figure() ### 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. @@ -315,25 +314,43 @@ For example: xs = 1:5 pts = Point2.(xs, xs) scatter(pts) -annotations!("Point " .* string.(xs), pts; - fontsize = 50 .- 2*xs, - rotation = 2pi ./ xs) +annotation!(pts; + text = "Point " .* string.(xs), + fontsize = 30 .- 5*xs) 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: * `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 * `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