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

Plotly backend #77

Closed
15 of 22 tasks
tbreloff opened this issue Nov 20, 2015 · 31 comments
Closed
15 of 22 tasks

Plotly backend #77

tbreloff opened this issue Nov 20, 2015 · 31 comments

Comments

@tbreloff
Copy link
Member

@joshday has put together a Plotly prototype at https://github.com/joshday/PlotlyLocal.jl. I want to review which parts are Plotly-specific, and which are "javascript plotting libs" specific, and generalize as best as possible.

  • Lines
  • Scatters
  • Fills/strokes
  • Hist/density
  • heatmap
  • Contour/Surface
  • Dates
  • shapes, styles, etc
  • pie charts
  • annotations
  • 3D line/scatter
  • subplots
  • tick labels/values/limits override
  • custom shapes
  • smoothing/regression
  • right y-axis
  • hline/vline (not supported directly?)
  • arbitrary fill range (not supported directly?)
  • linked subplots
  • proper writemime methods (need png)
  • easy embedding in IJulia
  • I would also like the ability to add/change the underlying plot data without rebuilding/reloading the html, but that might require something like WebSockets or Node.js (edit: done with plotlyjs!).
@rohitvarkey
Copy link

I would also like the ability to add/change the underlying plot data without rebuilding/reloading the html, but that might require something like WebSockets or Node.js.

Maybe Patchwork?

@tbreloff
Copy link
Member Author

Possibly, but I think that might be lower-level than I was aiming for. I was thinking about wrapping the Plotly javascript object with a socket to change it's data, then let them worry about individual DOM objects.

@waldyrious
Copy link
Contributor

I think this issue should include a note about why https://github.com/plotly/Plotly.jl is inadequate for this purpose, for future reference.

@tbreloff
Copy link
Member Author

Sure. Afaik, plotly/Plotly.jl is geared towards their cloud plotting API, whereas we want to access the newly released open source javascript lib.

On Nov 21, 2015, at 4:58 AM, Waldir Pimenta [email protected] wrote:

I think this issue should include a note about why https://github.com/plotly/Plotly.jl is inadequate for this purpose, for future reference.


Reply to this email directly or view it on GitHub.

@tbreloff
Copy link
Member Author

I've made a bunch of progress with Plotly, for anyone that wants to start testing things out. Latest is on the dev branch. A bunch of plot types are supported, even including contours and pie-charts, but a lot is still missing.

cc: @joshday @EricForgy

@joshday
Copy link
Contributor

joshday commented Nov 24, 2015

👍 Seems like a great start!

@tbreloff
Copy link
Member Author

tbreloff commented Dec 8, 2015

Has anyone figured out a good way to save a PNG of a Plotly graph automatically (and preferably without opening a browser window). Can I bypass the browser?

cc: @spencerlyon2

@sglyon
Copy link
Member

sglyon commented Dec 8, 2015

I can do from Julia, but only through a javascript call after an electron window is opened.

I'm still trying to come up with a better way to do this.

The best case scenario for me would to be able to save in png and pdf from a Julia script and configure at least the dpi.

Maybe @jackparmer knows some tricks?

@tbreloff
Copy link
Member Author

tbreloff commented Dec 8, 2015

What is the javascript call for this? I can do the same thing until we find a better solution.

@sglyon
Copy link
Member

sglyon commented Dec 8, 2015

It's basically this function, specifically the click callback

I haven't wrapped it up into something usable yet. I mostly played around at the js console in my electron window and mimicked the body of that function. I didn't have time to expose it from Julia -- though it's just a matter of pasting the code in as a string and letting blink call out to the js console for me.

I will say, however, that the quality is very disappointing. I think the image is saved at something like 96 dpi with no ability to configure

@tbreloff
Copy link
Member Author

tbreloff commented Dec 8, 2015

More progress! Unlinked subplots (independent axes) and IJulia embedding are supported now.

tmp

@Evizero
Copy link
Member

Evizero commented Dec 8, 2015

so this is already done completely locally? nice

@pkofod
Copy link
Contributor

