MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / set_positions

Method set_positions

lib/matplotlib/collections.py:1970–1983  ·  view source on GitHub ↗

Set the positions of the events.

(self, positions)

Source from the content-addressed store, hash-verified

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."""

Callers 2

__init__Method · 0.95
add_positionsMethod · 0.95

Calls 4

get_lineoffsetMethod · 0.95
get_linelengthMethod · 0.95
is_horizontalMethod · 0.95
set_segmentsMethod · 0.45

Tested by

no test coverage detected