Closed ccaprani closed 2 years ago
@sewkokot I discovered that I can use the current code without this PR by calling plt.gca().set_box_aspect(None)
once the axes has been created - it allows the box to expand again after the model flattened it.
Two points:
section_force_diagram_3d
is still good, so I leave the PR here for your decision.plt.gca()
workarounds. @ccaprani Thank you for this PR, however I would like to avoid the black tool corrections which hide the meaningful changes. Considering your two points I have provided the axes objects wherever possible to be reusable and added new commits (the pip package is also updated). Also I have added a new optional argument for both 2d and 3d section_force_diagram
functions:
alt_model_plot (int): 1 - for using the plot_model command, 2 - for using
simplified model plotting. Other integer - for no model plotting.
In this case the model can be plotted outside this command
using the axes (ax) object. Default is 1.
Let me know if such changes fix the issue or make the situation better?
Update:
Note that both section_forcediagram2d/3d functions now return three variables: minVal, maxVal, ax
. Alternatively `, _, ax = section_force_diagram_3d(...)` can be used if the min/max values are not needed.
Amazingly quick @sewkokot !
One final tweak is required to section_force_diagram_3d
to handle a passed in axes object. I had suggested:
# If supplied axis can be plotted to
if hasattr(ax, "name") and (ax.name == "3d"):
pass
else:
azim, elev = az_el
fig_wi, fig_he = fig_wi_he
fleft, fbottom, fright, ftop = fig_lbrt
fig = plt.figure(figsize=(fig_wi / 2.54, fig_he / 2.54))
fig.subplots_adjust(left=0.08, bottom=0.08, right=0.985, top=0.94)
ax = fig.add_subplot(111, projection=Axes3D.name)
# ax.axis('equal')
ax.view_init(azim=azim, elev=elev)
ax.set_xlabel("X")
ax.set_ylabel("Y")
ax.set_zlabel("Z")
@ccaprani Thank you very much :) I have applied the fix in the new commit and updated the pip package.
The new v1.0+ code rendered 3D force diagrams with unit scale factor flat because the model plotting was called first:
returning to the older means of plotting it element by element gives the correct outcome:
This PR also adds the ability to pass an Axes3D (or subplot) object to
section_force_diagram_3d
for plotting, and also removes theEw
from the docs (due to update).With apologies: I format with black on save, so it looks like there are more changes than there are!