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.Ticks Class Reference
Inheritance diagram for svgfig.Ticks:
svgfig.CurveAxis svgfig.Grid svgfig.HGrid svgfig.LineAxis svgfig.VGrid svgfig.XAxis svgfig.YAxis

Public Member Functions

def __init__
 
def __repr__
 
def compute_logminiticks
 
def compute_logticks
 
def compute_miniticks
 
def compute_ticks
 
def interpret
 
def orient_tickmark
 
def regular_miniticks
 
def SVG
 

Public Attributes

 arrow_end
 
 arrow_start
 
 attr
 
 f
 
 high
 
 labels
 
 last_miniticks
 
 logbase
 
 low
 
 miniticks
 
 text_attr
 
 ticks
 

Static Public Attributes

dictionary defaults = {"stroke-width":"0.25pt"}
 
float minitick_end = 0.75
 
float minitick_start = -0.75
 
int text_angle = 0
 
dictionary text_defaults = {"stroke":"none", "fill":"black", "font-size":5}
 
float text_start = 2.5
 
float tick_end = 1.5
 
float tick_start = -1.5
 

Detailed Description

Superclass for all graphics primatives that draw ticks,
miniticks, and tick labels.  This class only draws the ticks.

Ticks(f, low, high, ticks, miniticks, labels, logbase, arrow_start,
      arrow_end, text_attr, attribute=value)

f                       required        parametric function along which ticks
                                        will be drawn; has the same format as
                                        the function used in Curve
low, high               required        range of the independent variable
ticks                   default=-10     request ticks according to the standard
                                        tick specification (see below)
miniticks               default=True    request miniticks according to the
                                        standard minitick specification (below)
labels                  True            request tick labels according to the
                                        standard tick label specification (below)
logbase                 default=None    if a number, the axis is logarithmic with
                                        ticks at the given base (usually 10)
arrow_start             default=None    if a new string identifier, draw an arrow
                                        at the low-end of the axis, referenced by
                                        that identifier; if an SVG marker object,
                                        use that marker
arrow_end               default=None    if a new string identifier, draw an arrow
                                        at the high-end of the axis, referenced by
                                        that identifier; if an SVG marker object,
                                        use that marker
text_attr               default={}      SVG attributes for the text labels
attribute=value pairs   keyword list    SVG attributes for the tick marks 

Standard tick specification:

    * True: same as -10 (below).
    * Positive number N: draw exactly N ticks, including the endpoints. To
      subdivide an axis into 10 equal-sized segments, ask for 11 ticks.
    * Negative number -N: draw at least N ticks. Ticks will be chosen with
      "natural" values, multiples of 2 or 5.
    * List of values: draw a tick mark at each value.
    * Dict of value, label pairs: draw a tick mark at each value, labeling
      it with the given string. This lets you say things like {3.14159: "pi"}.
    * False or None: no ticks.

Standard minitick specification:

    * True: draw miniticks with "natural" values, more closely spaced than
      the ticks.
    * Positive number N: draw exactly N miniticks, including the endpoints.
      To subdivide an axis into 100 equal-sized segments, ask for 101 miniticks.
    * Negative number -N: draw at least N miniticks.
    * List of values: draw a minitick mark at each value.
    * False or None: no miniticks. 

Standard tick label specification:

    * True: use the unumber function (described below)
    * Format string: standard format strings, e.g. "%5.2f" for 12.34
    * Python callable: function that converts numbers to strings
    * False or None: no labels 

Definition at line 2321 of file svgfig.py.

Constructor & Destructor Documentation

def svgfig.Ticks.__init__ (   self,
  f,
  low,
  high,
  ticks = -10,
  miniticks = True,
  labels = True,
  logbase = None,
  arrow_start = None,
  arrow_end = None,
  text_attr = {},
  attr 
)

Definition at line 2392 of file svgfig.py.

2393  def __init__(self, f, low, high, ticks=-10, miniticks=True, labels=True, logbase=None, arrow_start=None, arrow_end=None, text_attr={}, **attr):
2394  self.f = f
2395  self.low = low
2396  self.high = high
2397  self.ticks = ticks
2398  self.miniticks = miniticks
2399  self.labels = labels
2400  self.logbase = logbase
2401  self.arrow_start = arrow_start
2402  self.arrow_end = arrow_end
2404  self.attr = dict(self.defaults)
2405  self.attr.update(attr)
2407  self.text_attr = dict(self.text_defaults)
2408  self.text_attr.update(text_attr)
def __init__
Definition: svgfig.py:2392
dictionary text_defaults
Definition: svgfig.py:2381
dictionary defaults
Definition: svgfig.py:2380

Member Function Documentation

def svgfig.Ticks.__repr__ (   self)

Definition at line 2389 of file svgfig.py.

References svgfig.SVG.attr, svgfig.Path.attr, svgfig.Curve.attr, svgfig.Poly.attr, svgfig.Text.attr, svgfig.TextGlobal.attr, svgfig.Dots.attr, svgfig.Line.attr, svgfig.LineGlobal.attr, svgfig.VLine.attr, svgfig.HLine.attr, svgfig.Rect.attr, svgfig.Ellipse.attr, svgfig.Ticks.attr, hippyaddtobaddatafiles.KeepWhileOpenFile.f, svgfig.Curve.f, svgfig.Line.f, svgfig.Rect.f, svgfig.Ellipse.f, svgfig.Ticks.f, svgfig.Curve.high, svgfig.Line.high, svgfig.Rect.high, svgfig.Ellipse.high, svgfig.Ticks.high, svgfig.Ticks.labels, svgfig.Curve.low, svgfig.Line.low, svgfig.Rect.low, svgfig.Ellipse.low, svgfig.Ticks.low, str, and svgfig.Ticks.ticks.

Referenced by data_sources.json_file.__str__().

2390  def __repr__(self):
2391  return "<Ticks %s from %s to %s ticks=%s labels=%s %s>" % (self.f, self.low, self.high, str(self.ticks), str(self.labels), self.attr)
def __repr__
Definition: svgfig.py:2389
#define str(s)
def svgfig.Ticks.compute_logminiticks (   self,
  base 
)
Return optimal logarithmic miniticks, given a set of ticks.

Normally only used internally.

Definition at line 2768 of file svgfig.py.

References svgfig.Curve.high, svgfig.Line.high, svgfig.Rect.high, svgfig.Ellipse.high, svgfig.Ticks.high, svgfig.Curve.low, svgfig.Line.low, svgfig.Rect.low, svgfig.Ellipse.low, svgfig.Ticks.low, and sistrip::SpyUtilities.range().

Referenced by svgfig.Ticks.interpret().

2769  def compute_logminiticks(self, base):
2770  """Return optimal logarithmic miniticks, given a set of ticks.
2771 
2772  Normally only used internally.
2773  """
2774  if self.low >= self.high: raise ValueError("low must be less than high")
2775 
2776  lowN = math.floor(math.log(self.low, base))
2777  highN = math.ceil(math.log(self.high, base))
2778  output = []
2779  num_ticks = 0
2780  for n in range(int(lowN), int(highN)+1):
2781  x = base**n
2782  if self.low <= x <= self.high: num_ticks += 1
2783  for m in range(2, int(math.ceil(base))):
2784  minix = m * x
2785  if self.low <= minix <= self.high: output.append(minix)
2786 
2787  if num_ticks <= 2: return []
2788  else: return output
def compute_logminiticks
Definition: svgfig.py:2768
const uint16_t range(const Frame &aFrame)
def svgfig.Ticks.compute_logticks (   self,
  base,
  N,
  format 
)
Return less than -N or exactly N optimal logarithmic ticks.

Normally only used internally.

Definition at line 2718 of file svgfig.py.

References funct.abs(), svgfig.Ticks.compute_ticks(), svgfig.Curve.high, svgfig.Line.high, svgfig.Rect.high, svgfig.Ellipse.high, svgfig.Ticks.high, svgfig.Curve.low, svgfig.Line.low, svgfig.Rect.low, svgfig.Ellipse.low, svgfig.Ticks.low, min(), and sistrip::SpyUtilities.range().

