Customizing Data Cursor marker Matlab

2019-07-19 01:49发布

问题:

Is there any possibility to change marker form and size for data cursor in Matlab? I mean it is black and square by default. I would like to change it to blue and circle, for example.
I've found only how to customize text of data tips.

Thank you.

回答1:

Yes - marker options are included in the properties of the undocumented graphics.datatip object class.

These objects are accessible as hidden properties of the graphics.datacursormanager objects accessible through the documented datacursormode function. The .DataCursors property contains an array of these objects for each Data Cursor in the figure and .CurrentDataCursor property contains the object for the current one.

To take your example, to change the marker for the current Data Cursor of the current figure to a blue circle, you can do as follows:

dcm_obj = datacursormode(gcf);
set(dcm_obj.CurrentDataCursor, 'Marker','o', 'MarkerFaceColor','b');

More detailed information about the undocumented functionality can be found at http://undocumentedmatlab.com/blog/controlling-plot-data-tips



回答2:

Hope this helps..... For white background and classic look....

  • alldatacursors = findall(gcf,'type','hggroup')
  • set(alldatacursors,'FontSize',11)

  • set(alldatacursors,'FontName','Times')

  • set(alldatacursors,'BackgroundColor','w');



回答3:

yes it is possible by set Pointer property of figure to custom and then set the value for PointerShapeCData as per your choice but you can't change to RGB color format. Because PointerShapeCData property accept value 1 and 2. value 1 means black and 2 means white.

for example :

a = zeros(16,16);   % create matrix with size of 16 X 16 with value zero
a(:,:) = 1;         % assign all element value of matrix a to 1.
figure('Pointer','custom ','PointerShapeCData',a); 

% change some element value of a variable as 2 for change black to white.

a(:,1) = 2;         
 a(:,3) = 2;
 a(:,7) = 2;
 figure('Pointer','custom ','PointerShapeCData',a);


标签: matlab cursor