mirror of
https://github.com/illiumst/marl-factory-grid.git
synced 2025-07-06 09:31:35 +02:00
added documentation to plotting methods and added info about monitoring, recording, plotting to usage.rst
This commit is contained in:
@ -20,12 +20,12 @@ PALETTE = 10 * (
|
||||
|
||||
def plot(filepath, ext='png'):
|
||||
"""
|
||||
Saves the current plot to a file and displays it.
|
||||
|
||||
Todo
|
||||
|
||||
:param filepath:
|
||||
:param ext:
|
||||
:return:
|
||||
:param filepath: The path to save the plot file.
|
||||
:type filepath: str
|
||||
:param ext: The file extension of the saved plot. Default is 'png'.
|
||||
:type ext: str
|
||||
"""
|
||||
plt.tight_layout()
|
||||
figure = plt.gcf()
|
||||
@ -43,11 +43,18 @@ def plot(filepath, ext='png'):
|
||||
|
||||
def prepare_tex(df, hue, style, hue_order):
|
||||
"""
|
||||
Todo
|
||||
Prepares a line plot for rendering in LaTeX.
|
||||
|
||||
:param filepath:
|
||||
:param ext:
|
||||
:return:
|
||||
:param df: The DataFrame containing the data to be plotted.
|
||||
:type df: pandas.DataFrame
|
||||
:param hue: Grouping variable that will produce lines with different colors.
|
||||
:type hue: str
|
||||
:param style: Grouping variable that will produce lines with different styles.
|
||||
:type style: str
|
||||
:param hue_order: Order for the levels of the hue variable in the plot.
|
||||
:type hue_order: list
|
||||
:return: The prepared line plot.
|
||||
:rtype: matplotlib.axes._subplots.AxesSubplot
|
||||
"""
|
||||
sns.set(rc={'text.usetex': True}, style='whitegrid')
|
||||
lineplot = sns.lineplot(data=df, x='Episode', y='Score', ci=95, palette=PALETTE,
|
||||
@ -60,11 +67,18 @@ def prepare_tex(df, hue, style, hue_order):
|
||||
|
||||
def prepare_plt(df, hue, style, hue_order):
|
||||
"""
|
||||
Todo
|
||||
Prepares a line plot using matplotlib.
|
||||
|
||||
:param filepath:
|
||||
:param ext:
|
||||
:return:
|
||||
:param df: The DataFrame containing the data to be plotted.
|
||||
:type df: pandas.DataFrame
|
||||
:param hue: Grouping variable that will produce lines with different colors.
|
||||
:type hue: str
|
||||
:param style: Grouping variable that will produce lines with different styles.
|
||||
:type style: str
|
||||
:param hue_order: Order for the levels of the hue variable in the plot.
|
||||
:type hue_order: list
|
||||
:return: The prepared line plot.
|
||||
:rtype: matplotlib.axes._subplots.AxesSubplot
|
||||
"""
|
||||
print('Struggling to plot Figure using LaTeX - going back to normal.')
|
||||
plt.close('all')
|
||||
@ -79,11 +93,18 @@ def prepare_plt(df, hue, style, hue_order):
|
||||
|
||||
def prepare_center_double_column_legend(df, hue, style, hue_order):
|
||||
"""
|
||||
Todo
|
||||
Prepares a line plot with a legend centered at the bottom and spread across two columns.
|
||||
|
||||
:param filepath:
|
||||
:param ext:
|
||||
:return:
|
||||
:param df: The DataFrame containing the data to be plotted.
|
||||
:type df: pandas.DataFrame
|
||||
:param hue: Grouping variable that will produce lines with different colors.
|
||||
:type hue: str
|
||||
:param style: Grouping variable that will produce lines with different styles.
|
||||
:type style: str
|
||||
:param hue_order: Order for the levels of the hue variable in the plot.
|
||||
:type hue_order: list
|
||||
:return: The prepared line plot.
|
||||
:rtype: matplotlib.axes._subplots.AxesSubplot
|
||||
"""
|
||||
print('Struggling to plot Figure using LaTeX - going back to normal.')
|
||||
plt.close('all')
|
||||
@ -99,11 +120,21 @@ def prepare_center_double_column_legend(df, hue, style, hue_order):
|
||||
|
||||
def prepare_plot(filepath, results_df, ext='png', hue='Measurement', style=None, use_tex=False):
|
||||
"""
|
||||
Todo
|
||||
Prepares a line plot for visualization. Based on the use tex parameter calls the prepare_tex or prepare_plot
|
||||
function accordingly, followed by the plot function to save the plot.
|
||||
|
||||
:param filepath:
|
||||
:param ext:
|
||||
:return:
|
||||
:param filepath: The file path where the plot will be saved.
|
||||
:type filepath: str
|
||||
:param results_df: The DataFrame containing the data to be plotted.
|
||||
:type results_df: pandas.DataFrame
|
||||
:param ext: The file extension of the saved plot (default is 'png').
|
||||
:type ext: str
|
||||
:param hue: The variable to determine the color of the lines in the plot.
|
||||
:type hue: str
|
||||
:param style: The variable to determine the style of the lines in the plot (default is None).
|
||||
:type style: str or None
|
||||
:param use_tex: Whether to use LaTeX for text rendering (default is False).
|
||||
:type use_tex: bool
|
||||
"""
|
||||
df = results_df.copy()
|
||||
df[hue] = df[hue].str.replace('_', '-')
|
||||
|
Reference in New Issue
Block a user