Linking axes



Do any of the plotting packages for Julia support linking the axes of plots, as well as interactive zooming/panning? I’ve found mention (though not in docs, only in GitHub issues) of a link kwarg in Plots.jl, but it didn’t work for me on 4 different backends (PlotlyJS, PyPlot, GR, InspectDR), but to no avail.


Well, I should have tried one more thing before posting. Using PyPlot directly works:

julia> using PyPlot

julia> ax1=subplot(2,1,1)
PyObject <matplotlib.axes._subplots.AxesSubplot object at 0x12c6d6fd0>

julia> plot(randn(100,1))
1-element Array{PyCall.PyObject,1}:
 PyObject <matplotlib.lines.Line2D object at 0x139bb3dd0>

julia> ax2=subplot(2,1,2, sharex=ax1)
PyObject <matplotlib.axes._subplots.AxesSubplot object at 0x139c0fcd0>

julia> plot(randn(100,1))
1-element Array{PyCall.PyObject,1}:
 PyObject <matplotlib.lines.Line2D object at 0x139c49c90>


In case you were still interested: InspectDR allows you to “link” x-axes (does not support y-axis links) - but you must use the module directly (“linking” not supported from the Plots.jl module).

“linking” is done implicitly when you plot curves on different plot “strips” (strip=1 is bottom-most, strip=2 is next up, …).

For example, if you were to generate a bode plot of X(f), you would want to plot the magnitude & phase on different “strips”:

wfrm = add(plot, f, X, strip=1)
wfrm = add(plot, f, phase(X), strip=2)

The sample directory provides examples of common usage in circuit design:

Bode Plot:

Mixed-signal “simulation”:

Digital buffer “simulation”:


Sample outputs can be found here:

I also personally find pan/zoom interactivity more responsive with InspectDR. The feel is also more consistent with other tools than what you get with PyPlot.


This should work in Plots. What code have you tried?


For example:

using Plots
plot(randn(100,2), layout=2, link=:x)


Yeah I saw from the issue you opened that you expected the axis to stay linked when zooming using the plotlyjs gui - that does not work.


Can you clarify what does work, as far as you know?


Having the (x/y) axis limits aligned when you do the plot. The thing is that Plots does not receive any signals from the backend gui - so Plots does not know you’ve zoomed it.


Ah, there’s the confusion then. To me “link axis” means what the linkaxes command in MATLAB does:

I guess in matplotlib/PyPlot it goes by the kwarg name sharex.

Given that a backend such at PyPlot or PlotlyJS supports the linkaxes behavior that I’m after, does that mean that it’s possible to expose that via Plots?

Edit: Maybe best to keep discussion in one place: