class pyqtgraph.LegendItem(size=None, offset=None)[source]

Displays a legend used for describing the contents of a plot. LegendItems are most commonly created by calling PlotItem.addLegend().

Note that this item should not be added directly to a PlotItem. Instead, Make it a direct descendant of the PlotItem:

__init__(size=None, offset=None)[source]
size Specifies the fixed size (width, height) of the legend. If this argument is omitted, the legend will autimatically resize to fit its contents.
offset Specifies the offset position relative to the legend’s parent. Positive values offset from the left or top; negative values offset from the right or bottom. If offset is None, the legend must be anchored manually by calling anchor() or positioned by calling setPos().
addItem(item, name)[source]

Add a new entry to the legend.

item A PlotDataItem from which the line and point style of the item will be determined or an instance of ItemSample (or a subclass), allowing the item display to be customized.
title The title to display for this item. Simple HTML allowed.

Removes one item from the legend.

item The item to remove or its name.