Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable data tips by default

In recent Matlab versions (I am using R2024b), when you hover or click on a line plotted on some axes it produces a data tip, which is a rectangle indicating the numerical values at that point.

I would like to disable data tips on all axes by default. For existing axes, it is enough to call the function disableDefaultInteractivity with those axes as input. But then, this would have to be done for every new axes. Is there a way to cause all axes to have data tips disabled by default?

I thought there would be some default property value in groot for this, but I can't find it. This answer suggests using the axes' CreateFcn property to call disableDefaultInteractivity, but that approach does not seem to work, at least not in all Matlab versions (see comments to that answer; it definitely does not work in R2024b).

like image 721
Luis Mendo Avatar asked Sep 14 '26 06:09

Luis Mendo


1 Answers

I found a method that works for me in R2024b:

set(groot , 'defaultAxesCreateFcn' , 'set(gca, ''Interactions'', [])')

The code sets a groot property such that, by default, all created axes have 'set(gca, ''Interactions'', [])' as their CreateFcn. This means that, immediately after the axes have been created, their 'Interactions' property is set to []. This gets rid of the data tip interaction, as well as other interactions (which I currently don't care about).

Including this code in the startup.m file ensures that it is run when Matlab starts.

The documentation pages that helped me come up with this are:

  • CartesianAxesInteractionOptions Properties.
  • Control chart interactivity.

Judging from the information on those pages, this approach may not work for some Matlab versions. I tested that it works in R2024b and in R2025b.

like image 125
Luis Mendo Avatar answered Sep 17 '26 11:09

Luis Mendo