R2025b Figure datatips appearing below colorbars or other elements
Mostra commenti meno recenti
Hi all,
I recently upgraded from R2024a to R2025b, and I observed that the datatips are now displayed below other elements of the figures, such as colorbars or other figures when using subplots. Below is a comparison of the behavior in R2024a and R2025b for the same figure.
Is there a way to have the datatip always be at the front ? Or to keep using legacy figures of R2024a in Matlab R2025b ?
This is very important for me because I often edit the datatip content to contain additionnal information, which can result in big datatips and I want them to be over any other element of the figure.
R2024a

R2025b

3 Commenti
Mathieu NOE
il 21 Nov 2025
hello
seems this behaviour is new since R2025a :
here's Copilot answer to the problem (you can move on and ask him for a permanent fix if you want)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
In MATLAB R2025a, there was a graphics system update that changed how UI layers are managed, and this can cause data tips to appear behind a colorbar or other UI elements in some layouts.
This is due to changes in the stacking order (z-order) of annotations and axes children.
Fix: Bring Data Tips to the Front
You can manually adjust the stacking order so that the data tips are drawn above the colorbar.
Option 1 — Use uistack on the Data Tip
% Example plot
surf(peaks);
cb = colorbar;
% Create a data tip programmatically
dt = datatip(findobj(gca,'Type','Surface'), 25, 25);
% Bring the data tip to the top of the stacking order
uistack(dt,'top');
This works because datatip returns a graphics object that can be reordered.
Option 2 — Adjust Axes and Colorbar Layering
If the colorbar is blocking the data tip, you can make the axes (and its annotations) render on top:
ax = gca; ax.Layer = 'top'; % Ensures ticks, grid, and annotations are above plot elements
However, this alone may not fix all cases in R2025a, because the colorbar is now a separate axes object.
Option 3 — Move Colorbar Behind
You can push the colorbar to the back:
cb = colorbar; uistack(cb,'bottom');
This ensures the colorbar is drawn first, so data tips appear above it.
Option 4 — Use AnnotationLayer (New in R2025a)
R2025a introduced an annotation layer for better control:
dt = datatip(findobj(gca,'Type','Surface'), 25, 25);
dt.AnnotationLayer = 'front'; % Forces it above all other UI elements
(This property is new in R2025a — older versions will error.)
✅ Recommendation:
If you want interactive data tips to always appear above the colorbar, set:
h = datacursormode(gcf);
h.UpdateFcn = @(~,event) ''; % Keep default text drawnow; uistack(findall(gcf,'Type','DataTip'),'top');
and call it after creating the tip.
Thanks for chipping in @Mathieu NOE. Copilot is right about this changing in R2025a but the rest about stacking order is only partially correct. The z-order it's refering to via uistack is only helpful within a layer but there is a back & front layer component and other annotation layering behind the scenes that is coming into play here as well.
I'll share a workaround if I find one.
Alexis Fouineau
il 21 Nov 2025
Modificato: Alexis Fouineau
il 21 Nov 2025
Risposte (1)
Pull the data box to the left of the data tip anchor point, so that it won't overlap with the colorbar -

1 Commento
Alexis Fouineau
il 1 Dic 2025
Categorie
Scopri di più su Annotations in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!