Skip to content
Snippets Groups Projects
Select Git revision
  • master
  • gitkeep
  • dev protected
  • Sprint/2022-01
  • Sprint/2021-22
  • Sprint/2021-18
  • Sprint/2021-14
  • Hotfix/1656-emailConfirmationTrigger
  • Sprint/2021-04
  • Product/789-userContactEmail
  • Topic/1295-contactChangeUi
  • Sprint/2021-02
  • Product/1273-CleanUpUserProfileProjectCreation
  • Topic/1225-CleanUpApps
  • Product/1107-frontendPerformance
  • Topic/1227-frontendPerformance
  • Product/1215-gitlabCleanUp
  • Topic/1222-apiConnection
  • Product/1027-apiClientGenerator
  • Product/1214-CleanUp
  • v1.5.3
  • v1.5.2
  • v1.5.1
  • v1.5.0
  • v1.4.0
  • v1.3.0
  • v1.2.1
  • v1.2.0
  • v1.1.5
  • v1.1.4
  • v1.1.3
  • v1.1.2
  • v1.1.1
  • v1.1.0
  • v1.0.0
35 results

README.md

Blame
  • Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    save_plot.py 910 B
    #!/usr/bin/env python3
    # -*- coding: utf-8 -*-
    """
    Export a plot figure to a picture file.
    
    Functions:
        save_plot(figure, string) -> path-like
    """
    
    import matplotlib
    import matplotlib.pyplot as plt
    
    
    def save_plot(figure, plot_name, extension='png'):
        """
        Export plot.
    
        Parameters
        ----------
        figure : figure object
            Figure that was tagged and now should be saved as picture.
        plot_name: Name of the file where the plot will be saved to.
        extension: string
            File extension for the plot export.
    
        Returns
        -------
        plot_path: Name of the created picture.
    
        """
        match type(figure):
            case matplotlib.figure.Figure:
                plt.figure(figure)
                plot_path = plot_name + '.' + extension
                plt.savefig(plot_path)
            case _:
                raise TypeError('The given figure is not a valid figure object.')
    
        return plot_path