c_lienk
c_lienk

Reputation: 11

Using Geom.abline in Gadfly without using Geom.point

I'm trying to plot a few straight lines in Gadfly using Geom.abline. This only works for me when I add a few dummy points, and use Geom.point as well. For instance, the following snippet produces the desired plot, jut with some dummy points I don't want.

using Gadfly 
slopes = [1 2 3]
intercepts = [-1 0 2]
p = plot(x = [-10, 10], y = [-10, 10],Geom.point, slope = slopes, intercept = intercepts, Geom.abline)

However, when I get rid of the points, I get the error message at the bottom of this comment. Here a a few attempts that give me the same error.

p = plot(slope = slopes, intercept = intercepts, Geom.abline)

p = plot(slope = slopes, intercept = intercepts, Geom.abline, Coord.cartesian(xmin=-10, xmax=10, ymin=-10, ymax=10))

p = plot(slope = slopes, intercept = intercepts, Geom.abline, Scale.x_continuous(minvalue = -10, maxvalue = 10),  Scale.y_continuous(minvalue = -10, maxvalue = 10))

Is there just no way to use Geom.abline in Gadfly without using Geom.point? (I guess I can just make the points invisible.)

>```Julia Client – Internal Error
MethodError: no method matching iterate(::Nothing)
Closest candidates are:
  iterate(!Matched::Union{LinRange, StepRangeLen}) at range.jl:664
  iterate(!Matched::Union{LinRange, StepRangeLen}, !Matched::Int64) at range.jl:664
  iterate(!Matched::T) where T<:Union{Base.KeySet{var"#s79", var"#s78"} where {var"#s79", var"#s78"<:Dict}, Base.ValueIterator{var"#s77"} where var"#s77"<:Dict} at dict.jl:693
  ...
_extrema_itr(f::typeof(identity), itr::Nothing) at operators.jl:482
extrema(itr::Nothing) at operators.jl:462
render(geom::Gadfly.Geom.ABLineGeometry, theme::Theme, aes::Gadfly.Aesthetics) at hvabline.jl:162
render(geom::Gadfly.Geom.ABLineGeometry, theme::Theme, aes::Gadfly.Aesthetics, subplot_layer_aess::Vector{Gadfly.Aesthetics}, subplot_layer_datas::Vector{Gadfly.Data}, scales::Dict{Symbol, Gadfly.ScaleElement}) at geometry.jl:45
(::Gadfly.var"#128#130"{Dict{Symbol, Gadfly.ScaleElement}})(::Tuple{Layer, Gadfly.Aesthetics, Vector{Gadfly.Aesthetics}, Vector{Gadfly.Data}, Theme}) at none:0
iterate at generator.jl:47 [inlined]
collect(itr::Base.Generator{Base.Iterators.Zip{Tuple{Vector{Layer}, Vector{Gadfly.Aesthetics}, Vector{Vector{Gadfly.Aesthetics}}, Vector{Vector{Gadfly.Data}}, Vector{Theme}}}, Gadfly.var"#128#130"{Dict{Symbol, Gadfly.ScaleElement}}}) at array.jl:678
render_prepared(plot::Plot, coord::Gadfly.Coord.Cartesian, plot_aes::Gadfly.Aesthetics, layer_aess::Vector{Gadfly.Aesthetics}, layer_stats::Vector{Vector{Gadfly.StatisticElement}}, layer_subplot_aess::Vector{Vector{Gadfly.Aesthetics}}, layer_subplot_datas::Vector{Vector{Gadfly.Data}}, scales::Dict{Symbol, Gadfly.ScaleElement}, guides::Vector{Gadfly.GuideElement}; table_only::Bool, dynamic::Bool) at Gadfly.jl:802
render_prepared(plot::Plot, coord::Gadfly.Coord.Cartesian, plot_aes::Gadfly.Aesthetics, layer_aess::Vector{Gadfly.Aesthetics}, layer_stats::Vector{Vector{Gadfly.StatisticElement}}, layer_subplot_aess::Vector{Vector{Gadfly.Aesthetics}}, layer_subplot_datas::Vector{Vector{Gadfly.Data}}, scales::Dict{Symbol, Gadfly.ScaleElement}, guides::Vector{Gadfly.GuideElement}) at Gadfly.jl:794
render(plot::Plot) at Gadfly.jl:740
draw at Gadfly.jl:843 [inlined]
show(io::IOContext{IOBuffer}, m::MIME{Symbol("application/prs.juno.plotpane+html")}, p::Plot) at Gadfly.jl:953
show(io::IOContext{IOBuffer}, m::String, x::Plot) at multimedia.jl:111
displayinplotpane(x::Plot) at showdisplay.jl:51
displayandrender(res::Plot) at showdisplay.jl:131
(::Atom.var"#204#209"{String})() at eval.jl:138
#invokelatest#2 at essentials.jl:708 [inlined]
invokelatest at essentials.jl:706 [inlined]
macro expansion at dynamic.jl:24 [inlined]
eval(text::String, line::Int64, path::String, mod::String, errorinrepl::Bool) at eval.jl:114
invokelatest(::Any, ::Any, ::Vararg{Any, N} where N; kwargs::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}) at essentials.jl:708
invokelatest(::Any, ::Any, ::Vararg{Any, N} where N) at essentials.jl:706
macro expansion at eval.jl:41 [inlined]
(::Atom.var"#184#185")() at task.jl:411```

Upvotes: 1

Views: 74

Answers (0)

Related Questions