CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
plotting.PlotText Class Reference

Public Member Functions

def __init__ (self, x, y, text, size=None, bold=True, align="left", color=ROOT.kBlack, font=None)
 
def Draw (self, options=None)
 

Private Attributes

 _l
 
 _text
 
 _x
 
 _y
 

Detailed Description

Abstraction on top of TLatex

Definition at line 1529 of file plotting.py.

Constructor & Destructor Documentation

def plotting.PlotText.__init__ (   self,
  x,
  y,
  text,
  size = None,
  bold = True,
  align = "left",
  color = ROOT.kBlack,
  font = None 
)
Constructor.

Arguments:
x     -- X coordinate of the text (in NDC)
y     -- Y coordinate of the text (in NDC)
text  -- String to draw
size  -- Size of text (None for the default value, taken from gStyle)
bold  -- Should the text be bold?
align -- Alignment of text (left, center, right)
color -- Color of the text
font  -- Specify font explicitly

Definition at line 1531 of file plotting.py.

1531  def __init__(self, x, y, text, size=None, bold=True, align="left", color=ROOT.kBlack, font=None):
1532  """Constructor.
1533 
1534  Arguments:
1535  x -- X coordinate of the text (in NDC)
1536  y -- Y coordinate of the text (in NDC)
1537  text -- String to draw
1538  size -- Size of text (None for the default value, taken from gStyle)
1539  bold -- Should the text be bold?
1540  align -- Alignment of text (left, center, right)
1541  color -- Color of the text
1542  font -- Specify font explicitly
1543  """
1544  self._x = x
1545  self._y = y
1546  self._text = text
1547 
1548  self._l = ROOT.TLatex()
1549  self._l.SetNDC()
1550  if not bold:
1551  self._l.SetTextFont(self._l.GetTextFont()-20) # bold -> normal
1552  if font is not None:
1553  self._l.SetTextFont(font)
1554  if size is not None:
1555  self._l.SetTextSize(size)
1556  if isinstance(align, str):
1557  if align.lower() == "left":
1558  self._l.SetTextAlign(11)
1559  elif align.lower() == "center":
1560  self._l.SetTextAlign(21)
1561  elif align.lower() == "right":
1562  self._l.SetTextAlign(31)
1563  else:
1564  raise Exception("Error: Invalid option '%s' for text alignment! Options are: 'left', 'center', 'right'."%align)
1565  else:
1566  self._l.SetTextAlign(align)
1567  self._l.SetTextColor(color)
1568 
def __init__(self, x, y, text, size=None, bold=True, align="left", color=ROOT.kBlack, font=None)
Definition: plotting.py:1531

Member Function Documentation

def plotting.PlotText.Draw (   self,
  options = None 
)
Draw the text to the current TPad.

Arguments:
options -- For interface compatibility, ignored

Provides interface compatible with ROOT's drawable objects.

Definition at line 1569 of file plotting.py.

References Vispa.Gui.VispaWidget.TextField._text, plotting.PlotText._text, PGeometricDet::Item._x, SpecificationBuilder_cfi.Specification._x, hitfit::Fourvec_Event._x, plotting.PlotText._x, PGeometricDet::Item._y, contrib::CMSBoostedTauSeedingAlgorithmStructure._y, SpecificationBuilder_cfi.Specification._y, and plotting.PlotText._y.

1569  def Draw(self, options=None):
1570  """Draw the text to the current TPad.
1571 
1572  Arguments:
1573  options -- For interface compatibility, ignored
1574 
1575  Provides interface compatible with ROOT's drawable objects.
1576  """
1577  self._l.DrawLatex(self._x, self._y, self._text)
1578 
1579 
def Draw(self, options=None)
Definition: plotting.py:1569

Member Data Documentation

plotting.PlotText._l
private

Definition at line 1548 of file plotting.py.

plotting.PlotText._text
private

Definition at line 1546 of file plotting.py.

Referenced by plotting.PlotText.Draw().

plotting.PlotText._x
private

Definition at line 1544 of file plotting.py.

Referenced by plotting.PlotText.Draw().

plotting.PlotText._y
private

Definition at line 1545 of file plotting.py.

Referenced by plotting.PlotText.Draw().