-
-
Notifications
You must be signed in to change notification settings - Fork 78
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
Shared axes? #159
Comments
Hi @jbrea it is definitely possible, though there isn't a "built in" way to do it yet. The example you linked to would look like this in PlotlyJS.jl: data = [
scatter(x=1:3, y=2:4),
scatter(x=20:10:40, y=fill(5, 3), xaxis="x2", yaxis="y"),
scatter(x=2:4, y=600:100:800, xaxis="x", yaxis="y3"),
scatter(x=4000:1000:6000, y=7000:1000:9000, xaxis="x4", yaxis="y4")
]
layout = Layout(
xaxis_domain=[0, 0.45],
yaxis_domain=[0, 0.45],
xaxis4=attr(domain=[0.55, 1.0], anchor="y4"),
xaxis2_domain=[0.55, 1],
yaxis3_domain=[0.55, 1],
yaxis4=attr(domain=[0.55, 1], anchor="x4")
)
plot(data, layout) I think this would be a good addition to the library, the only question is what the API should look like. One thing that could work would be to have a function function share_axes!(l::Layout; rows::Vector{Int}=Int[], cols::Vector{Int}=Int[])
# make sure `rows` and `cols` aren't both empty
# for each row in rows, make all the subplots in that row share axes with left most subplot in that row
# for each column in cols, make all subplots in that col share axes with bottom most subplot in that col
end
function share_axes!(p::Plot; rows::Vector{Int}=Int[], cols::Vector{Int}=Int[])
share_axes!(p.layout, rows=rows, cols=cols)
end
function share_axes!(p::SyncPlot; rows::Vector{Int}=Int[], cols::Vector{Int}=Int[])
share_axes!(p.plot, rows=rows, cols=cols)
end Does that seem reasonable to you? |
Hi @sglyon Thanks much for the quick response and the example! I like your proposition for the extension of the API. As an alternative, what do you think about functions like function share_xaxis!(plots::Vector{Plot})
# for each plot in plots share x-axis with plots[1]
end |
That's also a good idea. The one tricky thing is that a figure with multiple subplots will be just one Plot object... I need to think on that a bit more |
@sglyon any chance of an update? :) The example above is very helpful but my use-case is slightly different (I think?). I am in a situation similar to Either way, enjoying PlotlyJS so far! :) |
Hey @kylecarbon I haven't put more thought into this since the discussion fizzled out early this year. Would the proposed API I had in the comment above with the It is totally possible to do right now, but you would have to build the Layout object that does it by hand |
I think the I tried building the |
Is it possible to generate subplots with shared axes like
https://plot.ly/javascript/subplots/#subplots-with-shared-axes?
The text was updated successfully, but these errors were encountered: