LegendDecorator
- class qf_lib.plotting.decorators.legend_decorator.LegendDecorator(legend_placement: Location = Location.BEST, key: Optional[str] = None)[source]
Bases:
ChartDecorator
A decorator which draws a legend on the graph. The legend titles are automatically determined based on what was specified during decorator creation and series addition.
- Parameters:
legend_placement (Location) – where the legend should be placed on the chart
key (str) – the identifier of the decorator
Methods:
add_entry
(item, label)Adds new entry to the legend.
decorate
(chart)Modifies the axes object taken from the chart (e.g.
decorate_html
(chart, chart_id)Constructs code to decorate an existing web chart.
- add_entry(item: SimpleLegendItem, label: str) None [source]
Adds new entry to the legend.
- Parameters:
item (SimpleLegendItem) – a decorator which should be described in the legend or the matplotlib’s Artist object
label (str) – a label which should be assigned to a given decorator
- decorate(chart: Chart) None [source]
Modifies the axes object taken from the chart (e.g. adds legend, draws cone, etc.).
- decorate_html(chart: Chart, chart_id: str) str [source]
Constructs code to decorate an existing web chart.
- Parameters:
chart (Chart) –
chart_id (str) – A string identifying the specific chart. For the web, the <div> that represents this chart will typically use this as its id.
- Returns:
JavaScript code that is called before the underlying chart is initialised. The code can modify the pre-defined options variable.
- Return type:
str