pkofod commented Dec 14, 2015

Nice progress! Tried it out, and the quality is great. Is it only on my part that the text is a wee bit tiny?

@Evizero
Copy link
Member

Evizero commented Dec 14, 2015

Is it only on my part that the text is a wee bit tiny?

I second that observation

@tbreloff
Copy link
Member Author

the text is a wee bit tiny

I like it that size, but of course you can always change it:

using Plots; plotly()
default(guidefont = font(20), tickfont = font(15))
plot(rand(10), title="check out my font size")

Of course this brings up one of the issues with the Plotly backend, which is that the margins don't properly account for the guide labels.

@Evizero
Copy link
Member

Evizero commented Dec 14, 2015

I like it that size, ..

In the end it's your decision. But I would encourage you to use the usual defaults. As a user I would expect the plot to look similar to when I create it in R using the plotly package

@pkofod
Copy link
Contributor

pkofod commented Dec 14, 2015

In principle I am happy as long as I know how to change it (guidefont, legendfont, tickfont, I think I can remember three keywords :)).

If I am analysing data on my own, plotting variables I know the range of, then sure, I can live with small numbers. Though, it is a bit small for external communication - in my very humble opinion.

@tbreloff
Copy link
Member Author

But I would encourage you to use the usual defaults.

This brings up a tricky issue. In theory, everything about the plot is already defined before it gets to backend-specific code. That means the PyPlot title should be the same size as the Plotly title (it uses the Plots-default, regardless of what the backend default would be) This is the same for color palettes, etc.

I agree that there should be a way to use the backend defaults for certain things, maybe font is one of them? This might require having a default font nothing or :default, which would tell the backend not to override the font.

The other issue it highlights is that there should be a nice way to specify per-user defaults. (I guess you could always add something like this to your .juliarc.jl:

using Plots
pyplot()
default(guidefont = font(15))

@Evizero
Copy link
Member

Evizero commented Dec 14, 2015

I'm not sure I understand. If all backends share the same defaults I would expect them to look similar when it comes to size.

This is how plotly and gadfly look to me with default settings

screenshot1

screenshot2

@tbreloff
Copy link
Member Author

Ok I see... it's something weird with Plotly then. Gadfly and PyPlot seem to match. I'll try to figure out what's going on.

@Evizero
Copy link
Member

Evizero commented Dec 14, 2015

I agree that there should be a way to use the backend defaults for certain things, maybe font is one of them?

After reading your comment I changed my opinion about the backend defaults. I agree that a consistent experience across different backends is a better idea than using the backend default. I think the Gadfly plot above looks very reasonable.

@pkofod
Copy link
Contributor

pkofod commented Dec 15, 2015

A quick question, you've ( @tbreloff ) checked off "lines", and plot(x=rand(10), y=rand(10), lt = :line) does give the correct result (as the lt gets checked when arguments are parsed), but I get the warning stating that it is not supported. Is it simple because :line has not been added in the list of supported plots types, or is there still something missing?

@tbreloff
Copy link
Member Author

I don't think "line" (connected points sorted by x-value) is supported right now, but "path" is supported. This follows Gadfly's naming convention. "path" is the more general of the two. I'm not at my computer to test.

On Dec 15, 2015, at 3:53 AM, Patrick Kofod Mogensen [email protected] wrote:

A quick question, you've ( @tbreloff ) checked off "lines", and plot(x=rand(10), y=rand(10), lt = :line) does give the correct result (as the lt gets checked when arguments are parsed), but I get the warning stating that it is not supported. Is it simple because :line has not been added in the list of supported plots types, or is there still something missing?


Reply to this email directly or view it on GitHub.

@pkofod
Copy link
Contributor

pkofod commented Dec 15, 2015

I get the naming conventions, but despite the warning, the command gives me the correct result.

julia> using Plots
julia> plotly()
Plots.PlotlyPackage()
julia> y=rand(10)
10-element Array{Float64,1}:
 0.0590158
 0.862781 
 0.180373 
 0.212442 
 0.31547  
 0.853284 
 0.0148744
 0.0347428
 0.584031 
 0.874814 
julia> x=rand(10)
10-element Array{Float64,1}:
 0.818161
 0.779927
 0.897816
 0.322846
 0.192778
 0.295251
 0.273533
 0.414125
 0.52945 
 0.568889
julia> plot(x=x, y=y)
julia> Created new window in existing browser session.
julia> plot(x=x, y=y, lt=:line)
WARNING: linetype line is unsupported with Plots.PlotlyPackage().  Choose from: [:none,:path,:scatter,:steppre,:steppost,:heatmap,:hist,:density,:bar,:contour,:surface,:path3d,:scatter3d,:pie]
julia> Created new window in existing browser session.

path

line

So it works, even if an error is thrown saying that it doesn't. I guess because it flows through https://github.com/tbreloff/Plots.jl/blob/366dc1cca99e680a8bc175705344153876269ebc/src/plot.jl#L315-L322 ? So I should maybe interpret the warning as: " you will get a line plot, but not by actually calling the backend directly, rather I do something to the data first" ?

@tbreloff
Copy link
Member Author

Perfect thanks. Just need to add it to the supported list then :)

