Support non-identity axis scales in ablines - #5685
Conversation
ablines previously errored on any non-identity transform. It now draws the line as a subdivided curve in transformed space (256 points), keeping the efficient 2-point path for the identity transform. Points whose y leaves the y-scale domain become NaN, so a line crossing into e.g. negative territory on a log axis breaks off-screen instead of throwing. Per-line vector color/linewidth are expanded to match. Drawn with lines instead of linesegments.
…med-axes # Conflicts: # CHANGELOG.md
| scene = Makie.parent_scene(p) | ||
| transf = transform_func(scene) | ||
| is_identity_transform(transf) || throw(ArgumentError("ABLines is only defined for the identity transform, not $(typeof(transf)).")) | ||
| const N_ABLINE_SUBDIVISIONS = 256 |
There was a problem hiding this comment.
This should probably be an attribute?
|
At some point we wanted to make this work generically by adapting the apply_transform machinery to be able to add points to lines: apply_transform(func, vector_of_points)::Vector{Point}Maybe worth a shot with claude being able to do the annoying interface refactor? |
|
Dendrogram has something specifically for Makie.jl/Makie/src/stats/dendrogram.jl Lines 93 to 136 in eff2c6f If we added resampling in an automated way it would definitely need an on/off switch. Discrete plots like scatter definitely shouldn't resample. Something like lines may also have situations where it shouldn't. For example if you make a spider chart by reducing the number of points in a PolarAxis. |
|
Yeah, it'd need to dispatch on the plot type as well... |
ablinesused to error on any non-identity axis scale (ABLines is only defined for the identity transform). But there's no real reason for that:f(x) = slope * x + interceptis defined in data coordinates, so under a transform it just becomes a curve in screen space. This draws it as a subdivided curve (256 points sampled evenly across the visible range), and keeps the cheap 2-point line for the identity transform.A few details fall out of this:
NaN, so the line breaks there. Since the visible y-range is always inside the domain, the break is always off-screen.color/linewidthvectors still work, and it now draws withlinesrather thanlinesegments.