Automatic adjustment of ticks when zooming with Plots.jl

In Plots.jl using pyplot as the backend, when I zoom in the plot using the pan/zoom button, the axes ticks are not automatically adjusted as PyPlot, nor the x,y coordinates at the bottom left of the plot window are displayed.

Is there a way of obtaining this in Plots.jl?


You might want to try out a different backend. Each one has very different underlying behaviours (Plot.jl tries to achieve the similar outputs only).

Choosing a backend:

Of course, I suggest trying the InspectDR.jl backend:

using Plots
inspectdr() #use InspectDR
#pyplot() #instead of pyplot

  • InspectDR was designed with interactivity in mind. For example, you can always box-zoom in on plots by using the right mouse button.
  • InspectDR is faster at plotting than PyPlot. It is more noticeable with larger datasets… especially if you draw using only lines (without symbols).

See more on mouse/keybindings:


InspectDR is mostly limited to 2D plots. Among other things, it does not support:

  • 3D plots
  • Heatmaps
1 Like

Nice, I was also looking for a fix to OP’s issue and InspectDR works well so far. Thanks!

I had forgotten about this post. That’s great to hear @dalarev!

FYI: How to get it to work with PyPlot

Apparently, this behaviour can be achieved with PyPlot if you set options:


or if you set the option in your plot command:

plot(x, y, [other args here], ticks=:native)

I checked with the maintainers of Plots.jl, and it appears the intent of ticks=:native is indeed to use PyPlot’s own internal programming to display ticks (which auto-adjusts as you zoom):
[FR] Use ticks=:native by default? · Issue #3263 · JuliaPlots/Plots.jl · GitHub

PyPlot bug warning

Having said that, there still appears to be a bug with how Plots.jl controls the PyPlot backend. Specifically, it has issues displaying tick labels when ticks=:native, for some reason:
pyplot(ticks=:native) doesn't use native ticks · Issue #3284 · JuliaPlots/Plots.jl · GitHub