CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Public Member Functions | Public Attributes | Static Public Attributes
svgfig.Frame Class Reference

Public Member Functions

def __init__
 
def __repr__
 
def SVG
 

Public Attributes

 axis_attr
 
 d
 
 flipx
 
 flipy
 
 height
 
 last_window
 
 minusInfinity
 
 text_attr
 
 width
 
 x
 
 x2labels
 
 xlabels
 
 xlogbase
 
 xminiticks
 
 xticks
 
 xtitle
 
 y
 
 y2labels
 
 ylabels
 
 ylogbase
 
 ymax
 
 yminiticks
 
 yticks
 
 ytitle
 

Static Public Attributes

dictionary axis_defaults = {}
 
float minitick_length = 0.75
 
dictionary text_defaults = {"stroke":"none", "fill":"black", "font-size":5}
 
int text_xaxis_offset = 1
 
int text_xtitle_offset = 6
 
int text_yaxis_offset = 2
 
int text_ytitle_offset = 12
 
float tick_length = 1.5
 

Detailed Description

Definition at line 873 of file svgfig.py.

Constructor & Destructor Documentation

def svgfig.Frame.__init__ (   self,
  xmin,
  xmax,
  ymin,
  ymax,
  d,
  kwds 
)
Acts like Fig, but draws a coordinate frame around the data. You also need to supply plot ranges.

Frame(xmin, xmax, ymin, ymax, obj, obj, obj..., keyword options...)

