Text plot. Args: data_frame (pandas.DataFrame): Data source for the plot. x_column (str): Column name to plot on the x axis. y_column (str): Column name to plot on the y axis. text_column (str): Column name to plot as text labels.
(
self,
data_frame,
x_column,
y_column,
text_column,
color_column=None,
color_order=None,
font_size="1em",
x_offset=0,
y_offset=0,
angle=0,
text_color=None,
)
| 454 | return self._chart |
| 455 | |
| 456 | def text( |
| 457 | self, |
| 458 | data_frame, |
| 459 | x_column, |
| 460 | y_column, |
| 461 | text_column, |
| 462 | color_column=None, |
| 463 | color_order=None, |
| 464 | font_size="1em", |
| 465 | x_offset=0, |
| 466 | y_offset=0, |
| 467 | angle=0, |
| 468 | text_color=None, |
| 469 | ): |
| 470 | """Text plot. |
| 471 | |
| 472 | Args: |
| 473 | data_frame (pandas.DataFrame): Data source for the plot. |
| 474 | x_column (str): Column name to plot on the x axis. |
| 475 | y_column (str): Column name to plot on the y axis. |
| 476 | text_column (str): Column name to plot as text labels. |
| 477 | color_column (str, optional): Column name to group by on the |
| 478 | color dimension. |
| 479 | color_order (list, optional): List of values within the |
| 480 | 'color_column' for specific sorting of the colors. |
| 481 | font_size (str, optional): Size of text. |
| 482 | x_offset (int, optional): # of pixels for horizontal text offset. |
| 483 | Can be negative. Default: 0. |
| 484 | y_offset (int, optional): # of pixels for vertical text offset. |
| 485 | Can be negative. Default: 0. |
| 486 | angle (int): Degrees from horizontal for text rotation. |
| 487 | text_color (str): Color name or hex value. |
| 488 | See chartify.color_palettes.show() for available color names. |
| 489 | If omitted, will default to the next color in the |
| 490 | current color palette. |
| 491 | """ |
| 492 | text_font = self._chart.style._get_settings("text_callout_and_plot")["font"] |
| 493 | if text_color: |
| 494 | text_color = Color(text_color).get_hex_l() |
| 495 | colors, color_values = [text_color], [None] |
| 496 | else: |
| 497 | colors, color_values = self._get_color_and_order(data_frame, color_column, color_order) |
| 498 | |
| 499 | self._set_numeric_axis_default_format(data_frame, x_column, y_column) |
| 500 | |
| 501 | for color_value, color in zip(color_values, colors): |
| 502 | if color_column is None: # Single series |
| 503 | sliced_data = data_frame |
| 504 | else: |
| 505 | sliced_data = data_frame[data_frame[color_column] == color_value] |
| 506 | # Filter to only relevant columns. |
| 507 | sliced_data = sliced_data[ |
| 508 | [col for col in sliced_data.columns if col in (x_column, y_column, text_column, color_column)] |
| 509 | ] |
| 510 | cast_data = self._cast_datetime_axis(sliced_data, x_column) |
| 511 | |
| 512 | source = self._named_column_data_source(cast_data, series_name=color_value) |
| 513 |
no test coverage detected