MCPcopy Index your code
hub / github.com/spotify/chartify / text

Method text

chartify/_core/plot.py:456–528  ·  view source on GitHub ↗

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,
    )

Source from the content-addressed store, hash-verified

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

Callers 3

heatmapMethod · 0.45
textMethod · 0.45
text_stackedMethod · 0.45

Calls 7

ColorClass · 0.90
_get_settingsMethod · 0.80
get_hex_lMethod · 0.80
_get_color_and_orderMethod · 0.80
_cast_datetime_axisMethod · 0.80

Tested by

no test coverage detected