From 1a6c41f17a4a6f102b422d76100fb49e1f17c5ab Mon Sep 17 00:00:00 2001 From: Gui-FernandesBR Date: Sat, 14 Dec 2024 23:45:51 -0300 Subject: [PATCH] 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