xmin, xmax      required        minimum and maximum x values (in the objs' coordinates)
ymin, ymax      required        minimum and maximum y values (in the objs' coordinates)
obj             optional list   drawing primatives
keyword options keyword list    options defined below

The following are keyword options, with their default values:

x, y            20, 5         upper-left corner of the Frame in SVG coordinates
width, height   75, 80        width and height of the Frame in SVG coordinates
flipx, flipy    False, True   flip the sign of the coordinate axis
minusInfinity   -1000         if an axis is logarithmic and an object is plotted at 0 or
                          a negative value, -1000 will be used as a stand-in for NaN
xtitle          None          if a string, label the x axis
xticks          -10           request ticks according to the standard tick specification
                          (see help(Ticks))
xminiticks      True          request miniticks according to the standard minitick
                          specification
xlabels         True          request tick labels according to the standard tick label
                          specification
xlogbase        None          if a number, the axis and transformation are logarithmic
                          with ticks at the given base (10 being the most common)
(same for y)
text_attr       {}            a dictionary of attributes for label text
axis_attr       {}            a dictionary of attributes for the axis lines

Definition at line 887 of file svgfig.py.

888  def __init__(self, xmin, xmax, ymin, ymax, *d, **kwds):
889  """Acts like Fig, but draws a coordinate frame around the data. You also need to supply plot ranges.
890 
891  Frame(xmin, xmax, ymin, ymax, obj, obj, obj..., keyword options...)
892 
893  xmin, xmax required minimum and maximum x values (in the objs' coordinates)
894  ymin, ymax required minimum and maximum y values (in the objs' coordinates)
895  obj optional list drawing primatives
896  keyword options keyword list options defined below
897 
898  The following are keyword options, with their default values:
899 
900  x, y 20, 5 upper-left corner of the Frame in SVG coordinates
901  width, height 75, 80 width and height of the Frame in SVG coordinates
902  flipx, flipy False, True flip the sign of the coordinate axis
903  minusInfinity -1000 if an axis is logarithmic and an object is plotted at 0 or
904  a negative value, -1000 will be used as a stand-in for NaN
905  xtitle None if a string, label the x axis
906  xticks -10 request ticks according to the standard tick specification
907  (see help(Ticks))
908  xminiticks True request miniticks according to the standard minitick
909  specification
910  xlabels True request tick labels according to the standard tick label
911  specification
912  xlogbase None if a number, the axis and transformation are logarithmic
913  with ticks at the given base (10 being the most common)
914  (same for y)
915  text_attr {} a dictionary of attributes for label text
916  axis_attr {} a dictionary of attributes for the axis lines
917  """
919  self.xmin, self.xmax, self.ymin, self.ymax = xmin, xmax, ymin, ymax
920  self.d = list(d)
921  defaults = {"x":20, "y":5, "width":75, "height":80, "flipx":False, "flipy":True, "minusInfinity":-1000, \
922  "xtitle":None, "xticks":-10, "xminiticks":True, "xlabels":True, "x2labels":None, "xlogbase":None, \
923  "ytitle":None, "yticks":-10, "yminiticks":True, "ylabels":True, "y2labels":None, "ylogbase":None, \
924  "text_attr":{}, "axis_attr":{}}
925  defaults.update(kwds)
926  kwds = defaults
928  self.x = kwds["x"]; del kwds["x"]
929  self.y = kwds["y"]; del kwds["y"]
930  self.width = kwds["width"]; del kwds["width"]
931  self.height = kwds["height"]; del kwds["height"]
932  self.flipx = kwds["flipx"]; del kwds["flipx"]
933  self.flipy = kwds["flipy"]; del kwds["flipy"]
934  self.minusInfinity = kwds["minusInfinity"]; del kwds["minusInfinity"]
935  self.xtitle = kwds["xtitle"]; del kwds["xtitle"]
936  self.xticks = kwds["xticks"]; del kwds["xticks"]
937  self.xminiticks = kwds["xminiticks"]; del kwds["xminiticks"]
938  self.xlabels = kwds["xlabels"]; del kwds["xlabels"]
939  self.x2labels = kwds["x2labels"]; del kwds["x2labels"]
940  self.xlogbase = kwds["xlogbase"]; del kwds["xlogbase"]
941  self.ytitle = kwds["ytitle"]; del kwds["ytitle"]
942  self.yticks = kwds["yticks"]; del kwds["yticks"]
943  self.yminiticks = kwds["yminiticks"]; del kwds["yminiticks"]
944  self.ylabels = kwds["ylabels"]; del kwds["ylabels"]
945  self.y2labels = kwds["y2labels"]; del kwds["y2labels"]
946  self.ylogbase = kwds["ylogbase"]; del kwds["ylogbase"]
948  self.text_attr = dict(self.text_defaults)
949  self.text_attr.update(kwds["text_attr"]); del kwds["text_attr"]
951  self.axis_attr = dict(self.axis_defaults)
952  self.axis_attr.update(kwds["axis_attr"]); del kwds["axis_attr"]
953 
954  if len(kwds) != 0:
955  raise TypeError("Frame() got unexpected keyword arguments %s" % kwds.keys())
dictionary axis_defaults
Definition: svgfig.py:875
def __init__
Definition: svgfig.py:887
dictionary text_defaults
Definition: svgfig.py:874

Member Function Documentation

def svgfig.Frame.__repr__ (   self)

Definition at line 884 of file svgfig.py.

References svgfig.Fig.d, svgfig.Plot.d, and svgfig.Frame.d.

Referenced by data_sources.json_file.__str__().

885  def __repr__(self):
886  return "<Frame (%d items)>" % len(self.d)
def __repr__
Definition: svgfig.py:884
def svgfig.Frame.SVG (   self)
Apply the window transformation and return an SVG object.

Definition at line 956 of file svgfig.py.

957  def SVG(self):
958  """Apply the window transformation and return an SVG object."""
960  self.last_window = window(self.xmin, self.xmax, self.ymin, self.ymax, x=self.x, y=self.y, width=self.width, height=self.height, \
961  xlogbase=self.xlogbase, ylogbase=self.ylogbase, minusInfinity=self.minusInfinity, flipx=self.flipx, flipy=self.flipy)
962 
963  left = YAxis(self.ymin, self.ymax, self.xmin, self.yticks, self.yminiticks, self.ylabels, self.ylogbase, None, None, None, self.text_attr, **self.axis_attr)
964  right = YAxis(self.ymin, self.ymax, self.xmax, self.yticks, self.yminiticks, self.y2labels, self.ylogbase, None, None, None, self.text_attr, **self.axis_attr)
965  bottom = XAxis(self.xmin, self.xmax, self.ymin, self.xticks, self.xminiticks, self.xlabels, self.xlogbase, None, None, None, self.text_attr, **self.axis_attr)
966  top = XAxis(self.xmin, self.xmax, self.ymax, self.xticks, self.xminiticks, self.x2labels, self.xlogbase, None, None, None, self.text_attr, **self.axis_attr)
967 
968  left.tick_start = -self.tick_length
969  left.tick_end = 0
970  left.minitick_start = -self.minitick_length
971  left.minitick_end = 0.
972  left.text_start = self.text_yaxis_offset
973 
974  right.tick_start = 0.
975  right.tick_end = self.tick_length
976  right.minitick_start = 0.
977  right.minitick_end = self.minitick_length
978  right.text_start = -self.text_yaxis_offset
979  right.text_attr["text-anchor"] = "start"
980 
981  bottom.tick_start = 0.
982  bottom.tick_end = self.tick_length
983  bottom.minitick_start = 0.
984  bottom.minitick_end = self.minitick_length
985  bottom.text_start = -self.text_xaxis_offset
986 
987  top.tick_start = -self.tick_length
988  top.tick_end = 0.
989  top.minitick_start = -self.minitick_length
990  top.minitick_end = 0.
991  top.text_start = self.text_xaxis_offset
992  top.text_attr["dominant-baseline"] = "text-after-edge"
993 
994  output = Fig(*self.d).SVG(self.last_window)
995  output.prepend(left.SVG(self.last_window))
996  output.prepend(bottom.SVG(self.last_window))
997  output.prepend(right.SVG(self.last_window))
998  output.prepend(top.SVG(self.last_window))
999 
1000  if self.xtitle != None:
1001  output.append(SVG("text", self.xtitle, transform="translate(%g, %g)" % ((self.x + self.width/2.), (self.y + self.height + self.text_xtitle_offset)), dominant_baseline="text-before-edge", **self.text_attr))
1002  if self.ytitle != None:
1003  output.append(SVG("text", self.ytitle, transform="translate(%g, %g) rotate(-90)" % ((self.x - self.text_ytitle_offset), (self.y + self.height/2.)), **self.text_attr))
1004  return output
def window
Definition: svgfig.py:643
int text_ytitle_offset
Definition: svgfig.py:882
int text_xaxis_offset
Definition: svgfig.py:879
float minitick_length
Definition: svgfig.py:878
float tick_length
Definition: svgfig.py:877
int text_yaxis_offset
Definition: svgfig.py:880
int text_xtitle_offset
Definition: svgfig.py:881

Member Data Documentation

svgfig.Frame.axis_attr

Definition at line 950 of file svgfig.py.

dictionary svgfig.Frame.axis_defaults = {}
static

Definition at line 875 of file svgfig.py.

svgfig.Frame.d

Definition at line 919 of file svgfig.py.

Referenced by svgfig.Frame.__repr__(), svgfig.Path.__repr__(), svgfig.Poly.__repr__(), svgfig.Text.__repr__(), svgfig.TextGlobal.__repr__(), svgfig.Dots.__repr__(), svgfig.XErrorBars.__repr__(), svgfig.YErrorBars.__repr__(), svgfig.Poly.Path(), svgfig.Path.SVG(), svgfig.Text.SVG(), svgfig.TextGlobal.SVG(), svgfig.Dots.SVG(), svgfig.XErrorBars.SVG(), and svgfig.YErrorBars.SVG().

svgfig.Frame.flipx

Definition at line 931 of file svgfig.py.

svgfig.Frame.flipy

Definition at line 932 of file svgfig.py.

svgfig.Frame.height

Definition at line 930 of file svgfig.py.

Referenced by TkAlMap.TkAlMap.draw_cms_prelim(), presentation.PageLayout.fit(), TkAlMap.TkAlMap.load_geometry(), and svgfig.Dots.SVG().

svgfig.Frame.last_window

Definition at line 959 of file svgfig.py.

float svgfig.Frame.minitick_length = 0.75
static

Definition at line 878 of file svgfig.py.

svgfig.Frame.minusInfinity

Definition at line 933 of file svgfig.py.

svgfig.Frame.text_attr

Definition at line 947 of file svgfig.py.

Referenced by svgfig.Axes.SVG().

dictionary svgfig.Frame.text_defaults = {"stroke":"none", "fill":"black", "font-size":5}
static

Definition at line 874 of file svgfig.py.

Referenced by svgfig.CurveAxis.__init__().

int svgfig.Frame.text_xaxis_offset = 1
static

Definition at line 879 of file svgfig.py.

int svgfig.Frame.text_xtitle_offset = 6
static

Definition at line 881 of file svgfig.py.

int svgfig.Frame.text_yaxis_offset = 2
static

Definition at line 880 of file svgfig.py.

int svgfig.Frame.text_ytitle_offset = 12
static

Definition at line 882 of file svgfig.py.

float svgfig.Frame.tick_length = 1.5
static

Definition at line 877 of file svgfig.py.

svgfig.Frame.width

Definition at line 929 of file svgfig.py.

Referenced by python.rootplot.utilities.Hist.__init_TGraph(), python.rootplot.root2matplotlib.Hist.bar(), python.rootplot.root2matplotlib.Hist.barh(), TkAlMap.TkAlMap.draw_cms_prelim(), presentation.PageLayout.fit(), TkAlMap.TkAlMap.load_geometry(), and svgfig.Dots.SVG().

svgfig.Frame.x

Definition at line 927 of file svgfig.py.

Referenced by python.rootplot.utilities.Hist.__init_TGraph(), svgfig.Curve.Sample.__repr__(), svgfig.Text.__repr__(), svgfig.TextGlobal.__repr__(), svgfig.VLine.__repr__(), svgfig.Ellipse.__repr__(), edmStreamStallGrapher.Point.__str__(), python.rootplot.root2matplotlib.Hist._prepare_xaxis(), python.rootplot.root2matplotlib.Hist._prepare_yaxis(), python.rootplot.root2matplotlib.Hist2D.box(), python.rootplot.root2matplotlib.Hist2D.contour(), python.rootplot.root2matplotlib.Hist.errorbar(), python.rootplot.root2matplotlib.Hist.errorbarh(), geometryXMLparser.Alignable.pos(), ntupleDataFormat._HitObject.r(), ntupleDataFormat._HitObject.r3D(), svgfig.Text.SVG(), svgfig.TextGlobal.SVG(), and python.rootplot.utilities.Hist.TGraph().

svgfig.Frame.x2labels

Definition at line 938 of file svgfig.py.

svgfig.Frame.xlabels

Definition at line 937 of file svgfig.py.

Referenced by svgfig.Axes.SVG().

svgfig.Frame.xlogbase

Definition at line 939 of file svgfig.py.

Referenced by svgfig.Axes.SVG().

svgfig.Frame.xminiticks

Definition at line 936 of file svgfig.py.

Referenced by svgfig.Axes.SVG().

svgfig.Frame.xticks

Definition at line 935 of file svgfig.py.

Referenced by svgfig.Axes.SVG().

svgfig.Frame.xtitle

Definition at line 934 of file svgfig.py.

svgfig.Frame.y

Definition at line 928 of file svgfig.py.

Referenced by python.rootplot.utilities.Hist.__getitem__(), python.rootplot.utilities.Hist.__init_TGraph(), python.rootplot.utilities.Hist.__iter__(), svgfig.Curve.Sample.__repr__(), svgfig.Text.__repr__(), svgfig.TextGlobal.__repr__(), svgfig.HLine.__repr__(), svgfig.Ellipse.__repr__(), python.rootplot.utilities.Hist.__setitem__(), edmStreamStallGrapher.Point.__str__(), python.rootplot.root2matplotlib.Hist.bar(), python.rootplot.root2matplotlib.Hist.barh(), python.rootplot.root2matplotlib.Hist2D.box(), python.rootplot.root2matplotlib.Hist2D.contour(), python.rootplot.utilities.Hist.divide_wilson(), python.rootplot.root2matplotlib.Hist.errorbar(), python.rootplot.root2matplotlib.Hist.errorbarh(), python.rootplot.root2matplotlib.Hist.hist(), python.rootplot.utilities.Hist.min(), geometryXMLparser.Alignable.pos(), ntupleDataFormat._HitObject.r(), ntupleDataFormat._HitObject.r3D(), python.rootplot.utilities.Hist.scale(), svgfig.Text.SVG(), svgfig.TextGlobal.SVG(), python.rootplot.utilities.Hist.TGraph(), and python.rootplot.utilities.Hist.TH1F().

svgfig.Frame.y2labels

Definition at line 944 of file svgfig.py.

svgfig.Frame.ylabels

Definition at line 943 of file svgfig.py.

Referenced by svgfig.Axes.SVG().

svgfig.Frame.ylogbase

Definition at line 945 of file svgfig.py.

Referenced by svgfig.Axes.SVG().

svgfig.Frame.ymax

Definition at line 918 of file svgfig.py.

Referenced by svgfig.YAxis.__repr__(), svgfig.Axes.__repr__(), svgfig.VGrid.__repr__(), svgfig.Grid.__repr__(), and svgfig.Axes.SVG().

svgfig.Frame.yminiticks

Definition at line 942 of file svgfig.py.

Referenced by svgfig.Axes.SVG().

svgfig.Frame.yticks

Definition at line 941 of file svgfig.py.

Referenced by svgfig.Axes.SVG().

svgfig.Frame.ytitle

Definition at line 940 of file svgfig.py.