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

Function test_pan

lib/mpl_toolkits/mplot3d/tests/test_axes3d.py:2067–2103  ·  view source on GitHub ↗

Test mouse panning using the middle mouse button.

()

Source from the content-addressed store, hash-verified

2065
2066
2067def test_pan():
2068 """Test mouse panning using the middle mouse button."""
2069
2070 def convert_lim(dmin, dmax):
2071 """Convert min/max limits to center and range."""
2072 center = (dmin + dmax) / 2
2073 range_ = dmax - dmin
2074 return center, range_
2075
2076 fig = plt.figure()
2077 ax = fig.add_subplot(projection='3d')
2078 ax.scatter(0, 0, 0)
2079 fig.canvas.draw()
2080
2081 x_center0, x_range0 = convert_lim(*ax.get_xlim3d())
2082 y_center0, y_range0 = convert_lim(*ax.get_ylim3d())
2083 z_center0, z_range0 = convert_lim(*ax.get_zlim3d())
2084
2085 # move mouse diagonally to pan along all axis.
2086 MouseEvent._from_ax_coords(
2087 "button_press_event", ax, (0, 0), MouseButton.MIDDLE)._process()
2088 MouseEvent._from_ax_coords(
2089 "motion_notify_event", ax, (1, 1), MouseButton.MIDDLE)._process()
2090
2091 x_center, x_range = convert_lim(*ax.get_xlim3d())
2092 y_center, y_range = convert_lim(*ax.get_ylim3d())
2093 z_center, z_range = convert_lim(*ax.get_zlim3d())
2094
2095 # Ranges have not changed
2096 assert x_range == pytest.approx(x_range0)
2097 assert y_range == pytest.approx(y_range0)
2098 assert z_range == pytest.approx(z_range0)
2099
2100 # But center positions have
2101 assert x_center != pytest.approx(x_center0)
2102 assert y_center != pytest.approx(y_center0)
2103 assert z_center != pytest.approx(z_center0)
2104
2105
2106@pytest.mark.parametrize("tool,button,key,expected",

Callers

nothing calls this directly

Calls 7

convert_limFunction · 0.85
figureMethod · 0.80
add_subplotMethod · 0.80
_processMethod · 0.80
scatterMethod · 0.45
drawMethod · 0.45
_from_ax_coordsMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…