MCPcopy Index your code
hub / github.com/bqplot/bqplot / update_bands

Method update_bands

bqplot/plotting_widgets.py:107–138  ·  view source on GitHub ↗
(self, *args)

Source from the content-addressed store, hash-verified

105 self.update_data(None)
106
107 def update_bands(self, *args):
108 band_data = np.linspace(
109 self.data_range[0], self.data_range[1], self.num_bands + 1
110 )
111 self.scaled_band_data = (
112 (band_data - self.data_range[0])
113 / (self.data_range[1] - self.data_range[0])
114 )[:, np.newaxis]
115
116 n = len(self.data.index)
117
118 if self.band_type == "circle":
119 t = np.linspace(0, 2 * np.pi, 1000)
120 band_data_x, band_data_y = (
121 self.scaled_band_data * np.cos(t),
122 self.scaled_band_data * np.sin(t),
123 )
124 elif self.band_type == "polygon":
125 t = np.linspace(0, 2 * np.pi, n + 1)
126 band_data_x, band_data_y = (
127 self.scaled_band_data * np.sin(t),
128 self.scaled_band_data * np.cos(t),
129 )
130
131 with self.bands.hold_sync():
132 self.bands.x = band_data_x
133 self.bands.y = band_data_y
134
135 with self.band_labels.hold_sync():
136 self.band_labels.x = self.scaled_band_data[:, 0]
137 self.band_labels.y = [0.0] * (self.num_bands + 1)
138 self.band_labels.text = ["{:.0%}".format(b) for b in band_data]
139
140 def update_data(self, *args):
141 self.update_bands(None)

Callers 2

__init__Method · 0.95
update_dataMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected