Skip to content

Commit de4e9ca

Browse files
BUG: doesn't draw very well without buttons
1 parent 1ce0c0d commit de4e9ca

1 file changed

Lines changed: 15 additions & 11 deletions

File tree

rocketpy/plots/rocket_plots.py

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ def draw(self, vis_args=None):
127127
A full list of color names can be found at:
128128
https://matplotlib.org/stable/gallery/color/named_colors
129129
"""
130+
# TODO: we need to modularize this function, it is too big
130131
if vis_args is None:
131132
vis_args = {
132133
"background": "#EEEEEE",
@@ -270,7 +271,7 @@ def draw(self, vis_args=None):
270271

271272
# Draw tubes
272273
for i, d_surface in enumerate(drawn_surfaces):
273-
# Draw the tubes, from the end of the first surface to the beggining
274+
# Draw the tubes, from the end of the first surface to the beginning
274275
# of the next surface, with the radius of the rocket at that point
275276
surface, position, radius, last_x = d_surface
276277

@@ -284,7 +285,7 @@ def draw(self, vis_args=None):
284285
y_tube = [radius, radius]
285286
y_tube_negated = [-radius, -radius]
286287
else:
287-
# If it is not the last surface, the tube goes to the beggining
288+
# If it is not the last surface, the tube goes to the beginning
288289
# of the next surface
289290
next_surface, next_position, next_radius, next_last_x = drawn_surfaces[
290291
i + 1
@@ -356,15 +357,18 @@ def draw(self, vis_args=None):
356357
)
357358

358359
# Draw rail buttons
359-
buttons, pos = self.rocket.rail_buttons[0]
360-
lower = pos
361-
upper = pos + buttons.buttons_distance * csys
362-
ax.scatter(
363-
lower, -self.rocket.radius, marker="s", color=vis_args["buttons"], s=15
364-
)
365-
ax.scatter(
366-
upper, -self.rocket.radius, marker="s", color=vis_args["buttons"], s=15
367-
)
360+
try:
361+
buttons, pos = self.rocket.rail_buttons[0]
362+
lower = pos
363+
upper = pos + buttons.buttons_distance * csys
364+
ax.scatter(
365+
lower, -self.rocket.radius, marker="s", color=vis_args["buttons"], s=15
366+
)
367+
ax.scatter(
368+
upper, -self.rocket.radius, marker="s", color=vis_args["buttons"], s=15
369+
)
370+
except IndexError:
371+
pass
368372

369373
# Draw center of mass and center of pressure
370374
cm = self.rocket.center_of_mass(0)

0 commit comments

Comments
 (0)