Referenced by svgfig.Ticks.interpret().

2719  def compute_logticks(self, base, N, format):
2720  """Return less than -N or exactly N optimal logarithmic ticks.
2721 
2722  Normally only used internally.
2723  """
2724  if self.low >= self.high: raise ValueError("low must be less than high")
2725  if N == 1: raise ValueError("N can be 0 or >1 to specify the exact number of ticks or negative to specify a maximum")
2726 
2727  eps = _epsilon * (self.high - self.low)
2728 
2729  if N >= 0:
2730  output = {}
2731  x = self.low
2732  for i in range(N):
2733  if format == unumber and abs(x) < eps: label = u"0"
2734  else: label = format(x)
2735  output[x] = label
2736  x += (self.high - self.low)/(N-1.)
2737  return output
2738 
2739  N = -N
2740 
2741  lowN = math.floor(math.log(self.low, base))
2742  highN = math.ceil(math.log(self.high, base))
2743  output = {}
2744  for n in range(int(lowN), int(highN)+1):
2745  x = base**n
2746  label = format(x)
2747  if self.low <= x <= self.high: output[x] = label
2748 
2749  for i in range(1, len(output)):
2750  keys = sorted(output.keys())
2751  keys = keys[::i]
2752  values = map(lambda k: output[k], keys)
2753  if len(values) <= N:
2754  for k in output.keys():
2755  if k not in keys:
2756  output[k] = ""
2757  break
2758 
2759  if len(output) <= 2:
2760  output2 = self.compute_ticks(N=-int(math.ceil(N/2.)), format=format)
2761  lowest = min(output2)
2762 
2763  for k in output:
2764  if k < lowest: output2[k] = output[k]
2765  output = output2
2766 
2767  return output
const uint16_t range(const Frame &aFrame)
def compute_logticks
Definition: svgfig.py:2718
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
T min(T a, T b)
Definition: MathUtil.h:58
def compute_ticks
Definition: svgfig.py:2602
def svgfig.Ticks.compute_miniticks (   self,
  original_ticks 
)
Return optimal linear miniticks, given a set of ticks.

Normally only used internally.

Definition at line 2690 of file svgfig.py.

References funct.abs(), svgfig.Curve.high, svgfig.Line.high, svgfig.Rect.high, svgfig.Ellipse.high, svgfig.Ticks.high, svgfig.Curve.low, svgfig.Line.low, svgfig.Rect.low, svgfig.Ellipse.low, svgfig.Ticks.low, min(), sistrip::SpyUtilities.range(), and svgfig.Ticks.ticks.

Referenced by svgfig.Ticks.interpret().

2691  def compute_miniticks(self, original_ticks):
2692  """Return optimal linear miniticks, given a set of ticks.
2693 
2694  Normally only used internally.
2695  """
2696  if len(original_ticks) < 2: original_ticks = ticks(self.low, self.high)
2697  original_ticks = sorted(original_ticks.keys())
2698 
2699  if self.low > original_ticks[0] + _epsilon or self.high < original_ticks[-1] - _epsilon:
2700  raise ValueError("original_ticks {%g...%g} extend beyond [%g, %g]" % (original_ticks[0], original_ticks[-1], self.low, self.high))
2701 
2702  granularities = []
2703  for i in range(len(original_ticks)-1):
2704  granularities.append(original_ticks[i+1] - original_ticks[i])
2705  spacing = 10**(math.ceil(math.log10(min(granularities)) - 1))
2706 
2707  output = []
2708  x = original_ticks[0] - math.ceil(1.*(original_ticks[0] - self.low) / spacing) * spacing
2709 
2710  while x <= self.high:
2711  if x >= self.low:
2712  already_in_ticks = False
2713  for t in original_ticks:
2714  if abs(x-t) < _epsilon * (self.high - self.low): already_in_ticks = True
2715  if not already_in_ticks: output.append(x)
2716  x += spacing
2717  return output
def compute_miniticks
Definition: svgfig.py:2690
const uint16_t range(const Frame &aFrame)
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
T min(T a, T b)
Definition: MathUtil.h:58
def svgfig.Ticks.compute_ticks (   self,
  N,
  format 
)
Return less than -N or exactly N optimal linear ticks.

