Skip to content

Commit 1a6c41f

Browse files
DOC: Improve flight examples documentation
Update flight simulation documentation with improved markdown headers and replace matplotlib with Plotly for enhanced visualizations
1 parent 50b6017 commit 1a6c41f

File tree

3 files changed

+37
-24
lines changed

3 files changed

+37
-24
lines changed

docs/examples/defiance_flight_sim.ipynb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"cell_type": "markdown",
1717
"metadata": {},
1818
"source": [
19-
"# Importing necessary modules"
19+
"## Importing necessary modules"
2020
]
2121
},
2222
{
@@ -35,7 +35,7 @@
3535
"cell_type": "markdown",
3636
"metadata": {},
3737
"source": [
38-
"# Creating the simulation Environment"
38+
"## Creating the simulation Environment"
3939
]
4040
},
4141
{
@@ -118,7 +118,7 @@
118118
"cell_type": "markdown",
119119
"metadata": {},
120120
"source": [
121-
"# Building the Hybrid Motor"
121+
"## Building the Hybrid Motor"
122122
]
123123
},
124124
{
@@ -179,7 +179,7 @@
179179
"cell_type": "markdown",
180180
"metadata": {},
181181
"source": [
182-
"# Building the Rocket and adding Aerosurfaces"
182+
"## Building the Rocket and adding Aero surfaces"
183183
]
184184
},
185185
{
@@ -231,7 +231,7 @@
231231
"cell_type": "markdown",
232232
"metadata": {},
233233
"source": [
234-
"# Flight Simulation"
234+
"## Flight Simulation"
235235
]
236236
},
237237
{

docs/examples/index.rst

Lines changed: 31 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ apogee of some rockets.
1111
.. jupyter-execute::
1212
:hide-code:
1313

14-
import matplotlib.pyplot as plt
14+
import plotly.graph_objects as go
1515

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

4141
# Create the plot
42-
fig, ax = plt.subplots(figsize=(9, 9))
43-
ax.scatter(simulated, measured)
44-
ax.grid(True, alpha=0.3)
42+
fig = go.Figure()
4543

4644
# Add the x = y line
47-
ax.plot([0, max_apogee], [0, max_apogee], linestyle='--', color='black', alpha=0.6)
48-
49-
# Add text labels
50-
for i, label in enumerate(labels):
51-
ax.text(simulated[i], measured[i], label, ha='center', va='bottom', fontsize=8)
45+
fig.add_trace(go.Scatter(
46+
x=[0, max_apogee],
47+
y=[0, max_apogee],
48+
mode='lines',
49+
line=dict(dash='dash', color='black'),
50+
showlegend=False
51+
))
52+
53+
# Add scatter plot
54+
fig.add_trace(go.Scatter(
55+
x=simulated,
56+
y=measured,
57+
mode='markers',
58+
text=labels,
59+
textposition='top center',
60+
marker=dict(size=10),
61+
showlegend=False
62+
))
5263

5364
# Set titles and labels
54-
ax.set_title("Simulated x Measured Apogee")
55-
ax.set_xlabel("Simulated Apogee (m)")
56-
ax.set_ylabel("Measured Apogee (m)")
57-
58-
# Set aspect ratio to 1:1
59-
ax.set_aspect('equal', adjustable='box')
60-
ax.set_xlim(0, max_apogee)
61-
ax.set_ylim(0, max_apogee)
62-
63-
plt.show()
65+
fig.update_layout(
66+
title="Simulated x Measured Apogee",
67+
xaxis_title="Simulated Apogee (m)",
68+
yaxis_title="Measured Apogee (m)",
69+
xaxis=dict(range=[0, max_apogee]),
70+
yaxis=dict(range=[0, max_apogee]),
71+
width=650,
72+
height=650
73+
)
74+
75+
fig.show()
6476

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

docs/requirements.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ pandas==2.2.2
77
lxml_html_clean==0.1.1
88
sphinx-copybutton==0.5.2
99
sphinx-tabs==3.4.7
10+
plotly>=5

0 commit comments

Comments
 (0)