| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| import matplotlib.pyplot as plt | ||
|
|
||
| from matplotlib.backend_bases import MouseEvent | ||
|
|
||
|
|
||
| def test_scatter_3d_projection_conservation(): | ||
| fig = plt.figure() | ||
| ax = fig.add_subplot(projection='3d') | ||
| # fix axes3d projection | ||
| ax.roll = 0 | ||
| ax.elev = 0 | ||
| ax.azim = -45 | ||
| ax.stale = True | ||
|
|
||
| x = [0, 1, 2, 3, 4] | ||
| scatter_collection = ax.scatter(x, x, x) | ||
| fig.canvas.draw_idle() | ||
|
|
||
| # Get scatter location on canvas and freeze the data | ||
| scatter_offset = scatter_collection.get_offsets() | ||
| scatter_location = ax.transData.transform(scatter_offset) | ||
|
|
||
| # Yaw -44 and -46 are enough to produce two set of scatter | ||
| # with opposite z-order without moving points too far | ||
| for azim in (-44, -46): | ||
| ax.azim = azim | ||
| ax.stale = True | ||
| fig.canvas.draw_idle() | ||
|
|
||
| for i in range(5): | ||
| # Create a mouse event used to locate and to get index | ||
| # from each dots | ||
| event = MouseEvent("button_press_event", fig.canvas, | ||
| *scatter_location[i, :]) | ||
| contains, ind = scatter_collection.contains(event) | ||
| assert contains is True | ||
| assert len(ind["ind"]) == 1 | ||
| assert ind["ind"][0] == i |
| Back | FazBrowse Home | New Git URL |
Uh oh!
There was an error while loading. Please reload this page.