1

我正在尝试使用在 Gadfly 中绘制几条直线Geom.abline。这仅在我添加一些虚拟点并使用时才对我有用Geom.point。例如,下面的代码片段会产生所需的情节,并带有一些我不想要的虚拟点。

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)

但是,当我摆脱这些点时,我会在此评论的底部收到错误消息。这里有一些尝试给我同样的错误。

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))

没有使用就没有办法Geom.abline在 Gadfly 中使用Geom.point吗?(我想我可以让这些点不可见。)

>```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```
4

0 回答 0