Normally only used internally.

Definition at line 2602 of file svgfig.py.

References funct.abs(), svgfig.Curve.high, svgfig.Line.high, svgfig.Rect.high, svgfig.Ellipse.high, svgfig.Ticks.high, svgfig.Curve.low, svgfig.Line.low, svgfig.Rect.low, svgfig.Ellipse.low, svgfig.Ticks.low, SiStripPI.max, and sistrip::SpyUtilities.range().

Referenced by svgfig.Ticks.compute_logticks(), and svgfig.Ticks.interpret().

2603  def compute_ticks(self, N, format):
2604  """Return less than -N or exactly N optimal linear ticks.
2605 
2606  Normally only used internally.
2607  """
2608  if self.low >= self.high: raise ValueError("low must be less than high")
2609  if N == 1: raise ValueError("N can be 0 or >1 to specify the exact number of ticks or negative to specify a maximum")
2610 
2611  eps = _epsilon * (self.high - self.low)
2612 
2613  if N >= 0:
2614  output = {}
2615  x = self.low
2616  for i in range(N):
2617  if format == unumber and abs(x) < eps: label = u"0"
2618  else: label = format(x)
2619  output[x] = label
2620  x += (self.high - self.low)/(N-1.)
2621  return output
2622 
2623  N = -N
2624 
2625  counter = 0
2626  granularity = 10**math.ceil(math.log10(max(abs(self.low), abs(self.high))))
2627  lowN = math.ceil(1.*self.low / granularity)
2628  highN = math.floor(1.*self.high / granularity)
2629 
2630  while (lowN > highN):
2631  countermod3 = counter % 3
2632  if countermod3 == 0: granularity *= 0.5
2633  elif countermod3 == 1: granularity *= 0.4
2634  else: granularity *= 0.5
2635  counter += 1
2636  lowN = math.ceil(1.*self.low / granularity)
2637  highN = math.floor(1.*self.high / granularity)
2638 
2639  last_granularity = granularity
2640  last_trial = None
2641 
2642  while True:
2643  trial = {}
2644  for n in range(int(lowN), int(highN)+1):
2645  x = n * granularity
2646  if format == unumber and abs(x) < eps: label = u"0"
2647  else: label = format(x)
2648  trial[x] = label
2649 
2650  if int(highN)+1 - int(lowN) >= N:
2651  if last_trial == None:
2652  v1, v2 = self.low, self.high
2653  return {v1: format(v1), v2: format(v2)}
2654  else:
2655  low_in_ticks, high_in_ticks = False, False
2656  for t in last_trial.keys():
2657  if 1.*abs(t - self.low)/last_granularity < _epsilon: low_in_ticks = True
2658  if 1.*abs(t - self.high)/last_granularity < _epsilon: high_in_ticks = True
2659 
2660  lowN = 1.*self.low / last_granularity
2661  highN = 1.*self.high / last_granularity
2662  if abs(lowN - round(lowN)) < _epsilon and not low_in_ticks:
2663  last_trial[self.low] = format(self.low)
2664  if abs(highN - round(highN)) < _epsilon and not high_in_ticks:
2665  last_trial[self.high] = format(self.high)
2666  return last_trial
2667 
2668  last_granularity = granularity
2669  last_trial = trial
2670 
2671  countermod3 = counter % 3
2672  if countermod3 == 0: granularity *= 0.5
2673  elif countermod3 == 1: granularity *= 0.4
2674  else: granularity *= 0.5
2675  counter += 1
2676  lowN = math.ceil(1.*self.low / granularity)
2677  highN = math.floor(1.*self.high / granularity)
const uint16_t range(const Frame &aFrame)
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
def compute_ticks
Definition: svgfig.py:2602
def svgfig.Ticks.interpret (   self)
Evaluate and return optimal ticks and miniticks according to
the standard minitick specification.

Normally only used internally.

Definition at line 2508 of file svgfig.py.

