CMS 3D CMS Logo

List of all members | Public Member Functions | Public Attributes | Static Public Attributes
svgfig.Frame Class Reference

Public Member Functions

def __init__ (self, xmin, xmax, ymin, ymax, *d, **kwds)
 
def __repr__ (self)
 
def SVG (self)
 

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

◆ __init__()

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.

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

Member Function Documentation

◆ __repr__()

def svgfig.Frame.__repr__ (   self)

Definition at line 884 of file svgfig.py.

884  def __repr__(self):
885  return "<Frame (%d items)>" % len(self.d)
886 

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

Referenced by data_sources.json_file.__str__().

◆ SVG()

def svgfig.Frame.SVG (   self)
Apply the window transformation and return an SVG object.

Definition at line 956 of file svgfig.py.

956  def SVG(self):
957  """Apply the window transformation and return an SVG object."""
958 
959  self.last_window = window(self.xmin, self.xmax, self.ymin, self.ymax, x=self.x, y=self.y, width=self.width, height=self.height, \
960  xlogbase=self.xlogbase, ylogbase=self.ylogbase, minusInfinity=self.minusInfinity, flipx=self.flipx, flipy=self.flipy)
961 
962  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)
963  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)
964  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)
965  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)
966 
967  left.tick_start = -self.tick_length
968  left.tick_end = 0
969  left.minitick_start = -self.minitick_length
970  left.minitick_end = 0.
971  left.text_start = self.text_yaxis_offset
972 
973  right.tick_start = 0.
974  right.tick_end = self.tick_length
975  right.minitick_start = 0.
976  right.minitick_end = self.minitick_length
977  right.text_start = -self.text_yaxis_offset
978  right.text_attr["text-anchor"] = "start"
979 
980  bottom.tick_start = 0.
981  bottom.tick_end = self.tick_length
982  bottom.minitick_start = 0.
983  bottom.minitick_end = self.minitick_length
984  bottom.text_start = -self.text_xaxis_offset
985 
986  top.tick_start = -self.tick_length
987  top.tick_end = 0.
988  top.minitick_start = -self.minitick_length
989  top.minitick_end = 0.
990  top.text_start = self.text_xaxis_offset
991  top.text_attr["dominant-baseline"] = "text-after-edge"
992 
993  output = Fig(*self.d).SVG(self.last_window)
994  output.prepend(left.SVG(self.last_window))
995  output.prepend(bottom.SVG(self.last_window))
996  output.prepend(right.SVG(self.last_window))
997  output.prepend(top.SVG(self.last_window))
998 
999  if self.xtitle != None:
1000  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))
1001  if self.ytitle != None:
1002  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))
1003  return output
1004 

Member Data Documentation

◆ axis_attr

svgfig.Frame.axis_attr

Definition at line 950 of file svgfig.py.

◆ axis_defaults

dictionary svgfig.Frame.axis_defaults = {}
static

Definition at line 875 of file svgfig.py.

◆ d

svgfig.Frame.d

◆ flipx

svgfig.Frame.flipx

Definition at line 931 of file svgfig.py.

◆ flipy

svgfig.Frame.flipy

Definition at line 932 of file svgfig.py.

◆ height

svgfig.Frame.height

◆ last_window

svgfig.Frame.last_window

Definition at line 959 of file svgfig.py.

◆ minitick_length

float svgfig.Frame.minitick_length = 0.75
static

Definition at line 878 of file svgfig.py.

◆ minusInfinity

svgfig.Frame.minusInfinity

Definition at line 933 of file svgfig.py.

◆ text_attr

svgfig.Frame.text_attr

Definition at line 947 of file svgfig.py.

Referenced by svgfig.Axes.SVG().

◆ text_defaults

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__().

◆ text_xaxis_offset

int svgfig.Frame.text_xaxis_offset = 1.
static

Definition at line 879 of file svgfig.py.

◆ text_xtitle_offset

int svgfig.Frame.text_xtitle_offset = 6.
static

Definition at line 881 of file svgfig.py.

◆ text_yaxis_offset

int svgfig.Frame.text_yaxis_offset = 2.
static

Definition at line 880 of file svgfig.py.

◆ text_ytitle_offset

int svgfig.Frame.text_ytitle_offset = 12.
static

Definition at line 882 of file svgfig.py.

◆ tick_length

float svgfig.Frame.tick_length = 1.5
static

Definition at line 877 of file svgfig.py.

◆ width

svgfig.Frame.width

◆ x

svgfig.Frame.x

◆ x2labels

svgfig.Frame.x2labels

Definition at line 938 of file svgfig.py.

◆ xlabels

svgfig.Frame.xlabels

Definition at line 937 of file svgfig.py.

Referenced by svgfig.Axes.SVG().

◆ xlogbase

svgfig.Frame.xlogbase

Definition at line 939 of file svgfig.py.

Referenced by svgfig.Axes.SVG().

◆ xminiticks

svgfig.Frame.xminiticks

Definition at line 936 of file svgfig.py.

Referenced by svgfig.Axes.SVG().

◆ xticks

svgfig.Frame.xticks

Definition at line 935 of file svgfig.py.

Referenced by svgfig.Axes.SVG().

◆ xtitle

svgfig.Frame.xtitle

Definition at line 934 of file svgfig.py.

◆ y

svgfig.Frame.y

◆ y2labels

svgfig.Frame.y2labels

Definition at line 944 of file svgfig.py.

◆ ylabels

svgfig.Frame.ylabels

Definition at line 943 of file svgfig.py.

Referenced by svgfig.Axes.SVG().

◆ ylogbase

svgfig.Frame.ylogbase

Definition at line 945 of file svgfig.py.

Referenced by svgfig.Axes.SVG().

◆ ymax

svgfig.Frame.ymax

◆ yminiticks

svgfig.Frame.yminiticks

Definition at line 942 of file svgfig.py.

Referenced by svgfig.Axes.SVG().

◆ yticks

svgfig.Frame.yticks

Definition at line 941 of file svgfig.py.

Referenced by svgfig.Axes.SVG().

◆ ytitle

svgfig.Frame.ytitle

Definition at line 940 of file svgfig.py.

svgfig.window
def window(xmin, xmax, ymin, ymax, x=0, y=0, width=100, height=100, xlogbase=None, ylogbase=None, minusInfinity=-1000, flipx=False, flipy=True)
Definition: svgfig.py:643
update
#define update(a, b)
Definition: TrackClassifier.cc:10