CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros 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 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.

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
2403  self.attr = dict(self.defaults)
2404  self.attr.update(attr)
2406  self.text_attr = dict(self.text_defaults)
2407  self.text_attr.update(text_attr)
def __init__
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)

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

2389  def __repr__(self):
2390  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:2388
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, svgfig.Curve.low, svgfig.Line.low, svgfig.Rect.low, svgfig.Ellipse.low, and svgfig.Ticks.low.

Referenced by svgfig.Ticks.interpret().

2770  def compute_logminiticks(self, base):
2771  """Return optimal logarithmic miniticks, given a set of ticks.
2772 
2773  Normally only used internally.
2774  """
2775  if self.low >= self.high: raise ValueError, "low must be less than high"
2776 
2777  lowN = math.floor(math.log(self.low, base))
2778  highN = math.ceil(math.log(self.high, base))
2779  output = []
2780  num_ticks = 0
2781  for n in range(int(lowN), int(highN)+1):
2782  x = base**n
2783  if self.low <= x <= self.high: num_ticks += 1
2784  for m in range(2, int(math.ceil(base))):
2785  minix = m * x
2786  if self.low <= minix <= self.high: output.append(minix)
2787 
2788  if num_ticks <= 2: return []
2789  else: return output
def compute_logminiticks
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 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, python.multivaluedict.map(), and min.

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 xrange(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 = output.keys()
2751  keys.sort()
2752  keys = keys[::i]
2753  values = map(lambda k: output[k], keys)
2754  if len(values) <= N:
2755  for k in output.keys():
2756  if k not in keys:
2757  output[k] = ""
2758  break
2759 
2760  if len(output) <= 2:
2761  output2 = self.compute_ticks(N=-int(math.ceil(N/2.)), format=format)
2762  lowest = min(output2)
2763 
2764  for k in output:
2765  if k < lowest: output2[k] = output[k]
2766  output = output2
2767 
2768  return output
#define abs(x)
Definition: mlp_lapack.h:159
#define min(a, b)
Definition: mlp_lapack.h:161
def compute_logticks
Definition: svgfig.py:2718
def compute_ticks
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 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 = original_ticks.keys()
2697  original_ticks.sort()
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
#define abs(x)
Definition: mlp_lapack.h:159
#define min(a, b)
Definition: mlp_lapack.h:161
def compute_miniticks
Definition: svgfig.py:2689
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 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, and 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 xrange(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)
#define abs(x)
Definition: mlp_lapack.h:159
const T & max(const T &a, const T &b)
def compute_ticks
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 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, basestring):
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"
def compute_logminiticks
Definition: svgfig.py:2769
#define abs(x)
Definition: mlp_lapack.h:159
def compute_miniticks
Definition: svgfig.py:2689
def interpret
Definition: svgfig.py:2507
def compute_logticks
Definition: svgfig.py:2718
def compute_ticks
Definition: svgfig.py:2601
def regular_miniticks
Definition: svgfig.py:2677
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 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().

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, basestring): 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
#define abs(x)
Definition: mlp_lapack.h:159
def totrans
Definition: svgfig.py:597
def orient_tickmark
Definition: svgfig.py:2408
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().

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 xrange(N):
2686  output.append(x)
2687  x += (self.high - self.low)/(N-1.)
2688  return output
def regular_miniticks
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().

2436  def SVG(self, trans=None):
2437  """Apply the transformation "trans" and return an SVG object."""
2438  if isinstance(trans, basestring): trans = totrans(trans)
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, basestring):
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, basestring):
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
int text_angle
Definition: svgfig.py:2386
#define abs(x)
Definition: mlp_lapack.h:159
def interpret
Definition: svgfig.py:2507
float tick_end
Definition: svgfig.py:2382
def totrans
Definition: svgfig.py:597
float minitick_end
Definition: svgfig.py:2384
def make_marker
Definition: svgfig.py:1964
def orient_tickmark
Definition: svgfig.py:2408
float tick_start
Definition: svgfig.py:2381
float minitick_start
Definition: svgfig.py:2383
float text_start
Definition: svgfig.py:2385

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

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

svgfig.Ticks.f

Definition at line 2392 of file svgfig.py.

Referenced by svgfig.Ticks.__repr__(), Vispa.Views.RootCanvasView.RootCanvasView.createGraph(), Vispa.Views.RootCanvasView.RootCanvasView.createLegoPlot(), and svgfig.Ticks.orient_tickmark().

svgfig.Ticks.high

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

svgfig.Ticks.labels

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

svgfig.Ticks.logbase

Definition at line 2398 of file svgfig.py.

Referenced by svgfig.Ticks.interpret().

svgfig.Ticks.low

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

float svgfig.Ticks.minitick_start = -0.75
static

Definition at line 2383 of file svgfig.py.

svgfig.Ticks.miniticks

Definition at line 2396 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 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

Definition at line 2395 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().