Skip to content

Commit

Permalink
#1 Work in progress:
Browse files Browse the repository at this point in the history
- Update documentation

[ci skip]
  • Loading branch information
FABallemand committed Jan 28, 2024
1 parent c3fa759 commit 713c6c5
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 6 deletions.
14 changes: 9 additions & 5 deletions docs/tutorials/plotting.rst
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ This method relies on the well known Matplotlib Python library to create simple
watermark=True,
file_path="img.png")

.. image:: ../../img/matplotlib_plot_1.png
.. image:: ../../img/matplotlib_plot_1.jpg
:width: 500
:alt: Matplotlib plot

Expand Down Expand Up @@ -122,8 +122,8 @@ PaperMap
:width: 500
:alt: PaperMap plot

Expert Plot
^^^^^^^^^^^
Matplotlib Animation
^^^^^^^^^^^^^^^^^^^^

This method creates animations of the activity contained in a GPX file.

Expand Down Expand Up @@ -156,6 +156,10 @@ This method creates animations of the activity contained in a GPX file.
watermark=True,
file_path="video_1.mp4")

.. image:: ../../img/matplotlib_animation_1.gif
:width: 500
:alt: Matplotlib animation

Expert Plot
^^^^^^^^^^^

Expand Down Expand Up @@ -214,6 +218,6 @@ This is the most advanced plotting method built into ezGPX. It allows to plot th
watermark=False,
file_path="img.png")

.. image:: ../../img/expert_plot_1.png
.. image:: ../../img/expert_plot_1.jpg
:width: 500
:alt: PaperMap plot
:alt: Matplotlib "expert" plot
13 changes: 12 additions & 1 deletion ezgpx/gpx/gpx.py
Original file line number Diff line number Diff line change
Expand Up @@ -1976,6 +1976,7 @@ def matplotlib_animation(
dpi: int = 96,
interval: float = 20,
fps: int = 24,
bitrate: int = 1800,
repeat: bool = True,
title: Optional[str] = None,
title_fontsize: int = 20,
Expand Down Expand Up @@ -2104,7 +2105,17 @@ def animate(i):
if not os.path.exists(directory_path):
logging.error("Provided path does not exist")
return
ani.save(file_path, fps=fps, dpi=dpi)
# ani.save(file_path, fps=fps, dpi=dpi)
writer = None
if file_path.endswith(".mp4"):
writer = animation.FFMpegWriter(fps=15,
metadata=dict(artist='Me'),
bitrate=bitrate)
elif file_path.endswith(".gif"):
writer = animation.PillowWriter(fps=15,
metadata=dict(artist='Me'),
bitrate=bitrate)
ani.save(file_path, writer=writer)
else:
ani.show()

Expand Down
Binary file added img/matplotlib_animation_1.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified img/matplotlib_plot_1.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 713c6c5

Please sign in to comment.