Skip to content

Commit

Permalink
DOC: Improve flight examples documentation
Browse files Browse the repository at this point in the history
Update flight simulation documentation with improved markdown headers and replace matplotlib with Plotly for enhanced visualizations
  • Loading branch information
Gui-FernandesBR committed Dec 15, 2024
1 parent f407559 commit ab8053f
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 24 deletions.
10 changes: 5 additions & 5 deletions docs/examples/defiance_flight_sim.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Importing necessary modules"
"## Importing necessary modules"
]
},
{
Expand All @@ -35,7 +35,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Creating the simulation Environment"
"## Creating the simulation Environment"
]
},
{
Expand Down Expand Up @@ -118,7 +118,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Building the Hybrid Motor"
"## Building the Hybrid Motor"
]
},
{
Expand Down Expand Up @@ -179,7 +179,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Building the Rocket and adding Aerosurfaces"
"## Building the Rocket and adding Aero surfaces"
]
},
{
Expand Down Expand Up @@ -231,7 +231,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Flight Simulation"
"## Flight Simulation"
]
},
{
Expand Down
50 changes: 31 additions & 19 deletions docs/examples/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ apogee of some rockets.
.. jupyter-execute::
:hide-code:

import matplotlib.pyplot as plt
import plotly.graph_objects as go

results = {
# "Name (Year)": (simulated, measured) m
Expand Down Expand Up @@ -39,28 +39,40 @@ apogee of some rockets.
labels = list(results.keys())

# Create the plot
fig, ax = plt.subplots(figsize=(9, 9))
ax.scatter(simulated, measured)
ax.grid(True, alpha=0.3)
fig = go.Figure()

# Add the x = y line
ax.plot([0, max_apogee], [0, max_apogee], linestyle='--', color='black', alpha=0.6)

# Add text labels
for i, label in enumerate(labels):
ax.text(simulated[i], measured[i], label, ha='center', va='bottom', fontsize=8)
fig.add_trace(go.Scatter(
x=[0, max_apogee],
y=[0, max_apogee],
mode='lines',
line=dict(dash='dash', color='black'),
showlegend=False
))

# Add scatter plot
fig.add_trace(go.Scatter(
x=simulated,
y=measured,
mode='markers',
text=labels,
textposition='top center',
marker=dict(size=10),
showlegend=False
))

# Set titles and labels
ax.set_title("Simulated x Measured Apogee")
ax.set_xlabel("Simulated Apogee (m)")
ax.set_ylabel("Measured Apogee (m)")

# Set aspect ratio to 1:1
ax.set_aspect('equal', adjustable='box')
ax.set_xlim(0, max_apogee)
ax.set_ylim(0, max_apogee)

plt.show()
fig.update_layout(
title="Simulated x Measured Apogee",
xaxis_title="Simulated Apogee (m)",
yaxis_title="Measured Apogee (m)",
xaxis=dict(range=[0, max_apogee]),
yaxis=dict(range=[0, max_apogee]),
width=650,
height=650
)

fig.show()

In the next sections you will find the simulations of the rockets listed above.

Expand Down
1 change: 1 addition & 0 deletions docs/requirements.in
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ pandas==2.2.2
lxml_html_clean==0.1.1
sphinx-copybutton==0.5.2
sphinx-tabs==3.4.7
plotly>=5

0 comments on commit ab8053f

Please sign in to comment.