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

[BUG] link=:y doesn't work across nested subplots with layout #4934

Open
cstjean opened this issue May 9, 2024 · 2 comments
Open

[BUG] link=:y doesn't work across nested subplots with layout #4934

cstjean opened this issue May 9, 2024 · 2 comments
Labels

Comments

@cstjean
Copy link

cstjean commented May 9, 2024

Details

plot(plot([1,2]), plot([3,4]), 
	 plot([-1,-2]), plot([3,-4]), layout=(2,2),
     link=:y)

generates linked plots, but

plot(plot(plot([1,2]), plot([3,4]), layout=(2,1)), 
	 plot(plot([-1,-2]), plot([3,4]), layout=(2,1)),
     link=:y)

doesn't (top plots' yrange isn't linked):

image

Backends

This bug occurs on ( insert x below )

Backend yes no untested
gr (default) X
pythonplot X
plotlyjs X
pgfplotsx X
unicodeplots X
inspectdr X
gaston X

Versions

Plots.jl version: v1.40.4
Backend version (]st -m <backend(s)>):
Output of versioninfo():

@cstjean cstjean added the bug label May 9, 2024
@isentropic
Copy link
Member

I kinda understand why this happens, but I also thing this could be a feature rather than a bug. It is because each plot(...) returns different objects and ylink doesn't know about the existance of the outer plot in case you do it the second way

@cstjean
Copy link
Author

cstjean commented May 14, 2024

For context, I basically have (in pseudocode)

model_plots(m::Model) = plot(plot(m.efficiency), plot(m.yield); layout=(2,1))

compare_models(m1::Model, m2::Model) = plot(model_plots(m1), model_plots(m2), link=:y)

To me that feels very natural. Is there a better way of structuring that code?

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

No branches or pull requests

2 participants