CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Classes | Functions | Variables
svgfig Namespace Reference

Classes

class  Axes
 
class  Curve
 
class  CurveAxis
 
class  Dots
 
class  Ellipse
 
class  Fig
 
class  Frame
 
class  Grid
 
class  HGrid
 
class  HLine
 
class  Line
 
class  LineAxis
 
class  LineGlobal
 
class  Path
 
class  Plot
 
class  Poly
 
class  Rect
 
class  SVG
 
class  Text
 
class  TextGlobal
 
class  Ticks
 
class  VGrid
 
class  VLine
 
class  XAxis
 
class  XErrorBars
 
class  YAxis
 
class  YErrorBars
 

Functions

def attr_preprocess
 
def canvas
 
def canvas_outline
 
def funcRtoC
 
def funcRtoR
 
def funcRtoR2
 
def load
 
def load_stream
 
def make_marker
 
def make_symbol
 
def pathtoPath
 
def rgb
 
def rotate
 
def template
 
def totrans
 
def unumber
 
def window
 

Variables

dictionary _canvas_defaults
 
tuple _circular_dot = make_symbol("circular_dot")
 
tuple _default_directory
 
string _default_fileName = "tmp.svg"
 
int _epsilon = 1
 
dictionary _hacks = {}
 
dictionary _marker_templates
 
dictionary _symbol_templates
 
 all_whitespace
 
 output
 
 stack
 

Function Documentation

def svgfig.attr_preprocess (   attr)

Definition at line 47 of file svgfig.py.

Referenced by make_marker(), and make_symbol().

47 
48 def attr_preprocess(attr):
49  for name in attr.keys():
50  name_colon = re.sub("__", ":", name)
51  if name_colon != name:
52  attr[name_colon] = attr[name]
53  del attr[name]
54  name = name_colon
55 
56  name_dash = re.sub("_", "-", name)
57  if name_dash != name:
58  attr[name_dash] = attr[name]
59  del attr[name]
60  name = name_dash
61 
62  return attr
def attr_preprocess
Definition: svgfig.py:47
def svgfig.canvas (   sub,
  attr 
)
Creates a top-level SVG object, allowing the user to control the
image size and aspect ratio.

canvas(sub, sub, sub..., attribute=value)

sub                     optional list       nested SVG elements or text/Unicode
attribute=value pairs   optional keywords   SVG attributes

Default attribute values:

width           "400px"
height          "400px"
viewBox         "0 0 100 100"
xmlns           "http://www.w3.org/2000/svg"
xmlns:xlink     "http://www.w3.org/1999/xlink"
version         "1.1"
style           "stroke:black; fill:none; stroke-width:0.5pt; stroke-linejoin:round; text-anchor:middle"
font-family     "Helvetica,Arial,FreeSans?,Sans,sans,sans-serif"

Definition at line 482 of file svgfig.py.

Referenced by canvas_outline(), DD4hep_TrackingMaterialPlotter.draw(), TrackingMaterialPlotter.draw(), HcalObjRepresent::ADataRepr.draw(), DTOccupancyClusterBuilder.drawClusters(), ErrorsAnalyzer.drawHistograms(), ErrorsPropagationAnalyzer.drawHistograms(), TauDQMHistPlotter.endRun(), templateHelper::SiPixelTitles_Display< PayloadType, StoreType, TransientType >.fill(), templateHelper::SiPixelHeaderTable< PayloadType, StoreType, TransientType >.fill(), BeamSpotPI::DisplayParameters< PayloadType >.fill(), gainCalibHelper::SiPixelGainCalibrationValues< myType, PayloadType >.fill(), templateHelper::SiPixelIDs< PayloadType, myType >.fill(), gainCalibHelper::SiPixelGainCalibrationValuesPerRegion< isBarrel, myType, PayloadType >.fill(), templateHelper::SiPixelFullPixelIDMap< PayloadType, StoreType, TransientType >.fill(), gainCalibHelper::SiPixelGainCalibrationValuesComparisonPerRegion< isBarrel, myType, nIOVs, ntags, PayloadType >.fill(), gainCalibHelper::SiPixelGainCalibrationCorrelations< PayloadType >.fill(), gainCalibHelper::SiPixelGainCalibrationValuesByPart< myType, PayloadType >.fill(), gainCalibHelper::SiPixelGainCalibrationValueComparisonBase< myType, PayloadType >.fill(), gainCalibHelper::SiPixelGainCalibDiffAndRatioBase< myType, nIOVs, ntags, PayloadType >.fill(), gainCalibHelper::SiPixelGainCalibrationMap< myType, PayloadType, myDetType >.fill(), gainCalibHelper::SiPixelGainCalibrationByRegionComparisonBase< myType, PayloadType, nIOVs, ntags >.fill(), EcalDisplaysByEvent.init2DEcalCanvas(), main(), SiStripHistoPlotter.makeCondDBPlots(), TagProbeFitter.makeEfficiencyPlot1D(), TagProbeFitter.makeEfficiencyPlot2D(), SiStripHistoPlotter.makePlot(), MuScleFitUtils.minimizeLikelihood(), root.plotTF1(), DD4hep_ListGroups.produceAndSaveSummaryPlot(), ListGroups.produceAndSaveSummaryPlot(), SoftLeptonTagPlotter.psPlot(), TrackCountingTagPlotter.psPlot(), TrackProbabilityTagPlotter.psPlot(), IPTagPlotter< Container, Base >.psPlot(), JetTagPlotter.psPlot(), TagProbeFitter.saveDistributionsPlot(), TagProbeFitter.saveFitPlot(), PatternOptimizerBase.savePatternsInRoot(), DD4hep_MaterialAccountingGroup.savePlot(), MaterialAccountingGroup.savePlot(), svgfig.SVG.standalone_xml(), tfwliteselectortest::ThingsTSelector.terminate(), tfwliteselectortest::ThingsTSelector2.terminate(), __class__< T >.terminate(), HFunctionResolution.Write(), HCovarianceVSxy.Write(), PPSAlignmentHarvester.writeCutPlot(), TestCorrection.~TestCorrection(), and TestResolution.~TestResolution().