References funct.abs(), svgfig.Ticks.compute_logminiticks(), svgfig.Ticks.compute_logticks(), svgfig.Ticks.compute_miniticks(), svgfig.Ticks.compute_ticks(), svgfig.Curve.high, svgfig.Line.high, svgfig.Rect.high, svgfig.Ellipse.high, svgfig.Ticks.high, svgfig.Ticks.labels, svgfig.Ticks.logbase, svgfig.Curve.low, svgfig.Line.low, svgfig.Rect.low, svgfig.Ellipse.low, svgfig.Ticks.low, svgfig.Ticks.miniticks, svgfig.Ticks.regular_miniticks(), and svgfig.Ticks.ticks.

2509  def interpret(self):
2510  """Evaluate and return optimal ticks and miniticks according to
2511  the standard minitick specification.
2512 
2513  Normally only used internally.
2514  """
2515 
2516  if self.labels == None or self.labels == False:
2517  format = lambda x: ""
2518 
2519  elif self.labels == True:
2520  format = unumber
2521 
2522  elif isinstance(self.labels, str):
2523  format = lambda x: (self.labels % x)
2524 
2525  elif callable(self.labels):
2526  format = self.labels
2527 
2528  else: raise TypeError("labels must be None/False, True, a format string, or a number->string function")
2529 
2530  # Now for the ticks
2531  ticks = self.ticks
2532 
2533  # Case 1: ticks is None/False
2534  if ticks == None or ticks == False: return {}, []
2535 
2536  # Case 2: ticks is the number of desired ticks
2537  elif isinstance(ticks, (int, long)):
2538  if ticks == True: ticks = -10
2539 
2540  if self.logbase == None:
2541  ticks = self.compute_ticks(ticks, format)
2542  else:
2543  ticks = self.compute_logticks(self.logbase, ticks, format)
2544 
2545  # Now for the miniticks
2546  if self.miniticks == True:
2547  if self.logbase == None:
2548  return ticks, self.compute_miniticks(ticks)
2549  else:
2550  return ticks, self.compute_logminiticks(self.logbase)
2551 
2552  elif isinstance(self.miniticks, (int, long)):
2553  return ticks, self.regular_miniticks(self.miniticks)
2554 
2555  elif getattr(self.miniticks, "__iter__", False):
2556  return ticks, self.miniticks
2557 
2558  elif self.miniticks == False or self.miniticks == None:
2559  return ticks, []
2560 
2561  else:
2562  raise TypeError("miniticks must be None/False, True, a number of desired miniticks, or a list of numbers")
2563 
2564  # Cases 3 & 4: ticks is iterable
2565  elif getattr(ticks, "__iter__", False):
2566 
2567  # Case 3: ticks is some kind of list
2568  if not isinstance(ticks, dict):
2569  output = {}
2570  eps = _epsilon * (self.high - self.low)
2571  for x in ticks:
2572  if format == unumber and abs(x) < eps:
2573  output[x] = u"0"
2574  else:
2575  output[x] = format(x)
2576  ticks = output
2577 
2578  # Case 4: ticks is a dict
2579  else: pass
2580 
2581  # Now for the miniticks
2582  if self.miniticks == True:
2583  if self.logbase == None:
2584  return ticks, self.compute_miniticks(ticks)
2585  else:
2586  return ticks, self.compute_logminiticks(self.logbase)
2587 
2588  elif isinstance(self.miniticks, (int, long)):
2589  return ticks, self.regular_miniticks(self.miniticks)
2590 
2591  elif getattr(self.miniticks, "__iter__", False):
2592  return ticks, self.miniticks
2593 
2594  elif self.miniticks == False or self.miniticks == None:
2595  return ticks, []
2596 
2597  else:
2598  raise TypeError("miniticks must be None/False, True, a number of desired miniticks, or a list of numbers")
2599 
2600  else:
2601  raise TypeError("ticks must be None/False, a number of desired ticks, a list of numbers, or a dictionary of explicit markers")
def compute_logminiticks
Definition: svgfig.py:2768
def compute_miniticks
Definition: svgfig.py:2690
def interpret
Definition: svgfig.py:2508
def compute_logticks
Definition: svgfig.py:2718
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
def compute_ticks
Definition: svgfig.py:2602
def regular_miniticks
Definition: svgfig.py:2678
def svgfig.Ticks.orient_tickmark (   self,
  t,
  trans = None 
)
Return the position, normalized local x vector, normalized
local y vector, and angle of a tick at position t.

