sysdynpy/exporter.py
def export_graph(cls, results, file_format, system_elements, \
        range_x, range_y, colors, title="", label_x="", label_y="", line_width=1,
        legend_pos="upper left", rel_path="./results"):
        """Creates a diagram from the simulation results and saves it to the file
        system.

        Many arguments get piped through to `Matplotlib <https://matplotlib.org/>`__.
        See the `Documentation <https://matplotlib.org/api/pyplot_summary.html>`__
        for details. This method serves as a quick way to create a graph, but is
        fairly limited in its options. Use the Matplotlib API directly if you
        need more customization.

        :param results: The result of the simulation
        :type results: dict, see :py:func:`~sysdynpy.simulator.get_simulation_results`
            for more details.
        :param file_format: 'jpg' or 'png'
        :type file_format: str
        :param system_elements: Names of the system elements to export data for.
        :type system_elements: list of strings
        :param range_y: Matplotlib parameter. Defines the range of the y-axis.
            List with two integers. The first is the lower boundary, the second
            is the upper boundary.
        :type range_y: list of integers 
        :param colors: Matplotlib parameter. Colors to use for the trajectories.
            Each color corresponds to the system element at the same index.
        :type colors: list of strings.
        :param title: Matplotlib parameter. Headline of the plot, defaults to ""
        :type title: str
        :param label_x: Matplotlib parameter. Label for the x-axis, defaults to ""
        :type label_x: str
        :param label_y: Matplotlib parameter. Label for the y-axis, defaults to ""
        :type label_y: str
        :param line_width: Matplotlib parameter. Width of the trajectories, defaults to 1
        :type line_width: float
        :param legend_pos: Matplotlib parameter. Position of the legend in the
            canvas, defaults to "upper left"
        :type legend_pos: str
        :param rel_path: The path where to store the exported file (including the filename).
            Relative to the current working directory. Can include the file format.
            If it is not included it will be appended. Make sure the folder
            already exists, it will not be created. Defaults to "./results".

            Examples:

                |  .\\\\\\\\path\\\\\\\\to\\\\\\\\file.csv
                |  ./path/to/file.json
                |  ..\\\\\\\\path\\\\\\\\to\\\\\\\\file.json
                |  ../path/to/file
        :type rel_path: str
        """
        out_path, results_filtered = None, None
        try:
           out_path, results_filtered = \
                cls._prepare_export(results, file_format, system_elements, rel_path)
        except ValueError as v:
            raise v
        
        for key in results_filtered:
            data_x = range(len(results_filtered[key]))
            data_y = results_filtered[key]
            # get position of current key in system_elements so we can set the right color
            idx = system_elements.index(key)
            plt.plot(data_x, data_y, color=colors[idx], \
                linewidth=line_width, label=key)
        
        plt.title(title)
        plt.xlabel(label_x)
        plt.ylabel(label_y)
        plt.xlim(range_x)
        plt.ylim(range_y)
        plt.legend(loc=legend_pos)
        plt.savefig(out_path) # save
        plt.clf()
Creates a diagram from the simulation results and saves it to the file
        system.

        Many arguments get piped through to `Matplotlib <https://matplotlib.org/>`__.
        See the `Documentation <https://matplotlib.org/api/pyplot_summary.html>`__
        for details. This method serves as a quick way to create a graph, but is
        fairly limited in its options. Use the Matplotlib API directly if you
        need more customization.

        :param results: The result of the simulation
        :type results: dict, see :py:func:`~sysdynpy.simulator.get_simulation_results`
            for more details.
        :param file_format: 'jpg' or 'png'
        :type file_format: str
        :param system_elements: Names of the system elements to export data for.
        :type system_elements: list of strings
        :param range_y: Matplotlib parameter. Defines the range of the y-axis.
            List with two integers. The first is the lower boundary, the second
            is the upper boundary.
        :type range_y: list of integers 
        :param colors: Matplotlib parameter. Colors to use for the trajectories.
            Each color corresponds to the system element at the same index.
        :type colors: list of strings.
        :param title: Matplotlib parameter. Headline of the plot, defaults to ""
        :type title: str
        :param label_x: Matplotlib parameter. Label for the x-axis, defaults to ""
        :type label_x: str
        :param label_y: Matplotlib parameter. Label for the y-axis, defaults to ""
        :type label_y: str
        :param line_width: Matplotlib parameter. Width of the trajectories, defaults to 1
        :type line_width: float
        :param legend_pos: Matplotlib parameter. Position of the legend in the
            canvas, defaults to "upper left"
        :type legend_pos: str
        :param rel_path: The path where to store the exported file (including the filename).
            Relative to the current working directory. Can include the file format.
            If it is not included it will be appended. Make sure the folder
            already exists, it will not be created. Defaults to "./results".

            Examples:

                |  .\\\\\\\\path\\\\\\\\to\\\\\\\\file.csv
                |  ./path/to/file.json
                |  ..\\\\\\\\path\\\\\\\\to\\\\\\\\file.json
                |  ../path/to/file
        :type rel_path: str
        
Creates a diagram from the simulation results and saves it to the file
system.

Many arguments get piped through to `Matplotlib `__.
See the `Documentation `
for details. This method serves as a quick way to create a graph, but is
fairly limited in its options. Use the Matplotlib API directly if you
need more customization.
Creates a diagram from the simulation results and saves it to the file system . Many arguments get piped through to ` Matplotlib ` __ . See the ` Documentation ` for details . This method serves as a quick way to create a graph but is fairly limited in its options . Use the Matplotlib API directly if you need more customization .
def export_graph(cls, results, file_format, system_elements, \
        range_x, range_y, colors, title="", label_x="", label_y="", line_width=1,
        legend_pos="upper left", rel_path="./results"):
        out_path, results_filtered = None, None
        try:
           out_path, results_filtered = \
                cls._prepare_export(results, file_format, system_elements, rel_path)
        except ValueError as v:
            raise v
        for key in results_filtered:
            data_x = range(len(results_filtered[key]))
            data_y = results_filtered[key]
            idx = system_elements.index(key)
            plt.plot(data_x, data_y, color=colors[idx], \
                linewidth=line_width, label=key)
        plt.title(title)
        plt.xlabel(label_x)
        plt.ylabel(label_y)
        plt.xlim(range_x)
        plt.ylim(range_y)
        plt.legend(loc=legend_pos)
        plt.savefig(out_path) 
        plt.clf()
def export_graph ( cls , results , file_format , system_elements , range_x , range_y , colors , title = "" , label_x = "" , label_y = "" , line_width = 1 , legend_pos = "upper left" , rel_path = "./results" ) : out_path , results_filtered = None , None try : out_path , results_filtered = cls . _prepare_export ( results , file_format , system_elements , rel_path ) except ValueError as v : raise v for key in results_filtered : data_x = range ( len ( results_filtered [ key ] ) ) data_y = results_filtered [ key ] idx = system_elements . index ( key ) plt . plot ( data_x , data_y , color = colors [ idx ] , linewidth = line_width , label = key ) plt . title ( title ) plt . xlabel ( label_x ) plt . ylabel ( label_y ) plt . xlim ( range_x ) plt . ylim ( range_y ) plt . legend ( loc = legend_pos ) plt . savefig ( out_path ) plt . clf ( )
Creates a diagram from the simulation results and saves it to the file
system.
Creates a diagram from the simulation results and saves it to the file system .
"""Creates a diagram from the simulation results and saves it to the file
        system.

        Many arguments get piped through to `Matplotlib <https://matplotlib.org/>`__.
        See the `Documentation <https://matplotlib.org/api/pyplot_summary.html>`__
        for details. This method serves as a quick way to create a graph, but is
        fairly limited in its options. Use the Matplotlib API directly if you
        need more customization.

        :param results: The result of the simulation
        :type results: dict, see :py:func:`~sysdynpy.simulator.get_simulation_results`
            for more details.
        :param file_format: 'jpg' or 'png'
        :type file_format: str
        :param system_elements: Names of the system elements to export data for.
        :type system_elements: list of strings
        :param range_y: Matplotlib parameter. Defines the range of the y-axis.
            List with two integers. The first is the lower boundary, the second
            is the upper boundary.
        :type range_y: list of integers 
        :param colors: Matplotlib parameter. Colors to use for the trajectories.
            Each color corresponds to the system element at the same index.
        :type colors: list of strings.
        :param title: Matplotlib parameter. Headline of the plot, defaults to ""
        :type title: str
        :param label_x: Matplotlib parameter. Label for the x-axis, defaults to ""
        :type label_x: str
        :param label_y: Matplotlib parameter. Label for the y-axis, defaults to ""
        :type label_y: str
        :param line_width: Matplotlib parameter. Width of the trajectories, defaults to 1
        :type line_width: float
        :param legend_pos: Matplotlib parameter. Position of the legend in the
            canvas, defaults to "upper left"
        :type legend_pos: str
        :param rel_path: The path where to store the exported file (including the filename).
            Relative to the current working directory. Can include the file format.
            If it is not included it will be appended. Make sure the folder
            already exists, it will not be created. Defaults to "./results".

            Examples:

                |  .\\\\\\\\path\\\\\\\\to\\\\\\\\file.csv
                |  ./path/to/file.json
                |  ..\\\\\\\\path\\\\\\\\to\\\\\\\\file.json
                |  ../path/to/file
        :type rel_path: str
        """ # get position of current key in system_elements so we can set the right color # save
cls
results
The result of the simulation
The result of the simulation
file_format
'jpg' or 'png'
' jpg ' or ' png '
system_elements
Names of the system elements to export data for.
Names of the system elements to export data for .
range_x
range_y
Matplotlib parameter. Defines the range of the y-axis.
List with two integers. The first is the lower boundary, the second
is the upper boundary.
Matplotlib parameter . Defines the range of the y - axis . List with two integers . The first is the lower boundary the second is the upper boundary .
colors
Matplotlib parameter. Colors to use for the trajectories.
Each color corresponds to the system element at the same index.
Matplotlib parameter . Colors to use for the trajectories . Each color corresponds to the system element at the same index .
title
Matplotlib parameter. Headline of the plot, defaults to ""
Matplotlib parameter . Headline of the plot defaults to " "
""
label_x
Matplotlib parameter. Label for the x-axis, defaults to ""
Matplotlib parameter . Label for the x - axis defaults to " "
""
label_y
Matplotlib parameter. Label for the y-axis, defaults to ""
Matplotlib parameter . Label for the y - axis defaults to " "
""
line_width
Matplotlib parameter. Width of the trajectories, defaults to 1
Matplotlib parameter . Width of the trajectories defaults to 1
1
legend_pos
Matplotlib parameter. Position of the legend in the
canvas, defaults to "upper left"
Matplotlib parameter . Position of the legend in the canvas defaults to " upper left "
"upper left"
rel_path
The path where to store the exported file (including the filename).
Relative to the current working directory. Can include the file format.
If it is not included it will be appended. Make sure the folder
already exists, it will not be created. Defaults to "./results".




The path where to store the exported file ( including the filename ) . Relative to the current working directory . Can include the file format . If it is not included it will be appended . Make sure the folder already exists it will not be created . Defaults to " . / results " .