class_docstr: Displays a legend used for describing the contents of a plot.
  
  LegendItems are most commonly created by calling :meth:`PlotItem.addLegend
  <pyqtgraph.PlotItem.addLegend>`.
  
  Note that this item should *not* be added directly to a PlotItem (via
  :meth:`PlotItem.addItem <pyqtgraph.PlotItem.addItem>`). Instead, make it a
  direct descendant of the PlotItem::
  
      legend.setParentItem(plotItem)
class_docstr_tok: ["Displays","a","legend","used","for","describing","the","contents","of","a","plot",".","LegendItems","are","most","commonly","created","by","calling",":","meth",":","`","PlotItem.addLegend","<","pyqtgraph.PlotItem.addLegend",">","`",".","Note","that","this","item","should","*","not","*","be","added","directly","to","a","PlotItem","(","via",":","meth",":","`","PlotItem.addItem","<","pyqtgraph.PlotItem.addItem",">","`",")",".","Instead",",","make","it","a","direct","descendant","of","the","PlotItem",":",":","legend.setParentItem","(","plotItem",")"]
docstr: ==============  ===============================================================
  **Arguments:**
  size            Specifies the fixed size (width, height) of the legend. If
                  this argument is omitted, the legend will automatically 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().
  horSpacing      Specifies the spacing between the line symbol and the label.
  verSpacing      Specifies the spacing between individual entries of the legend
                  vertically. (Can also be negative to have them really close)
  pen             Pen to use when drawing legend border. Any single argument
                  accepted by :func:`mkPen <pyqtgraph.mkPen>` is allowed.
  brush           QBrush to use as legend background filling. Any single argument
                  accepted by :func:`mkBrush <pyqtgraph.mkBrush>` is allowed.
  labelTextColor  Pen to use when drawing legend text. Any single argument
                  accepted by :func:`mkPen <pyqtgraph.mkPen>` is allowed.
  labelTextSize   Size to use when drawing legend text. Accepts CSS style
                  string arguments, e.g. '9pt'.
  colCount        Specifies the integer number of columns that the legend should
                  be divided into. The number of rows will be calculated
                  based on this argument. This is useful for plots with many
                  curves displayed simultaneously. Default: 1 column.
  sampleType      Customizes the item sample class of the `LegendItem`.
  ==============  ===============================================================
docstr_tok: ["==============","===============================================================","*","*","Arguments",":","*","*","size","Specifies","the","fixed","size","(","width",",","height",")","of","the","legend",".","If","this","argument","is","omitted",",","the","legend","will","automatically","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","(",")",".","horSpacing","Specifies","the","spacing","between","the","line","symbol","and","the","label",".","verSpacing","Specifies","the","spacing","between","individual","entries","of","the","legend","vertically",".","(","Can","also","be","negative","to","have","them","really","close",")","pen","Pen","to","use","when","drawing","legend","border",".","Any","single","argument","accepted","by",":","func",":","`","mkPen","<","pyqtgraph.mkPen",">","`","is","allowed",".","brush","QBrush","to","use","as","legend","background","filling",".","Any","single","argument","accepted","by",":","func",":","`","mkBrush","<","pyqtgraph.mkBrush",">","`","is","allowed",".","labelTextColor","Pen","to","use","when","drawing","legend","text",".","Any","single","argument","accepted","by",":","func",":","`","mkPen","<","pyqtgraph.mkPen",">","`","is","allowed",".","labelTextSize","Size","to","use","when","drawing","legend","text",".","Accepts","CSS","style","string","arguments",",","e.g",".","'9pt","'",".","colCount","Specifies","the","integer","number","of","columns","that","the","legend","should","be","divided","into",".","The","number","of","rows","will","be","calculated","based","on","this","argument",".","This","is","useful","for","plots","with","many","curves","displayed","simultaneously",".","Default",":","1","column",".","sampleType","Customizes","the","item","sample","class","of","the","`","LegendItem","`",".","==============","==============================================================="]
code: def __init__(
      self,
      size=None,
      offset=None,
      horSpacing=25,
      verSpacing=0,
      pen=None,
      brush=None,
      labelTextColor=None,
      frame=True,
      labelTextSize="9pt",
      colCount=1,
      sampleType=None,
      **kwargs,
  ):
      """
      ==============  ===============================================================
      **Arguments:**
      size            Specifies the fixed size (width, height) of the legend. If
                      this argument is omitted, the legend will automatically 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().
      horSpacing      Specifies the spacing between the line symbol and the label.
      verSpacing      Specifies the spacing between individual entries of the legend
                      vertically. (Can also be negative to have them really close)
      pen             Pen to use when drawing legend border. Any single argument
                      accepted by :func:`mkPen <pyqtgraph.mkPen>` is allowed.
      brush           QBrush to use as legend background filling. Any single argument
                      accepted by :func:`mkBrush <pyqtgraph.mkBrush>` is allowed.
      labelTextColor  Pen to use when drawing legend text. Any single argument
                      accepted by :func:`mkPen <pyqtgraph.mkPen>` is allowed.
      labelTextSize   Size to use when drawing legend text. Accepts CSS style
                      string arguments, e.g. '9pt'.
      colCount        Specifies the integer number of columns that the legend should
                      be divided into. The number of rows will be calculated
                      based on this argument. This is useful for plots with many
                      curves displayed simultaneously. Default: 1 column.
      sampleType      Customizes the item sample class of the `LegendItem`.
      ==============  ===============================================================
  
      """
      GraphicsWidget.__init__(self)
      GraphicsWidgetAnchor.__init__(self)
      self.setFlag(self.GraphicsItemFlag.ItemIgnoresTransformations)
      self.layout = QtWidgets.QGraphicsGridLayout()
      self.layout.setVerticalSpacing(verSpacing)
      self.layout.setHorizontalSpacing(horSpacing)
  
      self.setLayout(self.layout)
      self.items = []
      self.size = size
      self.offset = offset
      self.frame = frame
      self.columnCount = colCount
      self.rowCount = 1
      if size is not None:
          self.setGeometry(
              QtCore.QRectF(0, 0, self.size[0], self.size[1])
          )
  
      if sampleType is not None:
          if not issubclass(sampleType, GraphicsWidget):
              raise RuntimeError(
                  "Only classes of type `GraphicsWidgets` "
                  "are allowed as `sampleType`"
              )
          self.sampleType = sampleType
      else:
          self.sampleType = ItemSample
  
      self.opts = {
          "pen": fn.mkPen(pen),
          "brush": fn.mkBrush(brush),
          "labelTextColor": labelTextColor,
          "labelTextSize": labelTextSize,
          "offset": offset,
      }
      self.opts.update(kwargs)
  
imports: import math
  from ..None import functions
  from ..icons import invisibleEye
  from ..Point import Point
  from ..Qt import QtCore, QtGui, QtWidgets
  from .BarGraphItem import BarGraphItem
  from .GraphicsWidget import GraphicsWidget
  from .GraphicsWidgetAnchor import GraphicsWidgetAnchor
  from .LabelItem import LabelItem
  from .PlotDataItem import PlotDataItem
  from .ScatterPlotItem import ScatterPlotItem, drawSymbol
label_desc: Use image node_id 1 to create a new LegendItem object from inherited base classes: GraphicsWidgetAnchor, GraphicsWidget with example: obj = LegendItem(size, offset, horSpacing, verSpacing, pen, brush, labelTextColor, frame, labelTextSize, colCount, sampleType)