Normally only used internally.

Definition at line 2409 of file svgfig.py.

References funct.abs(), hippyaddtobaddatafiles.KeepWhileOpenFile.f, svgfig.Curve.f, svgfig.Line.f, svgfig.Rect.f, svgfig.Ellipse.f, svgfig.Ticks.f, svgfig.Curve.high, svgfig.Line.high, svgfig.Rect.high, svgfig.Ellipse.high, svgfig.Ticks.high, svgfig.Curve.low, svgfig.Line.low, svgfig.Rect.low, svgfig.Ellipse.low, svgfig.Ticks.low, and svgfig.totrans().

2410  def orient_tickmark(self, t, trans=None):
2411  """Return the position, normalized local x vector, normalized
2412  local y vector, and angle of a tick at position t.
2413 
2414  Normally only used internally.
2415  """
2416  if isinstance(trans, str): trans = totrans(trans)
2417  if trans == None:
2418  f = self.f
2419  else:
2420  f = lambda t: trans(*self.f(t))
2421 
2422  eps = _epsilon * abs(self.high - self.low)
2423 
2424  X, Y = f(t)
2425  Xprime, Yprime = f(t + eps)
2426  xhatx, xhaty = (Xprime - X)/eps, (Yprime - Y)/eps
2427 
2428  norm = math.sqrt(xhatx**2 + xhaty**2)
2429  if norm != 0: xhatx, xhaty = xhatx/norm, xhaty/norm
2430  else: xhatx, xhaty = 1., 0.
2431 
2432  angle = math.atan2(xhaty, xhatx) + math.pi/2.
2433  yhatx, yhaty = math.cos(angle), math.sin(angle)
2434 
2435  return (X, Y), (xhatx, xhaty), (yhatx, yhaty), angle
def totrans
Definition: svgfig.py:598
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
def orient_tickmark
Definition: svgfig.py:2409
def svgfig.Ticks.regular_miniticks (   self,
  N 
)
Return exactly N linear ticks.

Normally only used internally.

Definition at line 2678 of file svgfig.py.

References svgfig.Curve.high, svgfig.Line.high, svgfig.Rect.high, svgfig.Ellipse.high, svgfig.Ticks.high, svgfig.Curve.low, svgfig.Line.low, svgfig.Rect.low, svgfig.Ellipse.low, svgfig.Ticks.low, and sistrip::SpyUtilities.range().

Referenced by svgfig.Ticks.interpret().

2679  def regular_miniticks(self, N):
2680  """Return exactly N linear ticks.
2681 
2682  Normally only used internally.
2683  """
2684  output = []
2685  x = self.low
2686  for i in range(N):
2687  output.append(x)
2688  x += (self.high - self.low)/(N-1.)
2689  return output
const uint16_t range(const Frame &aFrame)
def regular_miniticks
Definition: svgfig.py:2678
def svgfig.Ticks.SVG (   self,
  trans = None 
)
Apply the transformation "trans" and return an SVG object.

Definition at line 2436 of file svgfig.py.

References svgfig.totrans().

2437  def SVG(self, trans=None):
2438  """Apply the transformation "trans" and return an SVG object."""
2439  if isinstance(trans, str): trans = totrans(trans)
2441  self.last_ticks, self.last_miniticks = self.interpret()
2442  tickmarks = Path([], **self.attr)
2443  minitickmarks = Path([], **self.attr)
2444  output = SVG("g")
2445 
2446  if (self.arrow_start != False and self.arrow_start != None) or (self.arrow_end != False and self.arrow_end != None):
2447  defs = SVG("defs")
2448 
2449  if self.arrow_start != False and self.arrow_start != None:
2450  if isinstance(self.arrow_start, SVG):
2451  defs.append(self.arrow_start)
2452  elif isinstance(self.arrow_start, str):
2453  defs.append(make_marker(self.arrow_start, "arrow_start"))
2454  else:
2455  raise TypeError("arrow_start must be False/None or an id string for the new marker")
2456 
2457  if self.arrow_end != False and self.arrow_end != None:
2458  if isinstance(self.arrow_end, SVG):
2459  defs.append(self.arrow_end)
2460  elif isinstance(self.arrow_end, str):
2461  defs.append(make_marker(self.arrow_end, "arrow_end"))
2462  else:
2463  raise TypeError("arrow_end must be False/None or an id string for the new marker")
2464 
2465  output.append(defs)
2466 
2467  eps = _epsilon * (self.high - self.low)
2468 
2469  for t, label in self.last_ticks.items():
2470  (X, Y), (xhatx, xhaty), (yhatx, yhaty), angle = self.orient_tickmark(t, trans)
2471 
2472  if (not self.arrow_start or abs(t - self.low) > eps) and (not self.arrow_end or abs(t - self.high) > eps):
2473  tickmarks.d.append(("M", X - yhatx*self.tick_start, Y - yhaty*self.tick_start, True))
2474  tickmarks.d.append(("L", X - yhatx*self.tick_end, Y - yhaty*self.tick_end, True))
2475 
2476  angle = (angle - math.pi/2.)*180./math.pi + self.text_angle
2477 
2478  ########### a HACK! ############ (to be removed when Inkscape handles baselines)
2479  if _hacks["inkscape-text-vertical-shift"]:
2480  if self.text_start > 0:
2481  X += math.cos(angle*math.pi/180. + math.pi/2.) * 2.
2482  Y += math.sin(angle*math.pi/180. + math.pi/2.) * 2.
2483  else:
2484  X += math.cos(angle*math.pi/180. + math.pi/2.) * 2. * 2.5
2485  Y += math.sin(angle*math.pi/180. + math.pi/2.) * 2. * 2.5
2486  ########### end hack ###########
2487 
2488  if label != "":
2489  output.append(SVG("text", label, transform="translate(%g, %g) rotate(%g)" % \
2490  (X - yhatx*self.text_start, Y - yhaty*self.text_start, angle), **self.text_attr))
2491 
2492  for t in self.last_miniticks:
2493  skip = False
2494  for tt in self.last_ticks.keys():
2495  if abs(t - tt) < eps:
2496  skip = True
2497  break
2498  if not skip:
2499  (X, Y), (xhatx, xhaty), (yhatx, yhaty), angle = self.orient_tickmark(t, trans)
2500 
2501  if (not self.arrow_start or abs(t - self.low) > eps) and (not self.arrow_end or abs(t - self.high) > eps):
2502  minitickmarks.d.append(("M", X - yhatx*self.minitick_start, Y - yhaty*self.minitick_start, True))
2503  minitickmarks.d.append(("L", X - yhatx*self.minitick_end, Y - yhaty*self.minitick_end, True))
2504 
2505  output.prepend(tickmarks.SVG(trans))
2506  output.prepend(minitickmarks.SVG(trans))
2507  return output
int text_angle
Definition: svgfig.py:2387
def interpret
Definition: svgfig.py:2508
float tick_end
Definition: svgfig.py:2383
def totrans
Definition: svgfig.py:598
float minitick_end
Definition: svgfig.py:2385
def make_marker
Definition: svgfig.py:1965
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
def orient_tickmark
Definition: svgfig.py:2409
float tick_start
Definition: svgfig.py:2382
float minitick_start
Definition: svgfig.py:2384
float text_start
Definition: svgfig.py:2386

Member Data Documentation

svgfig.Ticks.arrow_end

Definition at line 2401 of file svgfig.py.

Referenced by svgfig.CurveAxis.SVG().

svgfig.Ticks.arrow_start

Definition at line 2400 of file svgfig.py.

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

svgfig.Ticks.attr

Definition at line 2403 of file svgfig.py.

