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

bugs in restyle and restyle! #178

Open
CarloLucibello opened this issue Feb 7, 2018 · 2 comments
Open

bugs in restyle and restyle! #178

CarloLucibello opened this issue Feb 7, 2018 · 2 comments

Comments

@CarloLucibello
Copy link

CarloLucibello commented Feb 7, 2018

Hi,
I think I encountered two different bugs. I'm a new user of plotly*, so sorry if I'm just doing everything wrong.
The first is in restyle

julia> pl = plot(scatter(x=1:10, y=1:10)) 

julia> restyle(pl, 1, y=1:2:20)
ERROR: MethodError: no method matching PlotlyJS.ElectronDisplay()
Closest candidates are:
  PlotlyJS.ElectronDisplay(::Base.Random.UUID) at /home/carlo/.julia/v0.6/PlotlyJS/src/displays/electron.jl:12
  PlotlyJS.ElectronDisplay(::Base.Random.UUID, ::Nullable{Any}) at /home/carlo/.julia/v0.6/PlotlyJS/src/displays/electron.jl:6
  PlotlyJS.ElectronDisplay(::PlotlyBase.Plot) at /home/carlo/.julia/v0.6/PlotlyJS/src/displays/electron.jl:13

The second in restyle!

julia> pl = plot(scatter(x=1:10, y=1:10)) 

julia> pl.plot.data[1].fields
Dict{Symbol,Any} with 3 entries:
  :y    => 1:10
  :type => "scatter"
  :x    => 1:10

julia> restyle!(pl, 1, y=1:2:20)


# after this the plot is a little screwed up
julia> restyle!(pl,1,y=1:2:20)
Blink.Page(3, WebSockets.WebSocket(19, TCPSocket(RawFD(23) active, 0 bytes waiting), CONNECTED::WebSockets.ReadyState = 1), Dict{String,Any}(Pair{String,Any}("callback", Blink.#3)), Future(1, 1, 9, Nullable{Any}(true)))

julia> pl.plot.data[1].fields
Dict{Symbol,Any} with 3 entries:
  :y    => 1   # ?????
  :type => "scatter"
  :x    => 1:10

@CarloLucibello CarloLucibello changed the title restyle bugs in restyle and restyle! Feb 7, 2018
@sglyon
Copy link
Member

sglyon commented Feb 8, 2018

Hi @CarloLucibello thanks for posting here.

The first but report is definitely a bug. I'll try to get that fixed up.

The second one is actually intentional. The API feels a bit strange, but matches the plotly.js API. The screenshot below shows what happens when I create a plot in my javascript console and then call Plotly.restyle on it. Notice that when I pass {y: [1, 3, ...]} the y attribute on the trace only has a 1 on it. However, when I pass {y: [[1, 3, ...]]} (note the two [[ and ]]), then things happen as they should.

screen shot 2018-02-08 at 8 55 53 am

The way to do this in julia is then to pass an array or tuple of arrays:

julia> pl = plot(scatter(x=1:10, y=1:10));

julia> pl.plot.data[1].fields
Dict{Symbol,Any} with 3 entries:
  :y    => 1:10
  :type => "scatter"
  :x    => 1:10

julia> restyle!(pl, 1, y=(1:2:20,)); pl.plot.data[1].fields
Dict{Symbol,Any} with 3 entries:
  :y    => 1:2:19
  :type => "scatter"
  :x    => 1:10

julia> restyle!(pl, 1, y=[1:2:20]); pl.plot.data[1].fields
Dict{Symbol,Any} with 3 entries:
  :y    => 1:2:19
  :type => "scatter"
  :x    => 1:10

Does that make sense?

@CarloLucibello
Copy link
Author

that was very clear, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants