| 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,34 @@ | ||
| *adjustable* keyword argument for setting equal aspect ratios in 3D | ||
| ------------------------------------------------------------------- | ||
|
|
||
| While setting equal aspect ratios for 3D plots, users can choose to modify | ||
| either the data limits or the bounding box. | ||
|
|
||
| .. plot:: | ||
| :include-source: true | ||
|
|
||
| import matplotlib.pyplot as plt | ||
| import numpy as np | ||
| from itertools import combinations, product | ||
|
|
||
| aspects = ('auto', 'equal', 'equalxy', 'equalyz', 'equalxz') | ||
| fig, axs = plt.subplots(1, len(aspects), subplot_kw={'projection': '3d'}, | ||
| figsize=(12, 6)) | ||
|
|
||
| # Draw rectangular cuboid with side lengths [4, 3, 5] | ||
| r = [0, 1] | ||
| scale = np.array([4, 3, 5]) | ||
| pts = combinations(np.array(list(product(r, r, r))), 2) | ||
| for start, end in pts: | ||
| if np.sum(np.abs(start - end)) == r[1] - r[0]: | ||
| for ax in axs: | ||
| ax.plot3D(*zip(start*scale, end*scale), color='C0') | ||
|
|
||
| # Set the aspect ratios | ||
| for i, ax in enumerate(axs): | ||
| ax.set_aspect(aspects[i], adjustable='datalim') | ||
| # Alternatively: ax.set_aspect(aspects[i], adjustable='box') | ||
| # which will change the box aspect ratio instead of axis data limits. | ||
| ax.set_title(f"set_aspect('{aspects[i]}')") | ||
|
|
||
| plt.show() |
| Back | FazBrowse Home | New Git URL |
Uh oh!
There was an error while loading. Please reload this page.