Set the positions of the events.
(self, positions)
| 1968 | return [segment[0, pos] for segment in self.get_segments()] |
| 1969 | |
| 1970 | def set_positions(self, positions): |
| 1971 | """Set the positions of the events.""" |
| 1972 | if positions is None: |
| 1973 | positions = [] |
| 1974 | if np.ndim(positions) != 1: |
| 1975 | raise ValueError('positions must be one-dimensional') |
| 1976 | lineoffset = self.get_lineoffset() |
| 1977 | linelength = self.get_linelength() |
| 1978 | pos_idx = 0 if self.is_horizontal() else 1 |
| 1979 | segments = np.empty((len(positions), 2, 2)) |
| 1980 | segments[:, :, pos_idx] = np.sort(positions)[:, None] |
| 1981 | segments[:, 0, 1 - pos_idx] = lineoffset + linelength / 2 |
| 1982 | segments[:, 1, 1 - pos_idx] = lineoffset - linelength / 2 |
| 1983 | self.set_segments(segments) |
| 1984 | |
| 1985 | def add_positions(self, position): |
| 1986 | """Add one or more events at the specified positions.""" |
no test coverage detected