我试图做一些非常基本的散点图。我按照此处的说明操作:https://plot.ly/julia/subplots/
using Plotly
trace1 = [
"x" => [1, 2, 3],
"y" => [4, 5, 6],
"type" => "scatter"
]
trace2 = [
"x" => [20, 30, 40],
"y" => [50, 60, 70],
"xaxis" => "x2",
"yaxis" => "y2",
"type" => "scatter"
]
data = [trace1, trace2]
layout = [
"xaxis" => ["domain" => [0, 0.45]],
"yaxis2" => ["anchor" => "x2"],
"xaxis2" => ["domain" => [0.55, 1]]
]
response = Plotly.plot(data, ["layout" => layout, "filename" => "simple-subplot", "fileopt" => "overwrite"])
plot_url = response["url"]
我明白了:
ERROR: MethodError: no method matching PlotlyJS.Plot(::Array{Array{Pair{String,Any},1},1}, ::Array{Pair{String,Any},1})
Closest candidates are:
PlotlyJS.Plot(::AbstractArray{T<:Union{AbstractString, Date, Number, Symbol},1}, ::AbstractArray{T,1} where T) where T<:Union{AbstractString, Date, Number, Symbol} at /Users/username/.julia/v0.6/PlotlyJS/src/convenience_api.jl:56
PlotlyJS.Plot(::AbstractArray{T<:Union{AbstractString, Date, Number, Symbol},1}, ::AbstractArray{T,1} where T, ::PlotlyJS.Layout; kind, style, kwargs...) where T<:Union{AbstractString, Date, Number, Symbol} at /Users/username/.julia/v0.6/PlotlyJS/src/convenience_api.jl:56
PlotlyJS.Plot(::AbstractArray{T<:(AbstractArray{T,1} where T),1}, ::AbstractArray{T,2} where T) where T<:(AbstractArray{T,1} where T) at /Users/username/.julia/v0.6/PlotlyJS/src/convenience_api.jl:68
...
Stacktrace:
[1] #plot#36(::Array{Any,1}, ::Function, ::Array{Array{Pair{String,Any},1},1}, ::Vararg{Any,N} where N) at /Users/username/.julia/v0.6/PlotlyJS/src/display.jl:76
[2] plot(::Array{Array{Pair{String,Any},1},1}, ::Vararg{Any,N} where N) at /Users/username/.julia/v0.6/PlotlyJS/src/display.jl:76
我看到错误调用PlotlyJS与常规Plotly。我将示例代码复制/粘贴到一个新的Julia shell中。我已完成Pkg.add("PlotlyJS")
,Pkg.add("Plotly")
和Pkg.update()
。仍然没有运气......
答案 0 :(得分:1)
我阅读文档表明,这是尝试的方法:
using PlotlyJS
t1 = scatter(;x=[1, 2, 3, 4, 5],
y=[1, 6, 3, 6, 1],
mode="lines",
name="Team A",
text=["A-1", "A-2", "A-3", "A-4", "A-5"])
t2 = scatter(;x=[1, 2, 3, 4, 5],
y=[10, 60, 30, 60, 10],
mode="lines",
name="Team B",
text=["B-1", "B-2", "B-3", "B-4", "B-5"])
layout = Layout(;title="Data Labels Hover",
xaxis_range=[0, 10],
yaxis_range=[0, 100])
data = [t1, t2]
PlotlyJS.plot(data, layout)
我认为我建议使用Plots.jl进行局部绘图(可以使用PlotlyJS.jl)。据推测,Plotly.jl用于绘制云计算?