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 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.

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

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

2768  def compute_logminiticks(self, base):
2769  """Return optimal logarithmic miniticks, given a set of ticks.
2770 
2771  Normally only used internally.
2772  """
2773  if self.low >= self.high: raise ValueError("low must be less than high")
2774 
2775  lowN = math.floor(math.log(self.low, base))
2776  highN = math.ceil(math.log(self.high, base))
2777  output = []
2778  num_ticks = 0
2779  for n in range(int(lowN), int(highN)+1):
2780  x = base**n
2781  if self.low <= x <= self.high: num_ticks += 1
2782  for m in range(2, int(math.ceil(base))):
2783  minix = m * x
2784  if self.low <= minix <= self.high: output.append(minix)
2785 
2786  if num_ticks <= 2: return []
2787  else: return output
2788 
def compute_logminiticks(self, base)
Definition: svgfig.py:2768
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 range(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 = sorted(output.keys())
2750  keys = keys[::i]
2751  values = map(lambda k: output[k], keys)
2752  if len(values) <= N:
2753  for k in output.keys():
2754  if k not in keys:
2755  output[k] = ""
2756  break
2757 
2758  if len(output) <= 2:
2759  output2 = self.compute_ticks(N=-int(math.ceil(N/2.)), format=format)
2760  lowest = min(output2)
2761 
2762  for k in output:
2763  if k < lowest: output2[k] = output[k]
2764  output = output2
2765 
2766  return output
2767 
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: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(), and svgfig.Ticks.ticks.

Referenced by svgfig.Ticks.interpret().

2690  def compute_miniticks(self, original_ticks):
2691  """Return optimal linear miniticks, given a set of ticks.
2692 
2693  Normally only used internally.
2694  """
2695  if len(original_ticks) < 2: original_ticks = ticks(self.low, self.high)
2696  original_ticks = sorted(original_ticks.keys())
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:2690
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, createfilelist.int, svgfig.Curve.low, svgfig.Line.low, svgfig.Rect.low, svgfig.Ellipse.low, svgfig.Ticks.low, and SiStripPI.max.

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

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

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

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

Referenced by svgfig.Ticks.interpret().

2678  def regular_miniticks(self, N):
2679  """Return exactly N linear ticks.
2680 
2681  Normally only used internally.
2682  """
2683  output = []
2684  x = self.low
2685  for i in range(N):
2686  output.append(x)
2687  x += (self.high - self.low)/(N-1.)
2688  return output
2689 
def regular_miniticks(self, N)
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().

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

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
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
svgfig.Ticks.high
svgfig.Ticks.labels
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
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
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