Plotter#

Module for plotting.

class Plotter[source]

Bases: object

Implementation of a plotter class, for easy visualizations.

plot_samples(problem, variables=None, filename=None, **kwargs)[source]

Plot the training grid samples.

Parameters:
  • problem (AbstractProblem) – The PINA problem from where to plot the domain.

  • variables (list(str)) – Variables to plot. If None, all variables are plotted. If ‘spatial’, only spatial variables are plotted. If ‘temporal’, only temporal variables are plotted. Defaults to None.

  • filename (str) – The file name to save the plot. If None, the plot is shown using the setted matplotlib frontend. Default is None.

Todo

  • Add support for 3D plots.

  • Fix support for more complex problems.

Example:
>>> plotter = Plotter()
>>> plotter.plot_samples(problem=problem, variables='spatial')
plot(solver, components=None, fixed_variables={}, method='contourf', res=256, filename=None, title=None, **kwargs)[source]

Plot sample of SolverInterface output.

Parameters:
  • solver (SolverInterface) – The SolverInterface object instance.

  • components (str | list(str)) – The output variable(s) to plot. If None, all the output variables of the problem are selected. Default value is None.

  • fixed_variables (dict) – A dictionary with all the variables that should be kept fixed during the plot. The keys of the dictionary are the variables name whereas the values are the corresponding values of the variables. Defaults is dict().

  • method (str) – The matplotlib method to use for plotting the solution. Available methods are {‘contourf’, ‘pcolor’}. Default is ‘contourf’.

  • res (int) – The resolution, aka the number of points used for plotting in each axis. Default is 256.

  • title (str) – The title for the plot. If None, the plot is shown without a title. Default is None.

  • filename (str) – The file name to save the plot. If None, the plot is shown using the setted matplotlib frontend. Default is None.

plot_loss(trainer, metrics=None, logy=False, logx=False, filename=None, **kwargs)[source]

Plot the loss function values during traininig.

Parameters:
  • trainer (Trainer) – the PINA Trainer object instance.

  • metric (str | list(str)) – The metrics to use in the y axis. If None, the mean loss is plotted.

  • logy (bool) – If True, the y axis is in log scale. Default is True.

  • logx (bool) – If True, the x axis is in log scale. Default is True.

  • filename (str) – The file name to save the plot. If None, the plot is shown using the setted matplotlib frontend. Default is None.