I have this minimum reproducible code
import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
import mpld3
# Create a DataFrame with columns id, X, and Y
# num_points = 100
# t = np.linspace(0, 4 * np.pi, num_points)
# data = {'id': range(1, num_points + 1), 'X': 10 * np.cos(t), 'Y': 5 * np.sin(t)} # Adjust amplitude and frequency as needed
# df = pd.DataFrame(data)
num_points = 25000
t = np.linspace(0, 8 * np.pi, num_points) # Adjust the range to control the length of the trajectory
data = {'id': range(1, num_points + 1), 'X': 10 * np.cos(t), 'Y': 5 * np.sin(t)} # Adjust amplitude and frequency as needed
df = pd.DataFrame(data)
# Set linewidth and markersize
linewidth = 0.1
markersize = 2
# Plot the trajectory with modified parameters
plt.plot(df['X'], df['Y'], marker='.', linestyle='-', linewidth=linewidth, markersize=markersize)
plt.title('Trajectory Plot')
plt.xlabel('X Coordinates')
plt.ylabel('Y Coordinates')
# Convert the plot to HTML using mpld3
html_fig = mpld3.fig_to_html(plt.gcf())
# Generate a simple HTML template
html_template = f"""
<!DOCTYPE html>
<html>
<head>
<title>Trajectory Plot</title>
</head>
<body>
<h1>Trajectory Plot</h1>
{html_fig}
</body>
</html>
"""
# <script src="https://mpld3.github.io/js/mpld3.v0.5.2.js"></script>
# Save the HTML to a file
with open('trajectory_plot.html', 'w') as f:
f.write(html_template)
# Display the Matplotlib plot
plt.show()
With this I get two things:
- A html page
trajectory_plot.html
with an interactive plot in it - The plot itself
Now observe the plot
They are very similar.
However if you zoom the plots they differ very much in the marker size
Why is this and how can I correct it?