On Dec 15, 2015, at 7:13 AM, Patrick Kofod Mogensen [email protected] wrote:

I get the naming conventions, but despite the warning, the command gives me the correct result.

julia> using Plots
julia> plotly()
Plots.PlotlyPackage()
julia> y=rand(10)
10-element Array{Float64,1}:
0.0590158
0.862781
0.180373
0.212442
0.31547
0.853284
0.0148744
0.0347428
0.584031
0.874814
julia> x=rand(10)
10-element Array{Float64,1}:
0.818161
0.779927
0.897816
0.322846
0.192778
0.295251
0.273533
0.414125
0.52945
0.568889
julia> plot(x=x, y=y)
julia> Created new window in existing browser session.
julia> plot(x=x, y=y, lt=:line)
WARNING: linetype line is unsupported with Plots.PlotlyPackage(). Choose from: [:none,:path,:scatter,:steppre,:steppost,:heatmap,:hist,:density,:bar,:contour,:surface,:path3d,:scatter3d,:pie]
julia> Created new window in existing browser session.

So it works, even if an error is thrown saying that it doesn't.


Reply to this email directly or view it on GitHub.

@Evizero
Copy link
Member

Evizero commented Dec 17, 2015

Is there a way to drawn onto a ploly surface plot? Last time I tried it said that it isn't allowed.

Context: I would like to be able to recreate GIFs like this one from an NVIDIA blog

optimization

@tbreloff
Copy link
Member Author

You should be able to do this already. This works for me:

surface(Surface((x,y)->cos(x)+sin(y),0:10,0:10))  # actually this constructor isn't pushed up yet, but any surface will work
path3d!(10rand(100),10rand(100),2rand(100), w=4)

The tough part is saving a PNG and creating the animation... Plotly is not the ideal choice because of that.

@Evizero
Copy link
Member

Evizero commented Dec 17, 2015

I'll check it out, thanks

The tough part is saving a PNG and creating the animation

actually, I would be fine with live animations as well. Would probably be cooler anyway to be able to rotate the thing while it's happening

@tbreloff
Copy link
Member Author

I would be fine with live animations as well.

I'd like this too, but PyPlot is a better option for both approaches. Right now, I create fresh html for Plotly every time you update/display the plot, so it would pop up 100 browser windows, each with the next frame.

Eventually I'd like to incorporate the approaches of @spencerlyon2 and/or @EricForgy to update existing Plotly plots.

@tbreloff
Copy link
Member Author

Fyi... I just added PyPlot support for 3d surfaces and wireframes:

tmp

@tbreloff
Copy link
Member Author

Closing in favor of meta-issue (#316)

t-bltg pushed a commit that referenced this issue Oct 6, 2022
t-bltg pushed a commit that referenced this issue Oct 6, 2022
Jonas-a-Zimmermann pushed a commit to Jonas-a-Zimmermann/Plots.jl that referenced this issue Oct 29, 2024
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

7 participants