CMS 3D CMS Logo

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__ (self, f, low, high, ticks=-10, miniticks=True, labels=True, logbase=None, arrow_start=None, arrow_end=None, text_attr={}, attr)
 
def __repr__ (self)
 
def compute_logminiticks (self, base)
 
def compute_logticks (self, base, N, format)
 
def compute_miniticks (self, original_ticks)
 
def compute_ticks (self, N, format)
 
def interpret (self)
 
def orient_tickmark (self, t, trans=None)
 
def regular_miniticks (self, N)
 
def SVG (self, trans=None)
 

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

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

Member Function Documentation

def svgfig.Ticks.__repr__ (   self)
def svgfig.Ticks.compute_logminiticks (   self,
  base 
)
Return optimal logarithmic miniticks, given a set of ticks.

Normally only used internally.

Definition at line 2769 of file svgfig.py.

References svgfig.Curve.high, svgfig.Line.high, svgfig.Rect.high, svgfig.Ellipse.high, svgfig.Ticks.high, createfilelist.int, svgfig.Curve.low, svgfig.Line.low, svgfig.Rect.low, svgfig.Ellipse.low, and svgfig.Ticks.low.

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
2789 
def compute_logminiticks(self, base)
Definition: svgfig.py:2769
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, createfilelist.int, svgfig.Curve.low, svgfig.Line.low, svgfig.Rect.low, svgfig.Ellipse.low, svgfig.Ticks.low, genParticles_cff.map, and min().

Referenced by svgfig.Ticks.interpret().

2718  def compute_logticks(self, base, N, format):
2719  """Return less than -N or exactly N optimal logarithmic ticks.
2720 
2721  Normally only used internally.
2722  """
2723  if self.low >= self.high: raise ValueError("low must be less than high")
2724  if N == 1: raise ValueError("N can be 0 or >1 to specify the exact number of ticks or negative to specify a maximum")
2725 
2726  eps = _epsilon * (self.high - self.low)
2727 
2728  if N >= 0:
2729  output = {}
2730  x = self.low
2731  for i in xrange(N):
2732  if format == unumber and abs(x) < eps: label = u"0"
2733  else: label = format(x)
2734  output[x] = label
2735  x += (self.high - self.low)/(N-1.)
2736  return output
2737 
2738  N = -N
2739 
2740  lowN = math.floor(math.log(self.low, base))
2741  highN = math.ceil(math.log(self.high, base))
2742  output = {}
2743  for n in range(int(lowN), int(highN)+1):
2744  x = base**n
2745  label = format(x)
2746  if self.low <= x <= self.high: output[x] = label
2747 
2748  for i in range(1, len(output)):
2749  keys = output.keys()
2750  keys.sort()
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
2768 
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
T min(T a, T b)
Definition: MathUtil.h:58
def compute_logticks(self, base, N, format)
Definition: svgfig.py:2718
def compute_ticks(self, N, format)
Definition: svgfig.py:2601
def svgfig.Ticks.compute_miniticks (   self,
  original_ticks 
)
Return optimal linear miniticks, given a set of ticks.

Normally only used internally.

Definition at line 2689 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(), and svgfig.Ticks.ticks.

Referenced by svgfig.Ticks.interpret().

2689  def compute_miniticks(self, original_ticks):
2690  """Return optimal linear miniticks, given a set of ticks.
2691 
2692  Normally only used internally.
2693  """
2694  if len(original_ticks) < 2: original_ticks = ticks(self.low, self.high)
2695  original_ticks = original_ticks.keys()
2696  original_ticks.sort()
2697 
2698  if self.low > original_ticks[0] + _epsilon or self.high < original_ticks[-1] - _epsilon:
2699  raise ValueError("original_ticks {%g...%g} extend beyond [%g, %g]" % (original_ticks[0], original_ticks[-1], self.low, self.high))
2700 
2701  granularities = []
2702  for i in range(len(original_ticks)-1):
2703  granularities.append(original_ticks[i+1] - original_ticks[i])
2704  spacing = 10**(math.ceil(math.log10(min(granularities)) - 1))
2705 
2706  output = []
2707  x = original_ticks[0] - math.ceil(1.*(original_ticks[0] - self.low) / spacing) * spacing
2708 
2709  while x <= self.high:
2710  if x >= self.low:
2711  already_in_ticks = False
2712  for t in original_ticks:
2713  if abs(x-t) < _epsilon * (self.high - self.low): already_in_ticks = True
2714  if not already_in_ticks: output.append(x)
2715  x += spacing
2716  return output
2717 
def compute_miniticks(self, original_ticks)
Definition: svgfig.py:2689
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 2601 of file svgfig.py.

References funct.abs(), svgfig.Curve.high, svgfig.Line.high, svgfig.Rect.high, svgfig.Ellipse.high, svgfig.Ticks.high, createfilelist.int, svgfig.Curve.low, svgfig.Line.low, svgfig.Rect.low, svgfig.Ellipse.low, svgfig.Ticks.low, and hpstanc_transforms.max.

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

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

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

References funct.abs(), 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().

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

Normally only used internally.

Definition at line 2677 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, and svgfig.Ticks.low.

Referenced by svgfig.Ticks.interpret().

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

Definition at line 2435 of file svgfig.py.

References svgfig.totrans().

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

Member Data Documentation

svgfig.Ticks.arrow_end

Definition at line 2400 of file svgfig.py.

Referenced by svgfig.CurveAxis.SVG().

svgfig.Ticks.arrow_start

Definition at line 2399 of file svgfig.py.

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

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

Definition at line 2379 of file svgfig.py.

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

svgfig.Ticks.f
svgfig.Ticks.high
svgfig.Ticks.labels
svgfig.Ticks.last_miniticks

Definition at line 2439 of file svgfig.py.

svgfig.Ticks.logbase

Definition at line 2398 of file svgfig.py.

Referenced by svgfig.Ticks.interpret().

svgfig.Ticks.low
float svgfig.Ticks.minitick_end = 0.75
static

Definition at line 2384 of file svgfig.py.

float svgfig.Ticks.minitick_start = -0.75
static

Definition at line 2383 of file svgfig.py.

svgfig.Ticks.miniticks
int svgfig.Ticks.text_angle = 0
static

Definition at line 2386 of file svgfig.py.

svgfig.Ticks.text_attr

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

Referenced by svgfig.CurveAxis.__init__().

float svgfig.Ticks.text_start = 2.5
static

Definition at line 2385 of file svgfig.py.

float svgfig.Ticks.tick_end = 1.5
static

Definition at line 2382 of file svgfig.py.

float svgfig.Ticks.tick_start = -1.5
static

Definition at line 2381 of file svgfig.py.

svgfig.Ticks.ticks