1 # -*- coding: utf-8 -*-
3 # Copyright (C) 2000-2005 by Yasushi Saito (yasushi.saito@gmail.com)
5 # Jockey is free software; you can redistribute it and/or modify it
6 # under the terms of the GNU General Public License as published by the
7 # Free Software Foundation; either version 2, or (at your option) any
10 # Jockey is distributed in the hope that it will be useful, but WITHOUT
11 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
23 from pychart_types import *
25 __doc__ = """Pychart offers several styles of error bars. Some of them
26 only displays the min/max confidence interval, while others can display
27 quartiles in addition to min/max."""
29 class T(chart_object.T):
31 ##AUTOMATICALLY GENERATED
33 ##END AUTOMATICALLY GENERATED
36 # Two horizontal lines at min & max locations.
38 __doc__ = error_bar_doc.doc_1
39 keys = {"tic_len" : (UnitType, 10, "Length of the horizontal bars"),
40 "line_style": (line_style.T, line_style.default, "")
42 ##AUTOMATICALLY GENERATED
44 ##END AUTOMATICALLY GENERATED
45 def draw(self, can, loc, min, max, qmin = None, qmax = None):
48 can.line(self.line_style, x-self.tic_len/2.0, y, x+self.tic_len/2.0, y)
50 can.line(self.line_style, x-self.tic_len/2.0, y, x+self.tic_len/2.0, y)
53 __doc__ = error_bar_doc.doc_2
54 keys = {"tic_len" : (UnitType, 3,
55 "The length of the horizontal bars"),
56 "hline_style": (line_style.T, line_style.default,
57 "The style of the horizontal bars."),
58 "vline_style": (line_style.T, None,
59 "The style of the vertical bar.")
62 ##AUTOMATICALLY GENERATED
64 ##END AUTOMATICALLY GENERATED
65 def draw(self, can, loc, min, max, qmin = None, qmax = None):
66 vline_style = self.vline_style
68 vline_style = self.hline_style
71 can.line(self.hline_style, x-self.tic_len/2.0, y1, x+self.tic_len/2.0, y1)
73 can.line(self.hline_style, x-self.tic_len/2.0, y2, x+self.tic_len/2.0, y2)
74 can.line(vline_style, x, y1, x, y2)
78 __doc__ = "This style is endorsed by the Tufte's books. " \
80 keys = { "line_style": (line_style.T, line_style.default, "")
83 ##AUTOMATICALLY GENERATED
85 ##END AUTOMATICALLY GENERATED
86 def draw(self, can, loc, min, max, qmin, qmax):
88 can.line(self.line_style, x, min, x, qmin)
89 can.line(self.line_style, x, qmax, x, max)
92 __doc__ = error_bar_doc.doc_4
93 keys = { "line_style": (line_style.T, line_style.default, ""),
94 "fill_style": (fill_style.T, fill_style.gray70, ""),
95 "box_width": (UnitType, 4, ""),
96 "tic_len": (UnitType, 4, "")
98 ##AUTOMATICALLY GENERATED
100 ##END AUTOMATICALLY GENERATED
101 def draw(self, can, loc, min, max, qmin, qmax):
103 style = self.line_style
105 can.line(style, x-self.tic_len/2.0, y1, x+self.tic_len/2.0, y1)
107 can.line(style, x-self.tic_len/2.0, y2, x+self.tic_len/2.0, y2)
108 can.line(style, x, y1, x, y2)
110 can.rectangle(style, self.fill_style,
111 x-self.box_width/2.0, qmin,
112 x+self.box_width/2.0, qmax)
116 __doc__ = error_bar_doc.doc_5
117 keys = { "line_style": (line_style.T, line_style.default, "")
119 ##AUTOMATICALLY GENERATED
121 ##END AUTOMATICALLY GENERATED
122 def draw(self, can, loc, min, max, qmin = None, qmax = None):
126 min = (min - y) *1 + y
127 max = (max - y) *1+ y
128 can.line(self.line_style, x, min, x, max)
132 __doc__ = error_bar_doc.doc_6
133 keys = { "line_style": (line_style.T, line_style.default, ""),
134 "fill_style": (fill_style.T, fill_style.gray70, ""),
135 "center_line_style": (line_style.T, line_style.T(width=0.5), ""),
136 "box_width": (UnitType, 4, ""),
138 ##AUTOMATICALLY GENERATED
140 ##END AUTOMATICALLY GENERATED
141 def draw(self, can, loc, min, max, qmin = None, qmax = None):
145 can.rectangle(self.line_style, self.fill_style,
146 x - self.box_width / 2.0, min,
147 x + self.box_width / 2.0, max)
148 can.line(self.center_line_style,
149 x - self.box_width/2.0, (min+max)/2.0,
150 x + self.box_width/2.0, (min+max)/2.0)
159 standards = object_set.T(bar1, bar2, bar3, bar4, bar5, bar6)