朱莉娅Plotly绘图。

3

我正在尝试制作一些基本的散点图。我正在按照这里的说明进行操作: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"]

I get:

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()。仍然没有成功...

1个回答

2

我的阅读文档的理解是,这是一种值得尝试的方法:

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)

PlotlyJS

我认为在本地绘图时应该使用Plots.jl(可以使用PlotlyJS.jl)。据说Plotly.jl是用于云端绘图的?


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接