483 def canvas(*sub, **attr):
484  """Creates a top-level SVG object, allowing the user to control the
485  image size and aspect ratio.
486 
487  canvas(sub, sub, sub..., attribute=value)
488 
489  sub optional list nested SVG elements or text/Unicode
490  attribute=value pairs optional keywords SVG attributes
491 
492  Default attribute values:
493 
494  width "400px"
495  height "400px"
496  viewBox "0 0 100 100"
497  xmlns "http://www.w3.org/2000/svg"
498  xmlns:xlink "http://www.w3.org/1999/xlink"
499  version "1.1"
500  style "stroke:black; fill:none; stroke-width:0.5pt; stroke-linejoin:round; text-anchor:middle"
501  font-family "Helvetica,Arial,FreeSans?,Sans,sans,sans-serif"
502  """
503  attributes = dict(_canvas_defaults)
504  attributes.update(attr)
505 
506  if sub == None or sub == ():
507  return SVG("svg", **attributes)
508  else:
509  return SVG("svg", *sub, **attributes)
def canvas
Definition: svgfig.py:482
def svgfig.canvas_outline (   sub,
  attr 
)
Same as canvas(), but draws an outline around the drawable area,
so that you know how close your image is to the edges.

Definition at line 510 of file svgfig.py.

References canvas().

511 def canvas_outline(*sub, **attr):
512  """Same as canvas(), but draws an outline around the drawable area,
513  so that you know how close your image is to the edges."""
514  svg = canvas(*sub, **attr)
515  match = re.match("[, \t]*([0-9e.+\-]+)[, \t]+([0-9e.+\-]+)[, \t]+([0-9e.+\-]+)[, \t]+([0-9e.+\-]+)[, \t]*", svg["viewBox"])
516  if match == None: raise ValueError("canvas viewBox is incorrectly formatted")
517  x, y, width, height = [float(x) for x in match.groups()]
518  svg.prepend(SVG("rect", x=x, y=y, width=width, height=height, stroke="none", fill="cornsilk"))
519  svg.append(SVG("rect", x=x, y=y, width=width, height=height, stroke="black", fill="none"))
520  return svg
def canvas_outline
Definition: svgfig.py:510
def canvas
Definition: svgfig.py:482
def svgfig.funcRtoC (   expr,
  var = "t",
  globals = None,
  locals = None 
)
Converts a complex "z(t)" string to a function acceptable for Curve.

expr    required        string in the form "z(t)"
var     default="t"   name of the independent variable
globals default=None    dict of global variables used in the expression;
                        you may want to use Python's builtin globals()
locals  default=None    dict of local variables

Definition at line 1452 of file svgfig.py.

References output, and submitPVValidationJobs.split().

1453 def funcRtoC(expr, var="t", globals=None, locals=None):
1454  """Converts a complex "z(t)" string to a function acceptable for Curve.
1455 
1456  expr required string in the form "z(t)"
1457  var default="t" name of the independent variable
1458  globals default=None dict of global variables used in the expression;
1459  you may want to use Python's builtin globals()
1460  locals default=None dict of local variables
1461  """
1462  g = cmath.__dict__
1463  if globals != None: g.update(globals)
1464  output = eval("lambda %s: (%s)" % (var, expr), g, locals)
1465  split = lambda z: (z.real, z.imag)
1466  output2 = lambda t: split(output(t))
1467  output2.__name__ = "%s -> %s" % (var, expr)
1468  return output2
def funcRtoC
Definition: svgfig.py:1452
output
Definition: svgfig.py:560
def svgfig.funcRtoR (   expr,
  var = "x",
  globals = None,
  locals = None 
)
Converts a "f(x)" string to a function acceptable for Curve.

expr    required        string in the form "f(x)"
var     default="x"   name of the independent variable
globals default=None    dict of global variables used in the expression;
                        you may want to use Python's builtin globals()
locals  default=None    dict of local variables

Definition at line 1484 of file svgfig.py.

1485 def funcRtoR(expr, var="x", globals=None, locals=None):
1486  """Converts a "f(x)" string to a function acceptable for Curve.
1487 
1488  expr required string in the form "f(x)"
1489  var default="x" name of the independent variable
1490  globals default=None dict of global variables used in the expression;
1491  you may want to use Python's builtin globals()
1492  locals default=None dict of local variables
1493  """
1494  g = math.__dict__
1495  if globals != None: g.update(globals)
1496  output = eval("lambda %s: (%s, %s)" % (var, var, expr), g, locals)
1497  output.__name__ = "%s -> %s" % (var, expr)
1498  return output
def funcRtoR
Definition: svgfig.py:1484
def svgfig.funcRtoR2 (   expr,
  var = "t",
  globals = None,
  locals = None 
)
Converts a "f(t), g(t)" string to a function acceptable for Curve.

expr    required        string in the form "f(t), g(t)"
var     default="t"   name of the independent variable
globals default=None    dict of global variables used in the expression;
                        you may want to use Python's builtin globals()
locals  default=None    dict of local variables

Definition at line 1469 of file svgfig.py.

Referenced by svgfig.Curve.Path().

1470 def funcRtoR2(expr, var="t", globals=None, locals=None):
1471  """Converts a "f(t), g(t)" string to a function acceptable for Curve.
1472 
1473  expr required string in the form "f(t), g(t)"
1474  var default="t" name of the independent variable
1475  globals default=None dict of global variables used in the expression;
1476  you may want to use Python's builtin globals()
1477  locals default=None dict of local variables
1478  """
1479  g = math.__dict__
1480  if globals != None: g.update(globals)
1481  output = eval("lambda %s: (%s)" % (var, expr), g, locals)
1482  output.__name__ = "%s -> %s" % (var, expr)
1483  return output
def funcRtoR2
Definition: svgfig.py:1469
def svgfig.load (   fileName)
Loads an SVG image from a file.

Definition at line 547 of file svgfig.py.

References mergeVDriftHistosByStation.file, and load_stream().

Referenced by l1t::MP7BufferDumpToRaw.formatAMC(), FWPartialConfigLoadGUI.FWPartialConfigLoadGUI(), FedRawDataInputSource.nextEvent(), l1t::stage1::EtSumPacker.pack(), l1t::stage1::MissEtPacker.pack(), l1t::stage1::CaloSpareHFPacker.pack(), l1t::stage1::MissHtPacker.pack(), l1t::stage2::GlobalExtBlkPacker.pack(), l1t::stage1::RCTEmRegionPacker.pack(), l1t::stage1::HFRingPacker.pack(), l1t::stage2::CaloTowerPacker.pack(), l1t::stage2::GlobalAlgBlkPacker.pack(), l1t::stage2::EtSumPacker.pack(), l1t::stage2::CaloLayer1Packer.pack(), dqmservices::DQMStreamerReader.prepareNextFile(), process(), l1t::L1TDigiToRaw.produce(), L1MuBMExtrapolationUnit.run(), L1MuDTExtrapolationUnit.run(), utils.unpickler.run(), and template().

548 def load(fileName):
549  """Loads an SVG image from a file."""
550  return load_stream(file(fileName))
def load_stream
Definition: svgfig.py:551
def load
Definition: svgfig.py:547
def svgfig.load_stream (   stream)
Loads an SVG image from a stream (can be a string or a file object).

Definition at line 551 of file svgfig.py.

References submitPVValidationJobs.__init__().

Referenced by load().

552 def load_stream(stream):
553  """Loads an SVG image from a stream (can be a string or a file object)."""
554 
555  from xml.sax import handler, make_parser
556  from xml.sax.handler import feature_namespaces, feature_external_ges, feature_external_pes
557 
558  class ContentHandler(handler.ContentHandler):
559  def __init__(self):
560  self.stack = []
561  self.output = None
562  self.all_whitespace = re.compile("^\s*$")
563 
564  def startElement(self, name, attr):
565  s = SVG(name)
566  s.attr = dict(attr.items())
567  if len(self.stack) > 0:
568  last = self.stack[-1]
569  last.sub.append(s)
570  self.stack.append(s)
571 
572  def characters(self, ch):
573  if not isinstance(ch, str) or self.all_whitespace.match(ch) == None:
574  if len(self.stack) > 0:
575  last = self.stack[-1]
576  if len(last.sub) > 0 and isinstance(last.sub[-1], str):
577  last.sub[-1] = last.sub[-1] + "\n" + ch
578  else:
579  last.sub.append(ch)
580 
581  def endElement(self, name):
582  if len(self.stack) > 0:
583  last = self.stack[-1]
584  if isinstance(last, SVG) and last.t == "style" and "type" in last.attr and last.attr["type"] == "text/css" and len(last.sub) == 1 and isinstance(last.sub[0], str):
585  last.sub[0] = "<![CDATA[\n" + last.sub[0] + "]]>"
586 
587  self.output = self.stack.pop()
588 
589  ch = ContentHandler()
590  parser = make_parser()
591  parser.setContentHandler(ch)
592  parser.setFeature(feature_namespaces, 0)
593  parser.setFeature(feature_external_ges, 0)
594  parser.parse(stream)
595  return ch.output
def load_stream
Definition: svgfig.py:551
def svgfig.make_marker (   id,
  shape,
  attr 
)
Creates a new instance of an SVG marker to avoid cross-linking objects.

id                     required         a new identifier (string/Unicode)
shape                  required         the shape name from _marker_templates
attribute=value list   keyword list     modify the SVG attributes of the new marker

Definition at line 1965 of file svgfig.py.

References attr_preprocess().

Referenced by svgfig.Line.SVG(), and svgfig.LineGlobal.SVG().

1966 def make_marker(id, shape, **attr):
1967  """Creates a new instance of an SVG marker to avoid cross-linking objects.
1968 
1969  id required a new identifier (string/Unicode)
1970  shape required the shape name from _marker_templates
1971  attribute=value list keyword list modify the SVG attributes of the new marker
1972  """
1973  output = copy.deepcopy(_marker_templates[shape])
1974  for i in output.sub: i.attr.update(attr_preprocess(attr))
1975  output["id"] = id
1976  return output
def make_marker
Definition: svgfig.py:1965
def attr_preprocess
Definition: svgfig.py:47
def svgfig.make_symbol (   id,
  shape = "dot",
  attr 
)
Creates a new instance of an SVG symbol to avoid cross-linking objects.

id                    required         a new identifier (string/Unicode)
shape                 default="dot"  the shape name from _symbol_templates
attribute=value list  keyword list     modify the SVG attributes of the new symbol

Definition at line 1894 of file svgfig.py.

References attr_preprocess().

1895 def make_symbol(id, shape="dot", **attr):
1896  """Creates a new instance of an SVG symbol to avoid cross-linking objects.
1897 
1898  id required a new identifier (string/Unicode)
1899  shape default="dot" the shape name from _symbol_templates
1900  attribute=value list keyword list modify the SVG attributes of the new symbol
1901  """
1902  output = copy.deepcopy(_symbol_templates[shape])
1903  for i in output.sub: i.attr.update(attr_preprocess(attr))
1904  output["id"] = id
1905  return output
def make_symbol
Definition: svgfig.py:1894
def attr_preprocess
Definition: svgfig.py:47
def svgfig.pathtoPath (   svg)
Converts SVG("path", d="...") into Path(d=[...]).

Definition at line 1007 of file svgfig.py.

References str.

Referenced by geometryDiffVisualization.draw_disk().

1008 def pathtoPath(svg):
1009  """Converts SVG("path", d="...") into Path(d=[...])."""
1010  if not isinstance(svg, SVG) or svg.t != "path":
1011  raise TypeError("Only SVG <path /> objects can be converted into Paths")
1012  attr = dict(svg.attr)
1013  d = attr["d"]
1014  del attr["d"]
1015  for key in attr.keys():
1016  if not isinstance(key, str):
1017  value = attr[key]
1018  del attr[key]
1019  attr[str(key)] = value
1020  return Path(d, **attr)
def pathtoPath
Definition: svgfig.py:1007
#define str(s)
def svgfig.rgb (   r,
  g,
  b,
  maximum = 1. 
)
Create an SVG color string "#xxyyzz" from r, g, and b.

r,g,b = 0 is black and r,g,b = maximum is white.

Definition at line 40 of file svgfig.py.

References SiStripPI.max, and min().

Referenced by cert_plot(), geometryDiffVisualization.csc_colors(), geometryDiffVisualization.dt_colors(), and RunInfoPI.reportSummaryMapPalette().

40 
41 def rgb(r, g, b, maximum=1.):
42  """Create an SVG color string "#xxyyzz" from r, g, and b.
43 
44  r,g,b = 0 is black and r,g,b = maximum is white.
45  """
46  return "#%02x%02x%02x" % (max(0, min(r*255./maximum, 255)), max(0, min(g*255./maximum, 255)), max(0, min(b*255./maximum, 255)))
def rgb
Definition: svgfig.py:40
T min(T a, T b)
Definition: MathUtil.h:58
def svgfig.rotate (   angle,
  cx = 0,
  cy = 0 
)
Creates and returns a coordinate transformation which rotates
around (cx,cy) by "angle" degrees.

Definition at line 705 of file svgfig.py.

Referenced by magneticfield::bLayer.bLayer(), magneticfield::MagGeoBuilder.build(), MagGeoBuilderFromDDD.build(), CmsTrackerPhase1DiskBuilder< FilteredView >.PhiPosNegSplit_innerOuter(), and CmsTrackerPhase2TPDiskBuilder< FilteredView >.PhiPosNegSplit_innerOuter().

706 def rotate(angle, cx=0, cy=0):
707  """Creates and returns a coordinate transformation which rotates
708  around (cx,cy) by "angle" degrees."""
709  angle *= math.pi/180.
710  return lambda x, y: (cx + math.cos(angle)*(x - cx) - math.sin(angle)*(y - cy), cy + math.sin(angle)*(x - cx) + math.cos(angle)*(y - cy))
def rotate
Definition: svgfig.py:705
def svgfig.template (   fileName,
  svg,
  replaceme = "REPLACEME" 
)
Loads an SVG image from a file, replacing instances of
<REPLACEME /> with a given svg object.

fileName         required                name of the template SVG
svg              required                SVG object for replacement
replaceme        default="REPLACEME"   fake SVG element to be replaced by the given object

>>> print load("template.svg")
None                 <svg (2 sub) style=u'stroke:black; fill:none; stroke-width:0.5pt; stroke-linejoi
[0]                      <rect height=u'100' width=u'100' stroke=u'none' y=u'0' x=u'0' fill=u'yellow'
[1]                      <REPLACEME />
>>> 
>>> print template("template.svg", SVG("circle", cx=50, cy=50, r=30))
None                 <svg (2 sub) style=u'stroke:black; fill:none; stroke-width:0.5pt; stroke-linejoi
[0]                      <rect height=u'100' width=u'100' stroke=u'none' y=u'0' x=u'0' fill=u'yellow'
[1]                      <circle cy=50 cx=50 r=30 />

Definition at line 521 of file svgfig.py.

References load().

Referenced by CAHitNtupletGeneratorKernels< TTraits >.allocateOnGPU(), dd_error_scan(), GenericMVAComputer.eval(), reco::modules::ParameterAdapter< S >.fillPSetDescription(), findNameSpaces(), edm::eventsetup::DependentRecordImplementation< EcalMappingRcd, edm::mpl::Vector< EcalMappingElectronicsRcd > >.get(), edm::eventsetup::DependentRecordImplementation< EcalMappingRcd, edm::mpl::Vector< EcalMappingElectronicsRcd > >.getHandle(), edm::eventsetup::DependentRecordImplementation< EcalMappingRcd, edm::mpl::Vector< EcalMappingElectronicsRcd > >.getRecord(), edm::refitem::GetRefPtrImpl< C, T, F, KEY >.getRefPtr_(), edm::refitem::GetRefPtrImpl< C, T, F, unsigned int >.getRefPtr_(), edm::eventsetup::DependentRecordImplementation< EcalMappingRcd, edm::mpl::Vector< EcalMappingElectronicsRcd > >.getTransientHandle(), HeterogeneousSoAImpl< T, Traits >.HeterogeneousSoAImpl(), edm::WorkerMaker< T >.makeModule(), edm::RefProd< T >.operator*(), edm::RefProd< T >.operator->(), TrackingRecHit2DHeterogeneous< Traits >.TrackingRecHit2DHeterogeneous(), and edm::eventsetup::DependentRecordImplementation< EcalMappingRcd, edm::mpl::Vector< EcalMappingElectronicsRcd > >.tryToGetRecord().

522 def template(fileName, svg, replaceme="REPLACEME"):
523  """Loads an SVG image from a file, replacing instances of
524  <REPLACEME /> with a given svg object.
525 
526  fileName required name of the template SVG
527  svg required SVG object for replacement
528  replaceme default="REPLACEME" fake SVG element to be replaced by the given object
529 
530  >>> print load("template.svg")
531  None <svg (2 sub) style=u'stroke:black; fill:none; stroke-width:0.5pt; stroke-linejoi
532  [0] <rect height=u'100' width=u'100' stroke=u'none' y=u'0' x=u'0' fill=u'yellow'
533  [1] <REPLACEME />
534  >>>
535  >>> print template("template.svg", SVG("circle", cx=50, cy=50, r=30))
536  None <svg (2 sub) style=u'stroke:black; fill:none; stroke-width:0.5pt; stroke-linejoi
537  [0] <rect height=u'100' width=u'100' stroke=u'none' y=u'0' x=u'0' fill=u'yellow'
538  [1] <circle cy=50 cx=50 r=30 />
539  """
540  output = load(fileName)
541  for ti, s in output:
542  if isinstance(s, SVG) and s.t == replaceme:
543  output[ti] = svg
544  return output
def load
Definition: svgfig.py:547
def template
Definition: svgfig.py:521
def svgfig.totrans (   expr,
  vars = ("x", "y",
  globals = None,
  locals = None 
)
Converts to a coordinate transformation (a function that accepts
two arguments and returns two values).

expr       required                  a string expression or a function
                                     of two real or one complex value
vars       default=("x", "y")    independent variable names;
                                     a singleton ("z",) is interpreted
                                     as complex
globals    default=None              dict of global variables
locals     default=None              dict of local variables

Definition at line 598 of file svgfig.py.

References output, and submitPVValidationJobs.split().

Referenced by svgfig.Ticks.orient_tickmark(), svgfig.Curve.Path(), svgfig.Poly.Path(), svgfig.Fig.SVG(), svgfig.Plot.SVG(), svgfig.Path.SVG(), svgfig.Text.SVG(), svgfig.Dots.SVG(), svgfig.LineGlobal.SVG(), svgfig.Ticks.SVG(), svgfig.XErrorBars.SVG(), and svgfig.YErrorBars.SVG().

599 def totrans(expr, vars=("x", "y"), globals=None, locals=None):
600  """Converts to a coordinate transformation (a function that accepts
601  two arguments and returns two values).
602 
603  expr required a string expression or a function
604  of two real or one complex value
605  vars default=("x", "y") independent variable names;
606  a singleton ("z",) is interpreted
607  as complex
608  globals default=None dict of global variables
609  locals default=None dict of local variables
610  """
611 
612  if callable(expr):
613  if expr.__code__.co_argcount == 2:
614  return expr
615 
616  elif expr.__code__.co_argcount == 1:
617  split = lambda z: (z.real, z.imag)
618  output = lambda x, y: split(expr(x + y*1j))
619  output.__name__ = expr.__name__
620  return output
621 
622  else:
623  raise TypeError("must be a function of 2 or 1 variables")
624 
625  if len(vars) == 2:
626  g = math.__dict__
627  if globals != None: g.update(globals)
628  output = eval("lambda %s, %s: (%s)" % (vars[0], vars[1], expr), g, locals)
629  output.__name__ = "%s,%s -> %s" % (vars[0], vars[1], expr)
630  return output
631 
632  elif len(vars) == 1:
633  g = cmath.__dict__
634  if globals != None: g.update(globals)
635  output = eval("lambda %s: (%s)" % (vars[0], expr), g, locals)
636  split = lambda z: (z.real, z.imag)
637  output2 = lambda x, y: split(output(x + y*1j))
638  output2.__name__ = "%s -> %s" % (vars[0], expr)
639  return output2
640 
641  else:
642  raise TypeError("vars must have 2 or 1 elements")
def totrans
Definition: svgfig.py:598
output
Definition: svgfig.py:560
def svgfig.unumber (   x)
Converts numbers to a Unicode string, taking advantage of special
Unicode characters to make nice minus signs and scientific notation.

Definition at line 2284 of file svgfig.py.

References betterConfigParser.unicode.

2285 def unumber(x):
2286  """Converts numbers to a Unicode string, taking advantage of special
2287  Unicode characters to make nice minus signs and scientific notation.
2288  """
2289  output = u"%g" % x
2290 
2291  if output[0] == u"-":
2292  output = u"\u2013" + output[1:]
2293 
2294  index = output.find(u"e")
2295  if index != -1:
2296  uniout = unicode(output[:index]) + u"\u00d710"
2297  saw_nonzero = False
2298  for n in output[index+1:]:
2299  if n == u"+": pass # uniout += u"\u207a"
2300  elif n == u"-": uniout += u"\u207b"
2301  elif n == u"0":
2302  if saw_nonzero: uniout += u"\u2070"
2303  elif n == u"1":
2304  saw_nonzero = True
2305  uniout += u"\u00b9"
2306  elif n == u"2":
2307  saw_nonzero = True
2308  uniout += u"\u00b2"
2309  elif n == u"3":
2310  saw_nonzero = True
2311  uniout += u"\u00b3"
2312  elif u"4" <= n <= u"9":
2313  saw_nonzero = True
2314  if saw_nonzero: uniout += eval("u\"\\u%x\"" % (0x2070 + ord(n) - ord(u"0")))
2315  else: uniout += n
2316 
2317  if uniout[:2] == u"1\u00d7": uniout = uniout[2:]
2318  return uniout
2319 
2320  return output
def unumber
Definition: svgfig.py:2284
def svgfig.window (   xmin,
  xmax,
  ymin,
  ymax,
  x = 0,
  y = 0,
  width = 100,
  height = 100,
  xlogbase = None,
  ylogbase = None,
  minusInfinity = -1000,
  flipx = False,
  flipy = True 
)
Creates and returns a coordinate transformation (a function that
accepts two arguments and returns two values) that transforms from
    (xmin, ymin), (xmax, ymax)
to
    (x, y), (x + width, y + height).

xlogbase, ylogbase    default=None, None     if a number, transform
                                             logarithmically with given base
minusInfinity         default=-1000          what to return if
                                             log(0 or negative) is attempted
flipx                 default=False          if true, reverse the direction of x
flipy                 default=True           if true, reverse the direction of y

(When composing windows, be sure to set flipy=False.)

Definition at line 643 of file svgfig.py.

Referenced by edm::storage::LocalCacheFile.cache(), CTPPSDiamondDQMSource::ChannelPlots.ChannelPlots(), CSCStripElectronicsSim.channelsToRead(), trackerDTC::Setup.consumeStubAlgorithm(), TTStubAlgorithm_official< T >.degradeBend(), trackerDTC::Setup.encodeBend(), PixelForwardLayer.groupedCompatibleDetsV(), PixelForwardLayerPhase1.groupedCompatibleDetsV(), TBLayer.groupedCompatibleDetsV(), TIBRing.groupedCompatibleDetsV(), CompositeTECWedge.groupedCompatibleDetsV(), PixelBlade.groupedCompatibleDetsV(), TOBRod.groupedCompatibleDetsV(), Phase1PixelBlade.groupedCompatibleDetsV(), Phase2OTBarrelRod.groupedCompatibleDetsV(), CompositeTECPetal.groupedCompatibleDetsV(), CSCGEMMatcher.matchedClusterLocES(), AlignmentMonitorMuonSystemMap1D::MuonSystemMapPlot1D.MuonSystemMapPlot1D(), TTStubAlgorithm_official< T >.PatternHitCorrelation(), MuonResidualsFitter.plotsimple(), MuonResidualsFitter.plotweighted(), CTPPSDiamondDQMSource::PotPlots.PotPlots(), and tmtt::DegradeBend.work().

644 def window(xmin, xmax, ymin, ymax, x=0, y=0, width=100, height=100, xlogbase=None, ylogbase=None, minusInfinity=-1000, flipx=False, flipy=True):
645  """Creates and returns a coordinate transformation (a function that
646  accepts two arguments and returns two values) that transforms from
647  (xmin, ymin), (xmax, ymax)
648  to
649  (x, y), (x + width, y + height).
650 
651  xlogbase, ylogbase default=None, None if a number, transform
652  logarithmically with given base
653  minusInfinity default=-1000 what to return if
654  log(0 or negative) is attempted
655  flipx default=False if true, reverse the direction of x
656  flipy default=True if true, reverse the direction of y
657 
658  (When composing windows, be sure to set flipy=False.)
659  """
660 
661  if flipx:
662  ox1 = x + width
663  ox2 = x
664  else:
665  ox1 = x
666  ox2 = x + width
667  if flipy:
668  oy1 = y + height
669  oy2 = y
670  else:
671  oy1 = y
672  oy2 = y + height
673  ix1 = xmin
674  iy1 = ymin
675  ix2 = xmax
676  iy2 = ymax
677 
678  if xlogbase != None and (ix1 <= 0. or ix2 <= 0.): raise ValueError("x range incompatible with log scaling: (%g, %g)" % (ix1, ix2))
679 
680  if ylogbase != None and (iy1 <= 0. or iy2 <= 0.): raise ValueError("y range incompatible with log scaling: (%g, %g)" % (iy1, iy2))
681 
682  def maybelog(t, it1, it2, ot1, ot2, logbase):
683  if t <= 0.: return minusInfinity
684  else:
685  return ot1 + 1.*(math.log(t, logbase) - math.log(it1, logbase))/(math.log(it2, logbase) - math.log(it1, logbase)) * (ot2 - ot1)
686 
687  xlogstr, ylogstr = "", ""
688 
689  if xlogbase == None:
690  xfunc = lambda x: ox1 + 1.*(x - ix1)/(ix2 - ix1) * (ox2 - ox1)
691  else:
692  xfunc = lambda x: maybelog(x, ix1, ix2, ox1, ox2, xlogbase)
693  xlogstr = " xlog=%g" % xlogbase
694 
695  if ylogbase == None:
696  yfunc = lambda y: oy1 + 1.*(y - iy1)/(iy2 - iy1) * (oy2 - oy1)
697  else:
698  yfunc = lambda y: maybelog(y, iy1, iy2, oy1, oy2, ylogbase)
699  ylogstr = " ylog=%g" % ylogbase
700 
701  output = lambda x, y: (xfunc(x), yfunc(y))
702 
703  output.__name__ = "(%g, %g), (%g, %g) -> (%g, %g), (%g, %g)%s%s" % (ix1, ix2, iy1, iy2, ox1, ox2, oy1, oy2, xlogstr, ylogstr)
704  return output
def window
Definition: svgfig.py:643

Variable Documentation

dictionary svgfig._canvas_defaults
Initial value:
1 = {"width": "400px", "height": "400px", "viewBox": "0 0 100 100", \
2  "xmlns": "http://www.w3.org/2000/svg", "xmlns:xlink": "http://www.w3.org/1999/xlink", "version":"1.1", \
3  "style": {"stroke":"black", "fill":"none", "stroke-width":"0.5pt", "stroke-linejoin":"round", "text-anchor":"middle"}, \
4  "font-family": ["Helvetica", "Arial", "FreeSans", "Sans", "sans", "sans-serif"], \
5  }

Definition at line 476 of file svgfig.py.

tuple svgfig._circular_dot = make_symbol("circular_dot")

Definition at line 1906 of file svgfig.py.

tuple svgfig._default_directory
Initial value:
1 = _winreg.QueryValueEx(_winreg.OpenKey(_winreg.HKEY_CURRENT_USER, \
2  r"Software\Microsoft\Windows\Current Version\Explorer\Shell Folders"), "Desktop")

Definition at line 27 of file svgfig.py.

string svgfig._default_fileName = "tmp.svg"

Definition at line 35 of file svgfig.py.

int svgfig._epsilon = 1

Definition at line 21 of file svgfig.py.

dictionary svgfig._hacks = {}

Definition at line 37 of file svgfig.py.

dictionary svgfig._marker_templates
Initial value:
1 = {"arrow_start": SVG("marker", SVG("path", d="M 9 3.6 L 10.5 0 L 0 3.6 L 10.5 7.2 L 9 3.6 Z"), viewBox="0 0 10.5 7.2", refX="9", refY="3.6", markerWidth="10.5", markerHeight="7.2", markerUnits="strokeWidth", orient="auto", stroke="none", fill="black"), \
2  "arrow_end": SVG("marker", SVG("path", d="M 1.5 3.6 L 0 0 L 10.5 3.6 L 0 7.2 L 1.5 3.6 Z"), viewBox="0 0 10.5 7.2", refX="1.5", refY="3.6", markerWidth="10.5", markerHeight="7.2", markerUnits="strokeWidth", orient="auto", stroke="none", fill="black"), \
3  }

Definition at line 1961 of file svgfig.py.

dictionary svgfig._symbol_templates
Initial value:
1 = {"dot": SVG("symbol", SVG("circle", cx=0, cy=0, r=1, stroke="none", fill="black"), viewBox="0 0 1 1", overflow="visible"), \
2  "box": SVG("symbol", SVG("rect", x1=-1, y1=-1, x2=1, y2=1, stroke="none", fill="black"), viewBox="0 0 1 1", overflow="visible"), \
3  "uptri": SVG("symbol", SVG("path", d="M -1 0.866 L 1 0.866 L 0 -0.866 Z", stroke="none", fill="black"), viewBox="0 0 1 1", overflow="visible"), \
4  "downtri": SVG("symbol", SVG("path", d="M -1 -0.866 L 1 -0.866 L 0 0.866 Z", stroke="none", fill="black"), viewBox="0 0 1 1", overflow="visible"), \
5  }

Definition at line 1888 of file svgfig.py.

svgfig.all_whitespace

Definition at line 561 of file svgfig.py.

svgfig.output

Definition at line 560 of file svgfig.py.

Referenced by funcRtoC(), and totrans().

svgfig.stack

Definition at line 559 of file svgfig.py.

Referenced by NamedCandCombinerBase.combine(), CandCombinerBase< OutputCollection, CandPtr >.combine(), trackerDTC::DTC.merge(), TauDQMHistPlotter.TauDQMHistPlotter(), and FWPSetTableManager.updateFilter().