Data Cursor Position Issue
5 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I have a number of bar charts in a figure window and each has the datacursormode enabled. When I click on a bar with a negative value, a y position of 0 is returned. It seems to work fine for bars of positive values so I'm somewhat perplexed.
2 comentarios
Richard
el 20 de Jun. de 2011
A simple example ( bar(-5:5) ) works OK for me. Do you have some code that reproduces the problem? Also, which version are you using?
Respuesta aceptada
Richard
el 3 de Ag. de 2011
Conor, sorry for the delay, I didn't notice your comment until today.
This is a bug in older versions of MATLAB. I can see the issue in v7.4 for a simple bar chart with a standard data cursor:
bar(-5:5)
For all of the bars, the data cursor is being placed at the maximum Y value instead of at the maximum absolute Y value, and for negative bars this is always 0 instead of being -5, -4, -3 etc. This incorrect value is also passed into your custom datatip function. There is no easy way to directly get the correct Y (RDI) value, however you could look up the X (Radii) value in the target's XData and then use the corresponding YData value:
xd = get(T, 'XData');
[~,idx] = min(abs(xd-P(1)));
yd = get(T, 'YData');
ThisRDI = yd(idx);
This bug has been fixed in a more recent version of MATLAB - I believe from R2008b onwards, so upgrading is another option.
Más respuestas (0)
Ver también
Categorías
Más información sobre Annotations en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!