From 836a2890af87365dd8dd576ac0898c4d883f5f09 Mon Sep 17 00:00:00 2001 From: Gui-FernandesBR Date: Sat, 14 Dec 2024 23:45:51 -0300 Subject: [PATCH 1/4] DOC: Improve flight examples documentation Update flight simulation documentation with improved markdown headers and replace matplotlib with Plotly for enhanced visualizations --- docs/examples/defiance_flight_sim.ipynb | 10 ++--- docs/examples/index.rst | 50 +++++++++++++++---------- docs/requirements.in | 1 + 3 files changed, 37 insertions(+), 24 deletions(-) diff --git a/docs/examples/defiance_flight_sim.ipynb b/docs/examples/defiance_flight_sim.ipynb index da6ac0411..b78924ce9 100644 --- a/docs/examples/defiance_flight_sim.ipynb +++ b/docs/examples/defiance_flight_sim.ipynb @@ -16,7 +16,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "# Importing necessary modules" + "## Importing necessary modules" ] }, { @@ -35,7 +35,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "# Creating the simulation Environment" + "## Creating the simulation Environment" ] }, { @@ -118,7 +118,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "# Building the Hybrid Motor" + "## Building the Hybrid Motor" ] }, { @@ -179,7 +179,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "# Building the Rocket and adding Aerosurfaces" + "## Building the Rocket and adding Aero surfaces" ] }, { @@ -231,7 +231,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "# Flight Simulation" + "## Flight Simulation" ] }, { diff --git a/docs/examples/index.rst b/docs/examples/index.rst index f6803834f..23440b916 100644 --- a/docs/examples/index.rst +++ b/docs/examples/index.rst @@ -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 @@ -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. diff --git a/docs/requirements.in b/docs/requirements.in index b5138ee0c..249681598 100644 --- a/docs/requirements.in +++ b/docs/requirements.in @@ -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 From f5810ac6cee55aa80fe6c656db961b149071bc8d Mon Sep 17 00:00:00 2001 From: Gui-FernandesBR Date: Sat, 14 Dec 2024 23:52:19 -0300 Subject: [PATCH 2/4] DEV: update changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1766e2dcf..84bdc3aa3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 From edb504eff2a2d2d83f423bee648d9333395358fe Mon Sep 17 00:00:00 2001 From: LUCKIN13 Date: Sun, 15 Dec 2024 20:10:31 +0000 Subject: [PATCH 3/4] DOC: Fix title in camoes simul --- docs/examples/camoes_flight_sim.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/examples/camoes_flight_sim.ipynb b/docs/examples/camoes_flight_sim.ipynb index fe0a46c19..2916e8c7e 100644 --- a/docs/examples/camoes_flight_sim.ipynb +++ b/docs/examples/camoes_flight_sim.ipynb @@ -333,7 +333,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "# Air Brakes - Active Control Systems" + "## Air Brakes - Active Control Systems" ] }, { From 0f4af95f199fb1559743ae86404a31ca21bd37a0 Mon Sep 17 00:00:00 2001 From: Gui-FernandesBR Date: Sun, 15 Dec 2024 23:39:21 -0300 Subject: [PATCH 4/4] DOC: Update docs/requirements.txt to include new dependencies --- docs/requirements.txt | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/docs/requirements.txt b/docs/requirements.txt index c56c20cae..14f379cdc 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -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 @@ -131,6 +133,7 @@ packaging==24.0 # via # ipykernel # nbconvert + # plotly # pydata-sphinx-theme # sphinx pandas==2.2.2 @@ -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 @@ -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 @@ -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