Skip to content

Commit

Permalink
BUG: Update flight trajectory plot axes limits
Browse files Browse the repository at this point in the history
  • Loading branch information
Gui-FernandesBR committed Feb 9, 2024
1 parent db95053 commit 59a5498
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ You can install this version by running `pip install rocketpy==1.2.0`

### Fixed

- BUG: Update flight trajectory plot axes limits [#552](https://github.com/RocketPy-Team/RocketPy/pull/552)
- MNT: small fixes before v1.2 [#550](https://github.com/RocketPy-Team/RocketPy/pull/550)
- BUG: Elliptical Fins Draw [#548](https://github.com/RocketPy-Team/RocketPy/pull/548)
- BUG: 3D trajectory plot not labeling axes [#533](https://github.com/RocketPy-Team/RocketPy/pull/533)
Expand Down
14 changes: 6 additions & 8 deletions rocketpy/plots/flight_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,25 +69,23 @@ def trajectory_3d(self):
min_x = min(self.flight.x[:, 1])
max_y = max(self.flight.y[:, 1])
min_y = min(self.flight.y[:, 1])
max_xy = max(max_x, max_y)
min_xy = min(min_x, min_y)

_ = plt.figure(figsize=(9, 9))
ax1 = plt.subplot(111, projection="3d")
ax1.plot(
self.flight.x[:, 1], self.flight.y[:, 1], zs=0, zdir="z", linestyle="--"
self.flight.x[:, 1], self.flight.y[:, 1], zs=min_z, zdir="z", linestyle="--"
)
ax1.plot(
self.flight.x[:, 1],
self.flight.altitude[:, 1],
zs=min_xy,
zs=min_y,
zdir="y",
linestyle="--",
)
ax1.plot(
self.flight.y[:, 1],
self.flight.altitude[:, 1],
zs=min_xy,
zs=min_x,
zdir="x",
linestyle="--",
)
Expand All @@ -114,9 +112,9 @@ def trajectory_3d(self):
ax1.set_ylabel("Y - North (m)")
ax1.set_zlabel("Z - Altitude Above Ground Level (m)")
ax1.set_title("Flight Trajectory")
ax1.set_zlim3d([min_z, max_z])
ax1.set_ylim3d([min_xy, max_xy])
ax1.set_xlim3d([min_xy, max_xy])
ax1.set_xlim(min_x, max_x)
ax1.set_ylim(min_y, max_y)
ax1.set_zlim(min_z, max_z)
ax1.view_init(15, 45)
ax1.set_box_aspect(None, zoom=0.95) # 95% for label adjustment
plt.show()
Expand Down

0 comments on commit 59a5498

Please sign in to comment.