docstring for plot
(self, widget, width = 0.6, colorup = 'r', colordown='g', lc='k', alpha=1)
| 99 | # missing they all are missing |
| 100 | @override_attributes |
| 101 | def plot(self, widget, width = 0.6, colorup = 'r', colordown='g', lc='k', alpha=1): |
| 102 | """docstring for plot""" |
| 103 | delta = self.width/2. |
| 104 | barVerts = [ ( (i-delta, open), (i-delta, close), (i+delta, close), (i+delta, open) ) for i, open, close in zip(xrange(len(self.data)), self.data.open, self.data.close) if open != -1 and close!=-1 ] |
| 105 | rangeSegments = [ ((i, low), (i, high)) for i, low, high in zip(xrange(len(self.data)), self.data.low, self.data.high) if low != -1 ] |
| 106 | r,g,b = colorConverter.to_rgb(self.colorup) |
| 107 | colorup = r,g,b,self.alpha |
| 108 | r,g,b = colorConverter.to_rgb(self.colordown) |
| 109 | colordown = r,g,b,self.alpha |
| 110 | colord = { True : colorup, |
| 111 | False : colordown, |
| 112 | } |
| 113 | colors = [colord[open<close] for open, close in zip(self.data.open, self.data.close) if open!=-1 and close !=-1] |
| 114 | assert(len(barVerts)==len(rangeSegments)) |
| 115 | useAA = 0, # use tuple here |
| 116 | lw = 0.5, # and here |
| 117 | r,g,b = colorConverter.to_rgb(self.lc) |
| 118 | linecolor = r,g,b,self.alpha |
| 119 | lineCollection = LineCollection(rangeSegments, |
| 120 | colors = ( linecolor, ), |
| 121 | linewidths = lw, |
| 122 | antialiaseds = useAA, |
| 123 | zorder = 0, |
| 124 | ) |
| 125 | |
| 126 | barCollection = PolyCollection(barVerts, |
| 127 | facecolors = colors, |
| 128 | edgecolors = colors, |
| 129 | antialiaseds = useAA, |
| 130 | linewidths = lw, |
| 131 | zorder = 1, |
| 132 | ) |
| 133 | #minx, maxx = 0, len(rangeSegments) |
| 134 | #miny = min([low for low in self.data.low if low !=-1]) |
| 135 | #maxy = max([high for high in self.data.high if high != -1]) |
| 136 | #corners = (minx, miny), (maxx, maxy) |
| 137 | #ax.update_datalim(corners) |
| 138 | widget.autoscale_view() |
| 139 | # add these last |
| 140 | widget.add_collection(barCollection) |
| 141 | widget.add_collection(lineCollection) |
| 142 | |
| 143 | #ax.plot(self.data.close, color = 'y') |
| 144 | #lineCollection, barCollection = None, None |
| 145 | return lineCollection, barCollection |
| 146 | |
| 147 | def set_yrange(self, lower, upper=[]): |
| 148 | self.upper = upper if len(upper)>0 else lower |
no outgoing calls
no test coverage detected