Referenced by svgfig.Ticks.__repr__(), svgfig.Axes.__repr__(), svgfig.HGrid.__repr__(), svgfig.VGrid.__repr__(), svgfig.Grid.__repr__(), svgfig.Axes.SVG(), svgfig.XErrorBars.SVG(), and svgfig.YErrorBars.SVG().

dictionary svgfig.Ticks.defaults = {"stroke-width":"0.25pt"}
static

Definition at line 2380 of file svgfig.py.

Referenced by tree.Tree.reset(), and tree.Tree.var().

svgfig.Ticks.f

Definition at line 2393 of file svgfig.py.

Referenced by svgfig.Ticks.__repr__(), ztail.Decoder.initial_synchronize(), and svgfig.Ticks.orient_tickmark().

svgfig.Ticks.high

Definition at line 2395 of file svgfig.py.

Referenced by svgfig.Ticks.__repr__(), svgfig.HGrid.__repr__(), svgfig.VGrid.__repr__(), svgfig.Ticks.compute_logminiticks(), svgfig.Ticks.compute_logticks(), svgfig.Ticks.compute_miniticks(), svgfig.Ticks.compute_ticks(), svgfig.Ticks.interpret(), svgfig.Ticks.orient_tickmark(), and svgfig.Ticks.regular_miniticks().

svgfig.Ticks.labels

Definition at line 2398 of file svgfig.py.

Referenced by svgfig.Ticks.__repr__(), svgfig.CurveAxis.__repr__(), svgfig.LineAxis.__repr__(), svgfig.XAxis.__repr__(), svgfig.YAxis.__repr__(), confdb.HLTProcess.dump(), and svgfig.Ticks.interpret().

svgfig.Ticks.last_miniticks

Definition at line 2440 of file svgfig.py.

svgfig.Ticks.logbase

Definition at line 2399 of file svgfig.py.

Referenced by svgfig.Ticks.interpret().

svgfig.Ticks.low

Definition at line 2394 of file svgfig.py.

Referenced by svgfig.Ticks.__repr__(), svgfig.HGrid.__repr__(), svgfig.VGrid.__repr__(), svgfig.Ticks.compute_logminiticks(), svgfig.Ticks.compute_logticks(), svgfig.Ticks.compute_miniticks(), svgfig.Ticks.compute_ticks(), svgfig.Ticks.interpret(), svgfig.Ticks.orient_tickmark(), and svgfig.Ticks.regular_miniticks().

float svgfig.Ticks.minitick_end = 0.75
static

Definition at line 2385 of file svgfig.py.

float svgfig.Ticks.minitick_start = -0.75
static

Definition at line 2384 of file svgfig.py.

svgfig.Ticks.miniticks

Definition at line 2397 of file svgfig.py.

Referenced by svgfig.HGrid.__repr__(), svgfig.VGrid.__repr__(), svgfig.Grid.__repr__(), and svgfig.Ticks.interpret().

int svgfig.Ticks.text_angle = 0
static

Definition at line 2387 of file svgfig.py.

svgfig.Ticks.text_attr

Definition at line 2406 of file svgfig.py.

Referenced by svgfig.Axes.SVG().

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

Definition at line 2381 of file svgfig.py.

Referenced by svgfig.CurveAxis.__init__().

float svgfig.Ticks.text_start = 2.5
static

Definition at line 2386 of file svgfig.py.

float svgfig.Ticks.tick_end = 1.5
static

Definition at line 2383 of file svgfig.py.

float svgfig.Ticks.tick_start = -1.5
static

Definition at line 2382 of file svgfig.py.

svgfig.Ticks.ticks

Definition at line 2396 of file svgfig.py.

Referenced by svgfig.Ticks.__repr__(), svgfig.CurveAxis.__repr__(), svgfig.LineAxis.__repr__(), svgfig.XAxis.__repr__(), svgfig.YAxis.__repr__(), svgfig.HGrid.__repr__(), svgfig.VGrid.__repr__(), svgfig.Grid.__repr__(), svgfig.Ticks.compute_miniticks(), and svgfig.Ticks.interpret().