Return a string representation of *data*. .. note:: This method is intended to be overridden by artist subclasses. As an end-user of Matplotlib you will most likely not call this method yourself. The default implementation converts ints
(self, data)
| 1411 | return None |
| 1412 | |
| 1413 | def format_cursor_data(self, data): |
| 1414 | """ |
| 1415 | Return a string representation of *data*. |
| 1416 | |
| 1417 | .. note:: |
| 1418 | This method is intended to be overridden by artist subclasses. |
| 1419 | As an end-user of Matplotlib you will most likely not call this |
| 1420 | method yourself. |
| 1421 | |
| 1422 | The default implementation converts ints and floats and arrays of ints |
| 1423 | and floats into a comma-separated string enclosed in square brackets, |
| 1424 | unless the artist has an associated colorbar, in which case scalar |
| 1425 | values are formatted using the colorbar's formatter. |
| 1426 | |
| 1427 | See Also |
| 1428 | -------- |
| 1429 | get_cursor_data |
| 1430 | """ |
| 1431 | if np.ndim(data) == 0 and hasattr(self, "_format_cursor_data_override"): |
| 1432 | # workaround for ScalarMappable to be able to define its own |
| 1433 | # format_cursor_data(). See ScalarMappable._format_cursor_data_override |
| 1434 | # for details. |
| 1435 | return self._format_cursor_data_override(data) |
| 1436 | else: |
| 1437 | try: |
| 1438 | data[0] |
| 1439 | except (TypeError, IndexError): |
| 1440 | data = [data] |
| 1441 | data_str = ', '.join(f'{item:0.3g}' for item in data |
| 1442 | if isinstance(item, Number)) |
| 1443 | return "[" + data_str + "]" |
| 1444 | |
| 1445 | def get_mouseover(self): |
| 1446 | """ |