BarChart

class qf_lib.plotting.charts.bar_chart.BarChart(orientation: qf_lib.common.enums.orientation.Orientation, stacked: bool = True, index_translator: qf_lib.plotting.helpers.index_translator.IndexTranslator = None, thickness: float = 0.8, start_x: Any = None, end_x: Any = None, upper_y: float = None, lower_y: float = None, **plot_settings)[source]

Bases: qf_lib.plotting.charts.chart.Chart

Creates a new bar chart with the specified orientation.

Parameters
  • orientation (Orientation) – The orientation of the bar chart, either Horizontal or Vertical.

  • stacked (bool) – default: True; if True then bars corresponding to different DataElementDecorators will be stacked. Otherwise bars will be plotted next to each other.

  • index_translator (IndexTranslator) – the mapper of index coordinates (e.g. you may use labels as index in a pandas series and this translator will ensure that it is plotted correctly)

  • thickness (float) – how thick should each bar be (expressed in numeric data coordinates system)

  • start_x (datetime.datetime) – The date where the x-axis should begin.

  • end_x (datetime.datetime) – The date where the x-axis should end.

  • upper_y (float) – The upper bound of the y-axis.

  • lower_y (float) – The lower bound of the y-axis.

  • plot_settings – Keyword arguments to pass to the plot function.

Methods

apply_data_element_decorators(…)

Plots all DataElementDecorators added to a chart.

plot(figsize, float] = None)

Plots the chart.

apply_data_element_decorators(data_element_decorators: List[qf_lib.plotting.decorators.data_element_decorator.DataElementDecorator]) → Any[source]

Plots all DataElementDecorators added to a chart. This function should set legend_artist field in each plotted DataElementDecorator (if applicable).

Parameters

data_element_decorators (List[DataElementDecorator]) – non-empty list of DataElementDecorators that should be plotted on the chart

plot(figsize: Tuple[float, float] = None)[source]

Plots the chart. The underlying figure stays hidden until the show() method is called.

Parameters

figsize (Tuple[float, float]) – The figure size to draw the chart at in inches. This is a tuple of (width, height) passed directly to matplotlib’s plot function. The values are expressed in inches.