Usage¶
To use chartify in a project:
import chartify
Chart¶
- class chartify.Chart(blank_labels=False, layout='slide_100%', x_axis_type='linear', y_axis_type='linear', second_y_axis=False)[source]¶
Class Docstring
Styling (.style)
Plotting (.plot)
Callouts (.callout)
Axes (.axes)
Bokeh figure (.figure)
- property data¶
Return a list of dictionaries of the data that have be plotted on the chart.
- Note:
The format will depend on the types of plots that have been added.
- property legend_location¶
str: Legend location.
- save(filename, format='html')[source]¶
Save the chart.
- Args:
filename (str): Name of output file. format (str):
- ‘html’: Output chart as HTML.
Renders faster and allows for interactivity. Charts saved as HTML in a Jupyter notebook WILL NOT display on Github. Logos will not display on HTML charts. Recommended when drafting plots.
- ‘png’: Output chart as PNG.
Easy to paste into google slides. Recommended when the plot is in a finished state. Will render logos.
‘svg’: Output as SVG.
- set_legend_location(location, orientation='horizontal')[source]¶
Set the legend location.
- Args:
location (str or tuple): Legend location. One of: - Outside of the chart: ‘outside_top’, ‘outside_bottom’,
‘outside_right’
- Within the chart area: ‘top_left’, ‘top_center’,
‘top_right’, ‘center_left’, ‘center’, ‘center_right’, ‘bottom_left’, ‘bottom_center’, ‘bottom_right’
Coordinates: Tuple(Float, Float)
None: Removes the legend.
orientation (str): ‘horizontal’ or ‘vertical’
- Returns:
Current chart object
- set_source_label(source)[source]¶
Set the chart data source.
- Args:
source (str): Data source.
- Returns:
Current chart object
- set_subtitle(subtitle)[source]¶
Set the chart subtitle.
- Args:
subtitle (str): Subtitle text.
- Note:
Set value to “” to remove subtitle.
- Returns:
Current chart object
- set_title(title)[source]¶
Set the chart title.
- Args:
title (str): Title text.
- Returns:
Current chart object
- show(format='html')[source]¶
Show the chart.
- Args:
- format (str):
- ‘html’: Output chart as HTML.
Renders faster and allows for interactivity. Charts saved as HTML in a Jupyter notebooks WILL NOT display on Github. Logos will not display on HTML charts. Recommended when drafting plots.
- ‘png’: Output chart as PNG.
Easy to copy+paste into slides. Will render logos. Recommended when the plot is in a finished state.
‘svg’: Output as SVG.
- property source_text¶
str: Data source of the chart.
- property subtitle¶
str: Subtitle text of the chart.
- property title¶
str: Title text of the chart.
Plot¶
- class chartify._core.plot.PlotCategoricalXY(chart, y_range_name='default')[source]¶
Plot functions for categorical x & y axes:
- Methods:
heatmap
- heatmap(data_frame, x_column, y_column, color_column, text_column=None, color_palette='RdBu', reverse_color_order=False, text_color='white', text_format='{:,.2f}', color_value_min=None, color_value_max=None, color_value_range=100)[source]¶
Heatmap.
- 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. color_column (str): Column name of numerical type to plot on
the color dimension.
text_column (str or None): Column name of the text labels. color_palette (str, chartify.ColorPalette): Color palette to
apply to the heatmap. See chartify.color_palettes.show() for available color palettes.
reverse_color_order (bool): Reverse order of the color palette. text_color (str): Color name or hex value.
See chartify.color_palettes.show() for available color names.
text_format: Python string formatting to apply to the text labels. color_value_min (float): Minimum value for the color palette.
If None, will default to the min value of the color_column dimension.
- color_value_max (float): Maximum value for the color palette.
If None, will default to the max value of the color_column dimension.
- color_value_range (int): The size of the range of colors in
the color palette. A larger color range will result in greater variation among the cell colors.
- class chartify._core.plot.PlotNumericXY(chart, y_range_name='default')[source]¶
Plot functions for numeric x & y axes:
- Methods:
line
scatter
text
area
- area(data_frame, x_column, y_column, second_y_column=None, color_column=None, color_order=None, stacked=False)[source]¶
Area plot.
- Note:
- When a single y_column is passed: Shade area between the
y_values and zero.
Use stacked argument for stacked areas.
- When both y_column and second_y_column are passed:
Shade area between the two y_columns.
- 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. second_y_column (str, optional): Column name to plot on
the y axis.
- color_column (str, optional): Column name to group by on
the color dimension.
- color_order (list, optional): List of values within the
‘color_column’ for specific sorting of the colors.
- stacked (bool, optional): Stacked the areas.
Only applicable with a single y_column. Default: False.
- line(data_frame, x_column, y_column, color_column=None, color_order=None, line_dash='solid', line_width=4, alpha=1.0)[source]¶
Line Chart.
- Note:
This method will not automatically sort the x-axis. Try sorting the axis if the line graph looks strange.
- 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. color_column (str, optional): Column name to group by on
the color dimension.
- color_order (list, optional): List of values within the
‘color_column’ for specific sorting of the colors.
- line_dash (str, optional): Dash style for the line. One of:
‘solid’
‘dashed’
‘dotted’
‘dotdash’
‘dashdot’
line_width (int, optional): Width of the line alpha (float): Alpha value.
- scatter(data_frame, x_column, y_column, size_column=None, color_column=None, color_order=None, alpha=1.0, marker='circle')[source]¶
Scatter 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. size_column (str, optional): Column name of numerical values
to plot on the size dimension.
- color_column (str, optional): Column name to group by on
the color dimension.
- color_order (list, optional): List of values within the
‘color_column’ for specific sorting of the colors.
alpha (float): Alpha value. marker (str): marker type. Valid types:
‘asterisk’, ‘circle’, ‘circle_cross’, ‘circle_x’, ‘cross’, ‘diamond’, ‘diamond_cross’, ‘hex’, ‘inverted_triangle’, ‘square’, ‘square_x’, ‘square_cross’, ‘triangle’, ‘x’, ‘*’, ‘+’, ‘o’, ‘ox’, ‘o+’
- text(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]¶
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. color_column (str, optional): Column name to group by on the
color dimension.
- color_order (list, optional): List of values within the
‘color_column’ for specific sorting of the colors.
font_size (str, optional): Size of text. x_offset (int, optional): # of pixels for horizontal text offset.
Can be negative. Default: 0.
- y_offset (int, optional): # of pixels for vertical text offset.
Can be negative. Default: 0.
angle (int): Degrees from horizontal for text rotation. text_color (str): Color name or hex value.
See chartify.color_palettes.show() for available color names. If omitted, will default to the next color in the current color palette.
- class chartify._core.plot.PlotNumericDensityXY(chart, y_range_name='default')[source]¶
Plot functions for single density:
- Methods:
histogram
kde
- histogram(data_frame, values_column, color_column=None, color_order=None, method='count', bins='auto')[source]¶
Histogram.
- Args:
data_frame (pandas.DataFrame): Data source for the plot. values_column (str): Column of numeric values. color_column (str, optional): Column name to group by on
the color dimension.
- color_order (list, optional): List of values within the
‘color_column’ for specific sorting of the colors.
method (str, optional): - ‘count’: Result will contain the number of samples at each bin. - ‘density’: Result is the value of the probability density
function at each bin. The PDF is normalized so that the integral over the range is 1.
- ‘mass’: Result is the value of the probability mass
function at each bin. The PMF is normalized so that the value is equivalent to the sample count at each bin divided by the total count.
- bins (int or sequence of scalars or str, optional):
If bins is an int, it defines the number of equal-width bins in the given range. If bins is a sequence, it defines the bin edges, including the rightmost edge, allowing for non-uniform bin widths. See numpy.histogram documentation for more details.
- ‘auto’:
Maximum of the ‘sturges’ and ‘fd’ estimators. Provides good all around performance.
- ‘fd’ (Freedman Diaconis Estimator)
Robust (resilient to outliers) estimator that takes into account data variability and data size.
- ‘doane’
An improved version of Sturges’ estimator that works better with non-normal datasets.
- ‘scott’
Less robust estimator that that takes into account data variability and data size.
- ‘rice’
Estimator does not take variability into account, only data size. Commonly overestimates number of bins required.
- ‘sturges’
R’s default method, only accounts for data size. Only optimal for gaussian data and underestimates number of bins for large non-gaussian datasets.
- ‘sqrt’
Square root (of data size) estimator, used by Excel and other programs for its speed and simplicity.
- kde(data_frame, values_column, color_column=None, color_order=None)[source]¶
Kernel Density Estimate Plot.
- Args:
data_frame (pandas.DataFrame): Data source for the plot. values_column (str): Column of numeric values. color_column (str, optional): Column name to group by on
the color dimension.
- color_order (list, optional): List of values within the
‘color_column’ for specific sorting of the colors.
- class chartify._core.plot.PlotDensityXY(chart, y_range_name='default')[source]¶
Plot functions for denxity X & Y:
- Methods:
hexbin
- hexbin(data_frame, x_values_column, y_values_column, size, color_palette='Blues', reverse_color_order=False, orientation='pointytop', color_value_range=10)[source]¶
Hexbin.
- Args:
data_frame (pandas.DataFrame): Data source for the plot. x_values_column (str): Column of numeric values to bin into tiles. y_values_column (str): Column of numeric values to bin into tiles. size (float): Bin size for the tiles. color_palette (str, chartify.ColorPalette): Color palette to
apply to the tiles. See chartify.color_palettes.show() for available color palettes.
reverse_color_order (bool): Reverse order of the color palette. orientation (str): “pointytop” or “flattop”. Whether the hexagonal
tiles should be oriented with a pointed corner on top, or a flat side on top.
- color_value_range (int): The size of the range of colors in
the color palette. A larger color range will result in greater variation among the cell colors.
- class chartify._core.plot.PlotMixedTypeXY(chart, y_range_name='default')[source]¶
Plot functions for mixed type x & y axes:
- Methods:
bar
bar_stacked
lollipop
parallel
- bar(data_frame, categorical_columns, numeric_column, color_column=None, color_order=None, categorical_order_by='values', categorical_order_ascending=False)[source]¶
Bar chart.
- Note:
To change the orientation set x_axis_type or y_axis_type argument of the Chart object.
- Args:
data_frame (pandas.DataFrame): Data source for the plot. categorical_columns (str or list): Column name to plot on
the categorical axis.
numeric_column (str): Column name to plot on the numerical axis. color_column (str, optional): Column name to group by on
the color dimension.
- color_order (list, optional): List of values within the
‘color_column’ for specific color sort.
- categorical_order_by (str or array-like, optional):
Dimension for ordering the categorical axis. Default ‘values’. - ‘values’: Order categorical axis by the numerical
axis values. Default.
‘labels’: Order categorical axis by the categorical labels.
- array-like object (list, tuple, np.array): New labels
to conform the categorical axis to.
- categorical_order_ascending (bool, optional): Sort order of the
categorical axis. Default False.
- bar_stacked(data_frame, categorical_columns, numeric_column, stack_column, normalize=False, stack_order=None, categorical_order_by='values', categorical_order_ascending=False)[source]¶
Plot stacked bar chart.
- Note:
To change the orientation set x_axis_type or y_axis_type
argument of the Chart object. - Stacked numeric values must be all positive or all negative. To plot both positive and negative values on the same chart call this method twice. Once for the positive values and once for the negative values.
- Args:
data_frame (pandas.DataFrame): Data source for the plot. categorical_columns (str or list): Column name to plot on
the categorical axis.
numeric_column (str): Column name to plot on the numerical axis. stack_column (str): Column name to group by on the stack dimension. normalize (bool, optional): Normalize numeric dimension for
100% stacked bars. Default False.
- stack_order (list, optional): List of values within the
‘stack_column’ dimension for specific stack sort.
- categorical_order_by (str or array-like, optional):
Dimension for ordering the categorical axis. Default ‘values’. - ‘values’: Order categorical axis by the numerical
axis values. Default.
‘labels’: Order categorical axis by the categorical labels.
- array-like object (list, tuple, np.array): New labels
to conform the categorical axis to.
- categorical_order_ascending (bool, optional): Sort order
of the categorical axis. Default False.
- boxplot(data_frame, categorical_columns, numeric_column, color_column=None, color_order=None, categorical_order_by='labels', categorical_order_ascending=True, outlier_marker='circle', outlier_color='black', outlier_alpha=0.3, outlier_size=15)[source]¶
Box-and-whisker plot.
- Note:
To change the orientation set x_axis_type or y_axis_type argument of the Chart object.
- Args:
data_frame (pandas.DataFrame): Data source for the plot. categorical_columns (str or list): Column name to plot on
the categorical axis.
numeric_column (str): Column name to plot on the numerical axis. color_column (str, optional): Column name to group by on
the color dimension.
- color_order (list, optional):
- List of values within the ‘color_column’ for
specific color sort.
- categorical_order_by (str or array-like, optional):
Dimension for ordering the categorical axis. Default ‘labels’. - ‘labels’: Order categorical axis by the categorical labels. - array-like object (list, tuple, np.array): New labels
to conform the categorical axis to.
- categorical_order_ascending (bool, optional):
Sort order of the categorical axis. Default True.
- outlier_marker (str, optional): Outlier marker type. Valid types:
‘asterisk’, ‘circle’, ‘circle_cross’, ‘circle_x’, ‘cross’, ‘diamond’, ‘diamond_cross’, ‘hex’, ‘inverted_triangle’, ‘square’, ‘square_x’, ‘square_cross’, ‘triangle’, ‘x’, ‘*’, ‘+’, ‘o’, ‘ox’, ‘o+’ Default ‘circle’
- outlier_color (str, optional): Color name or hex value.
See chartify.color_palettes.show() for available color names. Default ‘black’
outlier_alpha (float, optional): Alpha value. Default 0.3 outlier_size (float, optional): Size of outlier markers.
Default 15
- interval(data_frame, categorical_columns, lower_bound_column, upper_bound_column, middle_column=None, categorical_order_by='values', categorical_order_ascending=False, color='black')[source]¶
Interval.
- Args:
data_frame (pandas.DataFrame): Data source for the plot. categorical_columns (str or list): Column name to plot on
the categorical axis.
- lower_bound_column (str): Column name to plot on the
numerical axis for the lower bound.
- upper_bound_column (str): Column name to plot on the
numerical axis for the upper bound.
- middle_column (str, optional): Column name to plot on the
numerical axis for the middle tick.
- categorical_order_by (str or array-like, optional):
Dimension for ordering the categorical axis. Default ‘values’. - ‘values’: Order categorical axis by the numerical
axis values. Default.
‘labels’: Order categorical axis by the categorical labels.
- array-like object (list, tuple, np.array): New labels
to conform the categorical axis to.
- categorical_order_ascending (bool, optional): Sort order of the
categorical axis. Default False.
- color (str): Color name or hex value.
See chartify.color_palettes.show() for available color names.
- lollipop(data_frame, categorical_columns, numeric_column, color_column=None, color_order=None, categorical_order_by='values', categorical_order_ascending=False)[source]¶
Lollipop chart.
- Note:
To change the orientation set x_axis_type or y_axis_type argument of the Chart object.
- Args:
data_frame (pandas.DataFrame): Data source for the plot. categorical_columns (str or list): Column name to plot on
the categorical axis.
numeric_column (str): Column name to plot on the numerical axis. color_column (str, optional): Column name to group by on
the color dimension.
- color_order (list, optional):
- List of values within the ‘color_column’ for
specific color sort.
- categorical_order_by (str or array-like, optional):
Dimension for ordering the categorical axis. Default ‘values’. - ‘values’: Order categorical axis by the numerical axis values. - ‘labels’: Order categorical axis by the categorical labels. - array-like object (list, tuple, np.array): New labels
to conform the categorical axis to.
- categorical_order_ascending (bool, optional):
Sort order of the categorical axis. Default False.
- parallel(data_frame, categorical_columns, numeric_column, color_column=None, color_order=None, categorical_order_by='values', categorical_order_ascending=False, line_dash='solid', line_width=4, alpha=1.0)[source]¶
Parallel coordinate plot.
- Args:
data_frame (pandas.DataFrame): Data source for the plot. categorical_columns (str or list): Column name to plot on
the categorical axis.
numeric_column (str): Column name to plot on the numerical axis. color_column (str, optional): Column name to group by on
the color dimension.
- color_order (list, optional): List of values within the
‘color_column’ for specific color sort.
- categorical_order_by (str or array-like, optional):
Dimension for ordering the categorical axis. Default ‘values’. - ‘values’: Order categorical axis by the numerical axis values. - ‘labels’: Order categorical axis by the categorical labels. - array-like object (list, tuple, np.array): New labels
to conform the categorical axis to.
- categorical_order_ascending (bool, optional):
Sort order of the categorical axis. Default False.
- line_dash (str, optional): Dash style for the line. One of:
‘solid’
‘dashed’
‘dotted’
‘dotdash’
‘dashdot’
line_width (int, optional): Width of the line alpha (float): Alpha value
- scatter(data_frame, categorical_columns, numeric_column, size_column=None, color_column=None, color_order=None, categorical_order_by='count', categorical_order_ascending=False, alpha=1.0, marker='circle')[source]¶
Scatter chart.
- Note:
To change the orientation set x_axis_type or y_axis_type argument of the Chart object.
- Args:
data_frame (pandas.DataFrame): Data source for the plot. categorical_columns (str or list): Column name to plot on
the categorical axis.
numeric_column (str): Column name to plot on the numerical axis. size_column (str, optional): Column name of numerical values
to plot on the size dimension.
- color_column (str, optional): Column name to group by on
the color dimension.
- color_order (list, optional):
- List of values within the ‘color_column’ for
specific color sort.
- categorical_order_by (str or array-like, optional):
Dimension for ordering the categorical axis. Default ‘count’. - ‘count’: Order categorical axis by the count of values. - ‘labels’: Order categorical axis by the categorical labels. - array-like object (list, tuple, np.array): New labels
to conform the categorical axis to.
- categorical_order_ascending (bool, optional):
Sort order of the categorical axis. Default False.
alpha (float): Alpha value. marker (str): marker type. Valid types:
‘asterisk’, ‘circle’, ‘circle_cross’, ‘circle_x’, ‘cross’, ‘diamond’, ‘diamond_cross’, ‘hex’, ‘inverted_triangle’, ‘square’, ‘square_x’, ‘square_cross’, ‘triangle’, ‘x’, ‘*’, ‘+’, ‘o’, ‘ox’, ‘o+’
- text(data_frame, categorical_columns, numeric_column, text_column, color_column=None, color_order=None, categorical_order_by='values', categorical_order_ascending=False, font_size='1em', x_offset=0, y_offset=0, angle=0, text_color=None)[source]¶
Text plot.
- Args:
data_frame (pandas.DataFrame): Data source for the plot. categorical_columns (str or list): Column name to plot on
the categorical axis.
numeric_column (str): Column name to plot on the numerical axis. text_column (str): Column name to plot as text labels. color_column (str, optional): Column name to group by on the
color dimension.
- color_order (list, optional): List of values within the
‘color_column’ for specific color sort.
- categorical_order_by (str or array-like, optional):
Dimension for ordering the categorical axis. Default ‘values’. - ‘values’: Order categorical axis by the numerical axis
values. Default.
‘labels’: Order categorical axis by the categorical labels.
- array-like object (list, tuple, np.array): New labels
to conform the categorical axis to.
- categorical_order_ascending (bool, optional): Sort order of the
categorical axis. Default False.
font_size (str, optional): Size of text. x_offset (int, optional): # of pixels for horizontal text offset.
Can be negative. Default: 0.
- y_offset (int, optional): # of pixels for vertical text offset.
Can be negative. Default: 0.
angle (int): Degrees from horizontal for text rotation. text_color (str): Color name or hex value.
See chartify.color_palettes.show() for available color names. If omitted, will default to the next color in the current color palette.
- text_stacked(data_frame, categorical_columns, numeric_column, stack_column, text_column, normalize=False, stack_order=None, categorical_order_by='values', categorical_order_ascending=False, font_size='1em', x_offset=0, y_offset=0, angle=0, text_color=None)[source]¶
Text plot for use with stacked plots.
- Args:
data_frame (pandas.DataFrame): Data source for the plot. categorical_columns (str or list): Column name to plot on
the categorical axis.
numeric_column (str): Column name to plot on the numerical axis. text_column (str): Column name to plot as text labels.
Note: Null text values will be omitted from the plot.
stack_column (str): Column name to group by on the stack dimension. normalize (bool, optional): Normalize numeric dimension for
100% stacked bars. Default False.
- stack_order (list, optional): List of values within the
‘stack_column’ dimension for specific stack sort.
- categorical_order_by (str or array-like, optional):
Dimension for ordering the categorical axis. Default ‘values’. - ‘values’: Order categorical axis by the numerical
axis values. Default.
‘labels’: Order categorical axis by the categorical labels.
- array-like object (list, tuple, np.array): New labels
to conform the categorical axis to.
- categorical_order_ascending (bool, optional): Sort order of the
categorical axis. Default False.
font_size (str, optional): Size of text. x_offset (int, optional): # of pixels for horizontal text offset.
Can be negative. Default: 0.
- y_offset (int, optional): # of pixels for vertical text offset.
Can be negative. Default: 0.
angle (int): Degrees from horizontal for text rotation. text_color (str): Color name or hex value.
See chartify.color_palettes.show() for available color names. If omitted, will default to the next color in the current color palette.
Axes¶
Module for logic related to chart axes.
- class chartify._core.axes.BaseAxes(chart)[source]¶
Base class for axes.
- hide_xaxis()[source]¶
Hide the tick labels, ticks, and axis lines of the x-axis.
The x-axis label will remain visible, but can be removed with .axes.set_xaxis_label(“”)
- set_xaxis_label(label)[source]¶
Set x-axis label text.
- Args:
label (string): the text for the x-axis label
- Returns:
Current chart object
- set_xaxis_tick_orientation(orientation='horizontal')[source]¶
Change the orientation or the x axis tick labels.
- Args:
- orientation (str or list of str):
str: ‘horizontal’, ‘vertical’, or ‘diagonal’ list of str: different orientation values corresponding to each level of the grouping. Example: [‘horizontal’, ‘vertical’]
- property xaxis_label¶
Return x-axis label.
- Returns:
x-axis label text
- class chartify._core.axes.CategoricalXYAxes(chart)[source]¶
Axis class for categorical X and Y axes.
- class chartify._core.axes.DatetimeXNumericalYAxes(chart)[source]¶
Axis class for datetime X and numerical Y axes.
- class chartify._core.axes.NumericalXAxis(chart)[source]¶
Axis class for numerical X and categorical Y axes
Callout¶
- class chartify._core.callout.Callout(chart)[source]¶
Class for adding callouts to the chart.
- box(top=None, bottom=None, left=None, right=None, alpha=0.2, color='red')[source]¶
Add box callout to the chart.
- Args:
top (numeric, optional): Top edge of the box. bottom (numeric, optional): Bottom edge of the box. left (numeric, optional): Left edge of the box. right (numeric, optional): Right edge of the box. alpha (float, optional): 0.2 color (str): Color name or hex value.
See chartify.color_palettes.show() for available color names.
- Note:
The box will extend to the edge if the corresponding position argument is omitted.
- Returns:
Current chart object
- line(location, orientation='width', line_color='black', line_dash='solid', line_width=2, line_alpha=1.0)[source]¶
Add line callout to the chart.
- Args:
location (numeric): orientation (str, optional): (default: ‘width’)
‘width’
‘height’
- line_color (str, optional): Color name or hex value.
See chartify.color_palettes.show() for available color names.
- line_dash (str, optional): Dash style for the line. One of:
‘solid’
‘dashed’
‘dotted’
‘dotdash’
‘dashdot’
line_width (int, optional): Width of the line line_alpha (float, optional): Alpha of the line. Between 0 and 1.
- Returns:
Current chart object
- line_segment(x_start, y_start, x_end, y_end, line_color='black', line_dash='solid', line_width=2, line_alpha=1.0)[source]¶
Add line segment callout to the chart.
- Args:
x_start (numeric) y_start (numeric) x_end (numeric) y_end (numeric) line_color (str): Color name or hex value.
See chartify.color_palettes.show() for available color names.
- line_dash (str, optional): Dash style for the line. One of:
‘solid’
‘dashed’
‘dotted’
‘dotdash’
‘dashdot’
line_width (int, optional): Width of the line line_alpha (float, optional): Alpha of the line. Between 0 and 1.
- Returns:
Current chart object
- text(text, x, y, text_color='black', text_align='left', font_size='1em', angle=0)[source]¶
Add text callout to the chart.
- Note:
Use `
- ` within text for newlines.
- Args:
x (numeric): x location of the text. y (numeric, optional): y location of the text. text_color (str): Color name or hex value.
See chartify.color_palettes.show() for available color names.
text_align (str: ‘left’, ‘right’, ‘center’): Text alignment. font_size (str): Font size. angle (int, 0 to 360): Angle in degrees from horizontal. Default: 0
- Returns:
Current chart object
Options¶
- class chartify._core.options.ChartifyOptions[source]¶
-
- set_option(option_name, option_value)[source]¶
Set the default value of the specified option.
- Available options:
- ‘style.color_palette_categorical’: (str)
Color palette for categorical palette types.
- ‘style.color_palette_sequential’: (str)
Color palette for sequential palette types.
- ‘style.color_palette_diverging’: (str)
Color palette for diverging palette types.
- ‘style.color_palette_accent’: (str)
Color palette for assigning color to specific values.
- ‘style.color_palette_accent_default_color’: (str)
- Default color of values in the ‘color_column’ that
are not accented.
Default: ‘light grey’
- ‘chart.blank_labels’: boolean
- If False, chartify.Chart objects populate the default
chart labels with helper text.
Default: False
Style¶
- class chartify._core.style.Style(chart, layout)[source]¶
Contains attributes and methods for modifying the aesthetic style of the chart.
- set_color_palette(palette_type, palette=None, accent_values=None)[source]¶
- Args:
- palette_type:
- ‘categorical’: Use when the color dimension
has no meaningful order.
- ‘sequential’: Use when the color dimension
has a sequential order.
‘diverging’
- ‘accent’: Use to assign color to specific
values in the color dimension.
- palette (color palette name, ColorPalette object, or list of colors)
See chartify.color_palettes.show() for palette & color names. Default: ‘Spotify Palette’
accent_values (list or dict): List of values that should be accented or dictionary of ‘value’: ‘color’ pairs.
Only applies to ‘accent’ palette type.