MakieOrg / Makie.jl

Interactive data visualizations and plotting in Julia
https://docs.makie.org/stable
MIT License
2.41k stars 310 forks source link

Setting `xmin` and `xmax` for `hlines` in data coordinates #4443

Open musoke opened 3 weeks ago

musoke commented 3 weeks ago

Feature description

For clarity, I refer only to hlines in this feature request. Assume that the following applies to ymin and ymax for vlines too.

I would like to be able to set minimum and maximum x-values for hlines in data coordinates. As far as I can tell, it is currently only possible to set these in scene coordinates.

In this code, I attempt to draw horizontal lines that extend right from a curve by using xmin in scene coordinates.

using CairoMakie
lines(0..10, sqrt)
hvals = [1, 2, 3]
hlines!(hvals, xmin=hvals.^2 ./ 10)
current_figure()

image

As you can see, the naive conversion to scene coordinates is buggy because the scene's limits do not correspond exactly to the data's limits. In more complex plots, converting coordinates manually can be even harder.

Alternatively, being able to use lines without affecting the limits would allow a similar result.

musoke commented 3 weeks ago

matplotlib implements these as separate plot types: hlines and axhlines.

jkrumbiegel commented 3 weeks ago

You could use rangebars for that with horizontal orientation

musoke commented 3 weeks ago

Huh, that's an interesting approach!

On Thu, Oct 3, 2024, 00:54 Julius Krumbiegel @.***> wrote:

You could use rangebars for that with horizontal orientation

— Reply to this email directly, view it on GitHub https://github.com/MakieOrg/Makie.jl/issues/4443#issuecomment-2390515532, or unsubscribe https://github.com/notifications/unsubscribe-auth/AD7ET7C3WAHVYXBW5SFOD63ZZTEXJAVCNFSM6AAAAABPIRXYMCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGOJQGUYTKNJTGI . You are receiving this because you authored the thread.Message ID: @.***>