Skip to content

Commit

Permalink
Merge pull request #552 from RocketPy-Team/bug/3d-trajectory-plot
Browse files Browse the repository at this point in the history
BUG: Update flight trajectory plot axes limits
  • Loading branch information
Gui-FernandesBR authored Feb 10, 2024
2 parents b221d88 + 3330c5a commit e4e67f4
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)
- BUG: fix `get_controller_observed_variables` in the air brakes examples [#551](https://github.com/RocketPy-Team/RocketPy/pull/551)
- 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)
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 e4e67f4

Please sign in to comment.