MATLAB: How to set the text font style of a Data Cursor object

cursordatadatatipdefaultfontMATLABsetsize;text;tipweight

I have created a data cursor object on a plot. Is it possible to customize the font style, size, and/or weight for the text in the data cursor object?

Best Answer

You can customize the font style, size, or weight of the text in data cursors by using the following commands:
alldatacursors = findall(gcf,'type','hggroup')
set(alldatacursors,'FontSize',12)
set(alldatacursors,'FontName','Times')
set(alldatacursors, 'FontWeight', 'bold')
The options for 'FontWeight' are 'bold' or 'normal'. Please note that the text may appear to be the same weight for both 'bold' and 'normal' depending on the font chosen, as not all fonts have a bold weight.
You can find a list of available fonts by using the command;
listfonts
The ability to set specific default fonts for data cursors is not currently available. However, one can set the default styles and sizes for all plots. This can be done as follows:
set(0,'DefaultTextFontName','Script') % Sets Font Style
set(0,'DefaultTextFontSize',10) % Sets font size
This must be done before any figures are created or launched. A recommended place for this command is in the "startup.m" file.