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

Allow values to get passed to hline/vline instead of vectors #2575

Closed
djsegal opened this issue Apr 13, 2020 · 9 comments
Closed

Allow values to get passed to hline/vline instead of vectors #2575

djsegal opened this issue Apr 13, 2020 · 9 comments

Comments

@djsegal
Copy link
Contributor

djsegal commented Apr 13, 2020

Right now you get an error:

scatter(rand(100))
hline!(0.5)

Cannot convert Float64 to series data for plotting

Stacktrace:
 [1] error(::String) at ./error.jl:33
 [2] prepareSeriesData(::Float64) at /Users/dan/.julia/packages/Plots/cc8wh/src/series.jl:14
 [3] convertToAnyVector(::Float64, ::Dict{Symbol,Any}) at /Users/dan/.julia/packages/Plots/cc8wh/src/series.jl:29
 [4] macro expansion at /Users/dan/.julia/packages/Plots/cc8wh/src/series.jl:129 [inlined]
 [5] apply_recipe(::Dict{Symbol,Any}, ::Type{Plots.SliceIt}, ::Nothing, ::Float64, ::Nothing) at /Users/dan/.julia/packages/RecipesBase/G4s6f/src/RecipesBase.jl:279

// this should just automatically cast the hline or vline like:

hline([0.5])

@BeastyBlacksmith BeastyBlacksmith added the enhancement improving existing functionality label Apr 14, 2020
@BeastyBlacksmith
Copy link
Member

If this is going to be done, we shouldn't specialize hline/vline, but generally allow things like scatter(0.2,0.3).

@mkborregaard
Copy link
Member

mkborregaard commented Apr 14, 2020

Note that scatter(2) (using an Int rather than a float) does something different (opens an empty plot with 2 subplots).
I disagree with

this should just automatically cast the hline or vline

A distinction between vectors and scalars is exactly what makes julia nicer than R IMHO

@BeastyBlacksmith
Copy link
Member

Note that scatter(2) (using an Int rather than a float) does something different (opens an empty plot with 2 subplots).

Which I do find surprising

@mkborregaard
Copy link
Member

Maybe? At least it's the current behaviour and some users depend on it (useful for live updating plots where you gradually push to the series)

@mkborregaard mkborregaard added discussion and removed enhancement improving existing functionality labels Apr 14, 2020
@daschw
Copy link
Member

daschw commented Apr 14, 2020

plt = plot(2) creates a plot with 2 empty series (in one subplot). Then you can push a point to the ith series with push!(plt, i, (x, y)).

@mkborregaard
Copy link
Member

haha thanks @daschw I must have misremembered or used it with layout = 2

@BeastyBlacksmith
Copy link
Member

duplicate of #2129

@Gyoshi
Copy link

Gyoshi commented Jun 16, 2020

I would find it much more intuitive if the methods were at least called hlines and vlines to indicate that they take an array of values.

Well, maybe that is not the ideal solution, but when so many things "just work", it is honestly flabbergasting not to have something as straightforward as hline!(3.1) work.

@juliohm
Copy link

juliohm commented Aug 1, 2020

Should this be closed as a duplicate?

@daschw daschw closed this as completed Aug 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants