CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros 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 46 of file svgfig.py.

Referenced by make_marker(), and make_symbol().

46 
47 def attr_preprocess(attr):
48  for name in attr.keys():
49  name_colon = re.sub("__", ":", name)
50  if name_colon != name:
51  attr[name_colon] = attr[name]
52  del attr[name]
53  name = name_colon
54 
55  name_dash = re.sub("_", "-", name)
56  if name_dash != name:
57  attr[name_dash] = attr[name]
58  del attr[name]
59  name = name_dash
60 
61  return attr
def attr_preprocess
Definition: svgfig.py:46
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 481 of file svgfig.py.

References python.multivaluedict.dict.

Referenced by canvas_outline(), SiStripHistoPlotter.createStaticPlot(), TrackingMaterialPlotter.draw(), cond.draw(), HcalObjRepresent::ADataRepr.draw(), DTOccupancyClusterBuilder.drawClusters(), ErrorsAnalyzer.drawHistograms(), ErrorsPropagationAnalyzer.drawHistograms(), TauDQMHistPlotter.endRun(), EcalDisplaysByEvent.init2DEcalCanvas(), main(), SiStripHistoPlotter.makeCondDBPlots(), TagProbeFitter.makeEfficiencyPlot1D(), TagProbeFitter.makeEfficiencyPlot2D(), SiStripHistoPlotter.makePlot(), MuScleFitUtils.minimizeLikelihood(), cond::PayLoadInspector< DataT >.plot(), root.plotTF1(), ListGroups.produceAndSaveSummaryPlot(), SoftLeptonTagPlotter.psPlot(), IPTagPlotter< Container, Base >.psPlot(), TrackCountingTagPlotter.psPlot(), TrackProbabilityTagPlotter.psPlot(), JetTagPlotter.psPlot(), TagProbeFitter.saveDistributionsPlot(), TagProbeFitter.saveFitPlot(), MaterialAccountingGroup.savePlot(), svgfig.SVG.standalone_xml(), tfwliteselectortest::ThingsTSelector.terminate(), tfwliteselectortest::ThingsTSelector2.terminate(), examples::TrackAnalysisAlgorithm.terminate(), __class__< T >.terminate(), cond::PayLoadInspector< DataT >.trend_plot(), HFunctionResolution.Write(), HCovarianceVSxy.Write(), TestCorrection.~TestCorrection(), and TestResolution.~TestResolution().

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

References canvas().

510 def canvas_outline(*sub, **attr):
511  """Same as canvas(), but draws an outline around the drawable area,
512  so that you know how close your image is to the edges."""
513  svg = canvas(*sub, **attr)
514  match = re.match("[, \t]*([0-9e.+\-]+)[, \t]+([0-9e.+\-]+)[, \t]+([0-9e.+\-]+)[, \t]+([0-9e.+\-]+)[, \t]*", svg["viewBox"])
515  if match == None: raise ValueError, "canvas viewBox is incorrectly formatted"
516  x, y, width, height = [float(x) for x in match.groups()]
517  svg.prepend(SVG("rect", x=x, y=y, width=width, height=height, stroke="none", fill="cornsilk"))
518  svg.append(SVG("rect", x=x, y=y, width=width, height=height, stroke="black", fill="none"))
519  return svg
def canvas_outline
Definition: svgfig.py:509
def canvas
Definition: svgfig.py:481
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 1451 of file svgfig.py.

References output, and split.

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

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

Referenced by svgfig.Curve.Path().

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

Definition at line 546 of file svgfig.py.

References mergeVDriftHistosByStation.file, and load_stream().

Referenced by EcalDeadChannelRecoveryNN< DetIdT >.EcalDeadChannelRecoveryNN(), l1t::MP7BufferDumpToRaw.formatAMC(), FWPartialConfigLoadGUI.FWPartialConfigLoadGUI(), l1t::MicroGMTCaloIndexSelectionLUT.getParameters(), l1t::MicroGMTRelativeIsolationCheckLUT.getParameters(), l1t::MicroGMTAbsoluteIsolationCheckLUT.getParameters(), l1t::MicroGMTExtrapolationLUT.getParameters(), ThePEGInterface.initRepository(), cond::PayloadProxy< cond::KeyList >.load(), FedRawDataInputSource.nextEvent(), l1t::stage1::HFRingPacker.pack(), l1t::stage2::TauPacker.pack(), l1t::stage1::MissEtPacker.pack(), l1t::stage2::JetPacker.pack(), l1t::stage2::EGammaPacker.pack(), l1t::stage1::CaloSpareHFPacker.pack(), l1t::stage1::MissHtPacker.pack(), l1t::stage1::EtSumPacker.pack(), l1t::stage2::EtSumPacker.pack(), l1t::stage2::CaloTowerPacker.pack(), l1t::stage1::RCTEmRegionPacker.pack(), evf::FastMonitoringService.preStreamEndLumi(), process(), l1t::L1TDigiToRaw.produce(), L1MuDTExtrapolationUnit.run(), utils.unpickler.run(), and template().

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

Definition at line 550 of file svgfig.py.

References python.multivaluedict.__init__().

Referenced by load().

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

References attr_preprocess().

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

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

References attr_preprocess().

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

Definition at line 1006 of file svgfig.py.

References python.multivaluedict.dict.

Referenced by geometryDiffVisualization.draw_disk().

1007 def pathtoPath(svg):
1008  """Converts SVG("path", d="...") into Path(d=[...])."""
1009  if not isinstance(svg, SVG) or svg.t != "path":
1010  raise TypeError, "Only SVG <path /> objects can be converted into Paths"
1011  attr = dict(svg.attr)
1012  d = attr["d"]
1013  del attr["d"]
1014  for key in attr.keys():
1015  if not isinstance(key, str):
1016  value = attr[key]
1017  del attr[key]
1018  attr[str(key)] = value
1019  return Path(d, **attr)
def pathtoPath
Definition: svgfig.py:1006
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 39 of file svgfig.py.

References bookConverter.max, and min().

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

39 
40 def rgb(r, g, b, maximum=1.):
41  """Create an SVG color string "#xxyyzz" from r, g, and b.
42 
43  r,g,b = 0 is black and r,g,b = maximum is white.
44  """
45  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:39
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 704 of file svgfig.py.

Referenced by MagGeoBuilderFromDDD::bLayer.bLayer(), MagGeoBuilderFromDDD.build(), CmsTrackerPhase1DiskBuilder.PhiPosNegSplit_innerOuter(), DetPositioner.rotateGeomDet(), and ParticleReplacerZtautau.transformMuMu2LepLep().

705 def rotate(angle, cx=0, cy=0):
706  """Creates and returns a coordinate transformation which rotates
707  around (cx,cy) by "angle" degrees."""
708  angle *= math.pi/180.
709  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:704
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 520 of file svgfig.py.

References load().

Referenced by dd_count(), dd_error_scan(), GenericMVAComputer.eval(), findNameSpaces(), edm::refitem::GetRefPtrImpl< C, T, F, KEY >.getRefPtr_(), edm::refitem::GetRefPtrImpl< C, T, F, unsigned int >.getRefPtr_(), edm::WorkerMaker< T >.makeModule(), edm::RefProd< T >.operator*(), edm::RefProd< T >.operator->(), and TrackerStablePhiSort().

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

References output, and 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().

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

2284 def unumber(x):
2285  """Converts numbers to a Unicode string, taking advantage of special
2286  Unicode characters to make nice minus signs and scientific notation.
2287  """
2288  output = u"%g" % x
2289 
2290  if output[0] == u"-":
2291  output = u"\u2013" + output[1:]
2292 
2293  index = output.find(u"e")
2294  if index != -1:
2295  uniout = unicode(output[:index]) + u"\u00d710"
2296  saw_nonzero = False
2297  for n in output[index+1:]:
2298  if n == u"+": pass # uniout += u"\u207a"
2299  elif n == u"-": uniout += u"\u207b"
2300  elif n == u"0":
2301  if saw_nonzero: uniout += u"\u2070"
2302  elif n == u"1":
2303  saw_nonzero = True
2304  uniout += u"\u00b9"
2305  elif n == u"2":
2306  saw_nonzero = True
2307  uniout += u"\u00b2"
2308  elif n == u"3":
2309  saw_nonzero = True
2310  uniout += u"\u00b3"
2311  elif u"4" <= n <= u"9":
2312  saw_nonzero = True
2313  if saw_nonzero: uniout += eval("u\"\\u%x\"" % (0x2070 + ord(n) - ord(u"0")))
2314  else: uniout += n
2315 
2316  if uniout[:2] == u"1\u00d7": uniout = uniout[2:]
2317  return uniout
2318 
2319  return output
def unumber
Definition: svgfig.py:2283
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 642 of file svgfig.py.

Referenced by LocalCacheFile.cache(), CSCStripElectronicsSim.channelsToRead(), PixelForwardLayer.groupedCompatibleDetsV(), PixelForwardLayerPhase1.groupedCompatibleDetsV(), CompositeTECWedge.groupedCompatibleDetsV(), TIBRing.groupedCompatibleDetsV(), TBLayer.groupedCompatibleDetsV(), PixelBlade.groupedCompatibleDetsV(), TOBRod.groupedCompatibleDetsV(), Phase1PixelBlade.groupedCompatibleDetsV(), Phase2OTBarrelRod.groupedCompatibleDetsV(), CompositeTECPetal.groupedCompatibleDetsV(), EcalDeadChannelRecoveryNN< EBDetId >.makeNxNMatrice_RelDC(), AlignmentMonitorMuonSystemMap1D::MuonSystemMapPlot1D.MuonSystemMapPlot1D(), MuonResidualsFitter.plotsimple(), and MuonResidualsFitter.plotweighted().

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

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 475 of file svgfig.py.

tuple svgfig._circular_dot = make_symbol("circular_dot")

Definition at line 1905 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 26 of file svgfig.py.

string svgfig._default_fileName = "tmp.svg"

Definition at line 34 of file svgfig.py.

int svgfig._epsilon = 1

Definition at line 20 of file svgfig.py.

dictionary svgfig._hacks = {}

Definition at line 36 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 1960 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 1887 of file svgfig.py.

svgfig.all_whitespace

Definition at line 560 of file svgfig.py.

svgfig.output

Definition at line 559 of file svgfig.py.

Referenced by funcRtoC(), and totrans().

svgfig.stack

Definition at line 558 of file svgfig.py.

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