Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support scalars for hline! and vline! #2129

Open
fkastner opened this issue Aug 7, 2019 · 4 comments
Open

support scalars for hline! and vline! #2129

fkastner opened this issue Aug 7, 2019 · 4 comments
Labels
2.0 enhancement improving existing functionality
Milestone

Comments

@fkastner
Copy link

fkastner commented Aug 7, 2019

It would be nice to have hline!(0.73) working instead of hline!([0.73]). The same goes for vline!.
Currently for floats it errors with No user recipe defined for Float64.
For Ints on the other hand I get a BoundsError attempt to access 0-element Array{Float64,1} at index [1].

I am 70 percent sure this worked about four weeks ago but if not then consider this a feature request :)

@yha
Copy link
Member

yha commented Aug 13, 2019

Maybe we should just generally have @recipe f(x::Real) = [x]?
That way you can also do e.g. scatter!(3,5) to add a single marker to a plot.
This idea conflicts with the current interpretation of integers as adding empty series (plot(n) adds n empty series). But is this really useful?

I am 70 percent sure this worked about four weeks ago but if not then consider this a feature request :)

I remember this being an annoyance for quite some time. Perhaps somehow it was temporarily working recently, but I doubt it.

@daschw
Copy link
Member

daschw commented Aug 13, 2019

This idea conflicts with the current interpretation of integers as adding empty series (plot(n) adds n empty series). But is this really useful?

It's used in the Lorenz Attractor example on the start page of Plots Docs, http://docs.juliaplots.org/latest/#simple-is-beautiful, to initialize an empty series and grow it in an animation. I don't know how much it's used by users, I don't use it. But I think this change requires some discussion as it would be breaking.

I remember this being an annoyance for quite some time. Perhaps somehow it was temporarily working recently, but I doubt it.

I also cannot imagine that this worked recently. but I am not 100% sure.

@AshtonSBradley
Copy link

AshtonSBradley commented Mar 11, 2023

Does this really break anything? Can't we just set a generic scalar fallback for hline!, vline! of the form

hline!(x) = hline!([x])

so the previous behavior is retained.

In

http://docs.juliaplots.org/latest/#simple-is-beautiful

they use vline!([a])

so no breakage. For the Int problem above, why not just do a quick convert to Float? its all Float32 on the plot anyway, right? I don't see why this has to involve scatter, that presumably has its own use cases.

Isn't this just a one liner to make a rational fallback on top of existing behaviour?

I dont see why this is relevant

Maybe we should just generally have @recipe f(x::Real) = [x]? That way you can also do e.g. scatter!(3,5) to add a single marker to a plot. This idea conflicts with the current interpretation of integers as adding empty series (plot(n) adds n empty series). But is this really useful?

I am 70 percent sure this worked about four weeks ago but if not then consider this a feature request :)

I remember this being an annoyance for quite some time. Perhaps somehow it was temporarily working recently, but I doubt it.

This seems to be about new plots.

@isentropic isentropic mentioned this issue Jan 12, 2024
37 tasks
@BeastyBlacksmith BeastyBlacksmith mentioned this issue Mar 12, 2024
30 tasks
@TheFibonacciEffect
Copy link

Maybe a related bug:

julia> using Plots
julia> vline(100)

will display a plot with 100 lines instead of throwing an error.
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2.0 enhancement improving existing functionality
Projects
None yet
Development

No branches or pull requests

7 participants