How to interact til an inspectDR plot

Tagging @MA_Laforge

I have just discovered inspectDR, and it looks PERFECT for my needs - quick and interactive plotting for learning. It feels quick and snappy, and looks pretty good. The functionality of finding slopes interactivly is also simply fantastic. I am using is as a backend, with Plots.jl as frontend.

So over to a couple of starting problems:

  1. It seems like there is no interactivity in the VSCode plotting pane. This is a shame, as it is my preferred place to plot. A pretty okay workaround is calling gui() to have an interactive pop-out, but support for interactivity directly in the pane (as with Plotly) would be great.

  2. I don’t have any overview of how I interact with the plot. I can see that I can right-click-and-drag to create a zoom-box, and that I can press image to zoom and pan the x-axis. But I still dont know:

  • How to zoom out
  • How to find a slope
  • How to pan the y-axis

If provided with information on how to interact with the plot, I would love to add a section in the readme.md on “How to interact with the plot”.

Take a look at the keybindings section.

1 Like

Great to hear! Despite getting the occasional star, it’s hard to tell if people actually use/like it.

:thinking: Actually that would be nice. But at the moment, that would only be practical if you could instantiate Gtk within a VSCode plotting plane. I don’t have the free time to maintain two different GUIs at the moment - and I’m pretty sure the plotting pane only supports rendering images anyhow. That doesn’t mean we can’t get it to change, though.

I guess @rafael.guerra beat me to the answer (keybindings page) :smiley: . Thanks for helping out Rafael!

Also: thanks for pointing out the difficulty in finding the info. Maybe I can at least have an TOC entry that mentions “interacting with the plot” or something. If I’m actually going to have people looking at InspectDR, maybe I can add a quick tutorial with images too.

2 Likes

I felt silly after realizing that the keybindings are actually IN the TOC. I skimmed the actual text, and did not think to check the TOC as a seperate souce of info. But maybe a small subtitle with a tiny text with a link to the keybinding-section early in the readme would be more natural for a package with a focus on interactivity?

I am also not thrilled with the actual keybindings… I am often on a trackpad, and so holding right-click or a keyboard-button is ankward while actually using the mouse. It might be a dealbreaker for becoming my goto backend, which would mean I would only use inspectdr when dealing with several 100 tousands of datapoints.

In terms of interactivity in the plotting pane, WGLMakie and plotly have it down, but several others do not.

I have been thinking of making a post with the point of trying to arrive at a logical and easy set of keybinds, because ATM it seems like every plotting package (Makie, inspectdr, gadfly, and my main backend plotly) have a COMPLETELY different set of keybindings (or mousebindings I guess?), and when going a bit back and forth it is simply a pain in the butt. Thoughs on efforts to crowdsource “the superior set of keybindings”?

Changing the default keybindings.

Well, if it’s not too invasive, I can probably modify the built-in keybindings (ex: add a key you could use for box-zoom instead of needing the RMB).

Custom keybindings

If you are going to experiment for yourself, you can take a look at the InspectDR.keybindings global “const” (you can actually change the values even if it is “const” - this is a Julia thing).

Just take a look at src/gtk_input.jl.

The KeyBindings struct has Dict structures that hold the key maps.

  • nomod: When you aren’t holding down any “modifier” keys.
  • shiftmod: When you are holding down the SHIFT key.
  • ctrlmod: When you are holding down the CTRL key.
  • altmod: When you are holding down the ALT key.
function _setdefaults(bnd::KeyBindings)
	bnd.nomod = KeyMap(
		GdkKeySyms.Escape => setstate_normal,
		GdkKeySyms.Up => pan_up,
		GdkKeySyms.Down => pan_down,
[...More code here ...]

startup.jl

You could in theory overwrite these settings in your ~/.julia/config/startup.jl if you were willing to also run using InspectDR in there too.

I usually prefer that settings in startup.jl not need my module to be loaded, but I haven’t built that infrastructure yet. I only have it for defaults like x/y-axis notation (SI/ENG/SCI), fontname, fontsize, enable legend, … as described in:
InspectDR.jl/config.md at master · ma-laforge/InspectDR.jl · GitHub

InspectDR wrapper

To automate things for now, you could also just write a simple wrapper “package” that loads

using MyInspectDR
#using InspectDR #Call it "again" to get InspectDR symbols if you don't use Reexport.jl

MyInspectDR/src/MyInspectDR.jl:

module MyInspectDR
   using InspectDR
   kb = InspectDR.defaults.keybindings

   #Personalize kb here

   #You could probably make use of Reexport.jl
end
1 Like

Adapting box zoom to initiate on a keypress would require a bit of intervention on my part (I would need to add a few more functions). I don’t mind adding this feature: It sounds perfectly reasonable (Added complexity worth the added flexibilty).

The only problem is it might take me a few weeks to get to it.

Please let me know what you would like, and I’ll see what I can do.

1 Like

I am really impressed by your answers, both in terms of looks and quality/content ^-^

I want to put some real thought into a good set of keybindings, and I will get back once I feel like I have figured something out worth implementing. Thanks a lot for the openness to suggestion!

I also really appriciate the info about how to experiment myself. Preferably I would be able to create a PR instead of asking for someone else to implement my whishes.