Skip to content

Commit

Permalink
DOC: flight comparison improvements (#755)
Browse files Browse the repository at this point in the history
* DOC: Improve flight examples documentation
Update flight simulation documentation with improved markdown headers and replace matplotlib with Plotly for enhanced visualizations

* DEV: update changelog

* DOC: Fix title in camoes simul

* DOC: Update docs/requirements.txt to include new dependencies

---------

Co-authored-by: LUCKIN13 <[email protected]>
  • Loading branch information
Gui-FernandesBR and LUCKIN13 authored Dec 16, 2024
1 parent c7f1623 commit ed6af68
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 27 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ Attention: The newest changes should be on top -->

### Changed

-
- DOC: flight comparison improvements [#755](https://github.com/RocketPy-Team/RocketPy/pull/755)

### Fixed

Expand Down
2 changes: 1 addition & 1 deletion docs/examples/camoes_flight_sim.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Air Brakes - Active Control Systems"
"## Air Brakes - Active Control Systems"
]
},
{
Expand Down
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
13 changes: 12 additions & 1 deletion docs/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ docutils==0.20.1
# sphinx-tabs
entrypoints==0.4
# via nbconvert
exceptiongroup==1.2.2
# via ipython
executing==2.0.1
# via stack-data
fastjsonschema==2.19.1
Expand Down Expand Up @@ -131,6 +133,7 @@ packaging==24.0
# via
# ipykernel
# nbconvert
# plotly
# pydata-sphinx-theme
# sphinx
pandas==2.2.2
Expand All @@ -143,6 +146,8 @@ pexpect==4.9.0
# via ipython
platformdirs==4.2.2
# via jupyter-core
plotly==5.24.1
# via -r requirements.in
prompt-toolkit==3.0.43
# via ipython
psutil==5.9.8
Expand Down Expand Up @@ -218,8 +223,12 @@ sphinxcontrib-serializinghtml==1.1.10
# via sphinx
stack-data==0.6.3
# via ipython
tenacity==9.0.0
# via plotly
tinycss2==1.3.0
# via nbconvert
tomli==2.2.1
# via sphinx
tornado==6.4
# via
# ipykernel
Expand All @@ -238,7 +247,9 @@ traitlets==5.14.3
# nbformat
# nbsphinx
typing-extensions==4.12.0
# via pydata-sphinx-theme
# via
# ipython
# pydata-sphinx-theme
tzdata==2024.1
# via pandas
urllib3==2.2.1
Expand Down

0 comments on commit ed6af68

Please sign in to comment.