LegendItem

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:

legend.setParentItem(plotItem)
__init__(size=None, offset=None)[source]
Arguments:  
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.

Arguments:  
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.
removeItem(name)[source]

Removes one item from the legend.

Arguments:  
title The title displayed for this item.