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

xlims and xlabel not working in plotlyjs #1485

Closed
leoll2 opened this issue Apr 15, 2018 · 10 comments
Closed

xlims and xlabel not working in plotlyjs #1485

leoll2 opened this issue Apr 15, 2018 · 10 comments

Comments

@leoll2
Copy link

leoll2 commented Apr 15, 2018

I've already documented the issue here.

Basically, when using plotlyjs as backend to draw 3d graphs, the xlims and xlabel attributes don't work, although they're supported according to this list.
On the other side, 2d plots work fine.
Here's a picture:

And here's the code to reproduce the issue:

`using Plots

plotlyjs()

x = [2,3,4,1]
y = [8,3,1,2]
z = [4,5,3,4]

p1 = plot(x, y, seriestype=:scatter,
title="Hello!", xlabel = "xlabel", ylabel="ylabel",
xlims=(0.0, 6.5), ylims=(0.0,9.0))
p2 = plot(x, y, z, seriestype=:scatter,
title="Hello!", xlabel="xlabel",ylabel="ylabel", zlabel="zlabel",
xlims=(0.0, 80.5), ylims=(0.0,9.0), zlims=(0.0,5.0))

`

Finally, I'd like to stress the usefulness of this feature and why it'd be important for me (and others) to fix as soon as possible. I use graphs to dynamically represent an evolving data set (scatter points). Without xlims, it's very hard for me to visualize the fluctuations in the data, since the axes keep re-scaling according to the extremal values in the set.

@juliohm
Copy link

juliohm commented Apr 22, 2018

Not only with plotlyjs, the xlabel attribute is not working with plot recipes in GR either:

using Variography

foo = EmpiricalVariogram(eye(3), ones(3))

plot(foo, xlab="foo") # xlab is ignored

@BoundaryValueProblems
Copy link
Contributor

Using scatter in 3D as @leoll2 did, xlabel, ylabel, zlabel work as expected under both pyplot and gr backends, but not under plotlyjs backend at this point. It's quite strange though. It worked in January 2018. I have a script/function to do some 3D scatter plot, and I have a pdf file generated in January 2018, where I could see the plotlyjs backend did correct axis labeling. Now, the same script does not render xlabel, ylabel, zlabel as I specified. Instead, it shows simply, x, y, z on the plot. I'm currently using PlotlyJS.jl version 0.10.2 (master) with Plots.jl 0.17.0+ (master).

@mkborregaard
Copy link
Member

Hm, it looks as if the axis title attribute is being correctly set - is there a change to how this is done in plotlyjs? The 3d examples http://spencerlyon.com/PlotlyJS.jl/examples/3d/ only show x, y and z on the axes.

@BoundaryValueProblems
Copy link
Contributor

BoundaryValueProblems commented Jun 5, 2018

@mkborregaard , I communicated with @sglyon about this problem, and he gave me the following answer at JuliaPlots/PlotlyJS.jl#189 , i.e.,

After looking at the json generated by Plots.jl , I think the problem is that Plots is setting properties on layout.scene.(x|y|z)axis1 instead of layout.scene.(x|y|z)axis -- the addition of the 1 is messing things up.

Could you or @daschw check if removing 1 from the above is possible and solves this problem? I could not nail which file in Plots.jl sets this. Thanks a lot!

@mkborregaard
Copy link
Member

That happens here: https://github.com/JuliaPlots/Plots.jl/blob/master/src/backends/plotly.jl#L361-L363
It looks like it happens on purpose, for when there are more than one subplot. Did the plotly specification change?

@mkborregaard
Copy link
Member

This is apparently due to a change in the plotlyjs specification, where it's only called "xaxis" IF there's only one subplot. Plots' series don't know about subplots, but one solution could be to just always have both keys in there.
Easy PR I guess.

@daschw
Copy link
Member

daschw commented Jun 6, 2018

What's the problem with checking for length(plt.subplots) > 1?

@mkborregaard
Copy link
Member

I guess you could do that, and then revisit if used in p = scatter(randn(10)); p2 = scatter(randn(20)); plot(p1, p2)?

@daschw
Copy link
Member

daschw commented Jun 6, 2018

Ah, ok, will the axes not be updated with plot(p1, p2)?

@mkborregaard
Copy link
Member

I didn't think so but I haven't checked. That would make it easy

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

5 participants