Skip to content

Commit

Permalink
BUG: fix the label of 3D trajectory plot and add aesthetics
Browse files Browse the repository at this point in the history
  • Loading branch information
Gui-FernandesBR committed Jan 14, 2024
1 parent 14dd0f6 commit 7f033d8
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ straightforward as possible.
- ENH: Parachute trigger doesn't work if "Apogee" is used instead of "apogee" [#489](https://github.com/RocketPy-Team/RocketPy/pull/489)
- BUG: fin_flutter_analysis doesn't find any fin set [#510](https://github.com/RocketPy-Team/RocketPy/pull/510)
- FIX: EmptyMotor is breaking the Rocket.draw() method [#516](https://github.com/RocketPy-Team/RocketPy/pull/516)
- BUG: 3D trajectory plot not labeling axes [#533](https://github.com/RocketPy-Team/RocketPy/pull/533)

## [v1.1.4] - 2023-12-07

Expand Down
25 changes: 17 additions & 8 deletions rocketpy/plots/flight_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,18 +63,16 @@ def trajectory_3d(self):
-------
None
"""

# Get max and min x and y
max_z = max(self.flight.z[:, 1] - self.flight.env.elevation)
min_z = min(self.flight.z[:, 1] - self.flight.env.elevation)
max_x = max(self.flight.x[:, 1])
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)

# Create figure
fig1 = plt.figure(figsize=(9, 9))
_ = 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="--"
Expand All @@ -99,19 +97,30 @@ def trajectory_3d(self):
self.flight.z[:, 1] - self.flight.env.elevation,
linewidth="2",
)
ax1.scatter(0, 0, 0)
ax1.scatter(
self.flight.x(0),
self.flight.y(0),
self.flight.z(0) - self.flight.env.elevation,
color="black",
)
ax1.scatter(
self.flight.x(self.flight.t_final),
self.flight.y(self.flight.t_final),
self.flight.z(self.flight.t_final) - self.flight.env.elevation,
color="red",
marker="X",
)
ax1.set_xlabel("X - East (m)")
ax1.set_ylabel("Y - North (m)")
ax1.set_zlabel("Z - Altitude Above Ground Level (m)")
ax1.set_title("Flight Trajectory")
ax1.set_zlim3d([0, max_z])
ax1.set_zlim3d([min_z, max_z])
ax1.set_ylim3d([min_xy, max_xy])
ax1.set_xlim3d([min_xy, max_xy])
ax1.view_init(15, 45)
ax1.set_box_aspect(None, zoom=0.95) # 95% for label adjustment
plt.show()

return None

def linear_kinematics_data(self):
"""Prints out all Kinematics graphs available about the Flight
Expand Down

0 comments on commit 7f033d8

Please sign in to comment.