Function values under the cursor


#1

Hi, someone could help me to plot a graph that show the function value under the cursor?
For example in the image below if the black point is cursor it will show (-0.5,2)

Tks


#2

If you are using IJulia, then you can do this with Plots.jl and plotly:

using Plots
plotly()
plot(linspace(-1, 1).^2)

#3

And if you’re using Plots with Juno, the plotlyjs() backend will do it. Just swap out that plotly() command. And if you’re at the REPL, plotlyjs() will give you a GUI window with that interactivity, while plotly() will open it in a browser.


#4

The InspectDR backend was built with this kind of interactivity in mind:

InspectDR.jl: https://github.com/ma-laforge/InspectDR.jl

  • Coordinates show up in the bottom-left corner when you hover over the plot.
  • You can also add single markers (using key “r” over point of interest)
  • You can follow up with one or more delta markers by using the “d” key.

Eventually, the intent was to have the cursor track the plot data so that all displayed coordinates are meaningful, but for now, all features are “floating” in the plot window.

How to use directly

How to use with Plots.jl (At the time of writing)

  • To use the new features of InspectDR using Plots.jl as a “frontend”, you must currently check out the master branch of Plots.jl:
julia> Pkg.checkout("Plots")

Just remember to eventually restore Plots.jl to its most recent “tagged” version once Tom (the maintainer of Plots.jl) creates a new release:

julia> Pkg.free("Plots")