JuliaPlots / Plots.jl

Powerful convenience for Julia visualizations and data analysis
https://docs.juliaplots.org
Other
1.84k stars 355 forks source link

wireframe plot in plolyjs backend #643

Open BoundaryValueProblems opened 7 years ago

BoundaryValueProblems commented 7 years ago

The wireframe function with plolyjs as the backend renders quite a strange plot, which does not happen using pyplot as the backend. Here is a very simple example:

vx=reshape(linspace(-pi,pi,20),1,20);x=repmat(vx,20,1);
vy=reshape(linspace(-pi,pi,20),20,1);y=repmat(vy,1,20);
z=sin(x+y);
wireframe(x,y,z)

Here is an output using plolyjs: newplot

Here is an output using pyplot:

screen shot 2017-01-11 at 11 09 27 pm

Normally when we use wireframe, we would expect the latter rendering of pyplot. So, what's wrong with plotlyjs? Also, with plotlyjs as the backend, the wireframe function shows the unnecessary colorbar as shown above, and the attribute setting colorbar=false has no effect.

Thanks!

mkborregaard commented 7 years ago

In PlotlyJS, the wireframe is just a heatmap with no filling of the surface. This creates this slightly unintuitive behaviour. On GR, wireframe doesn't work at all. I think the best solution here is to define wireframe as a new series recipe creating a web of 3-d lines (which is what it is, after all). This should work on all 3-d capable backends. Is that something you'd consider doing @BoundaryValueProblems ? (and do you agree with this suggestion @tbreloff ?)

pkofod commented 7 years ago

Wherever we can avoid pointing directly to "advanced" functionality by relying on recipes, I think we all agree we should. It's much easier to maintain correct behaviour of a 3d line, than a 3d line, a wireframe, a ..., :)

BoundaryValueProblems commented 7 years ago

@mkborregaard, in principle, I want to contribute to make wireframe plot via plotlyjs correctly render expected figures, but it may take a long time considering my teaching schedule and other immediate duties, etc. To do so, I need to learn how to create a new series recipe in the first place. Perhaps, I may be able to persuade one of my students to do this, or maybe this should be one of my summer projects...

tbreloff commented 7 years ago

The actual recipe should be super quick. Less than 30 minutes? Just know that "z" should be a Plots.Surface when the recipe is processed. The method will be a simple double-loop adding line segments originating at each (x,y) grid point.

I'd do it but this is a good learning experience for someone.

On Tue, Mar 14, 2017 at 10:27 PM Naoki Saito notifications@github.com wrote:

@mkborregaard https://github.com/mkborregaard, in principle, I want to contribute to make wireframe plot via plotlyjs correctly render expected figures, but it may take a long time considering my teaching schedule and other immediate duties, etc. To do so, I need to learn how to create a new series recipe in the first place. Perhaps, I may be able to persuade one of my students to do this, or maybe this should be one of my summer projects...

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/JuliaPlots/Plots.jl/issues/643#issuecomment-286622316, or mute the thread https://github.com/notifications/unsubscribe-auth/AA492nSMXG7HIIwnKdiXchBAAmPjCHgvks5rl0ysgaJpZM4LhcQf .

mkborregaard commented 7 years ago

@BoundaryValueProblems If you have an ambitious student that uses julia, this could provide a very good experience with contributing to an open source project with the quality bar set high (and the potential user uptake of the work quite big). Just note that this would go in core Plots (in the recipes.jl file) and so the quality level must be 100%. But as Tom said it shouldn't be super difficult. There is a very good contributing page in the docs, and I am happy to answer doubts on the gitter channel.