How to add more information to plot help-box?

5 次查看(过去 30 天)
You know that little help-box which shows up when you mouse over a data point in a plot and tells you its coodinates? I noticed that with scatter plots the box also displays the size of the point, so I was wondering if there's a way to make it show other data. I have a plot with several lines, each with a corresponding number, and I want to be able to tell which line has which number. I'd rather not use colors and a legend since I'm already using color as a distinguishing feature. I also thought of giving each line a z-value corresponding to the number I care about, but that seems both annoying to implement and has the issue of forcing a single stacking order, when I need to be able to choose which line is on top. Hence my question about if it's possible to manipulate what shows up in the help-box.
Thanks in advance!

采纳的回答

Walter Roberson
Walter Roberson 2023-10-29
See datacursormode for the more general function.
In the particular case of what MATLAB refers to as "chart objects" (which it does not define to users), there is a completely different mechanism available which is introduced at https://www.mathworks.com/help/matlab/creating_plots/create-custom-data-tips.html "Examples of objects with a DataTipTemplate property include Line, Histogram, Surface, and FunctionLine objects."
(An example of something that does not have DataTipTemplate is a patch() object)

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Annotations 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by