FEDEM Solver  R8.0
Source code of the dynamics solver
Data Types | Functions/Subroutines | Variables
pyplot_module Module Reference

Interface for plots in python (x-y plots). More...

Data Types

type  pyplot
 Main python plot class. More...
 

Functions/Subroutines

subroutine destroy (me)
 Destroys an instance of pyplot. More...
 
subroutine add_str (me, str)
 Add a string to the string buffer. More...
 
subroutine initialize (me, grid, xlabel, ylabel, zlabel, title, legend, use_numpy, figsize, font_size, axes_labelsize, xtick_labelsize, ytick_labelsize, ztick_labelsize, legend_fontsize, mplot3d, axis_equal, polar, real_fmt, use_oo_api, axisbelow, tight_layout, istat)
 Initializes curve plots. More...
 
subroutine add_plot (me, x, y, label, linestyle, markersize, linewidth, xlim, ylim, xscale, yscale, color, istat)
 Add an x,y plot. More...
 
subroutine add_hist (me, x, label, xlim, ylim, xscale, yscale, bins, normed, cumulative, istat)
 Add an histogram plot. More...
 
subroutine add_contour (me, x, y, z, label, linestyle, linewidth, levels, color, filled, cmap, colorbar, istat)
 Add a contour plot. More...
 
subroutine add_3d_plot (me, x, y, z, label, linestyle, markersize, linewidth, istat)
 Add a 3D x, y, z plot. More...
 
subroutine add_sphere (me, r, xc, yc, zc, n_facets, linewidth, antialiased, color, istat)
 Add a sphere to a 3D x,y,z plot. More...
 
subroutine add_bar (me, x, height, label, width, bottom, color, yerr, align, xlim, ylim, xscale, yscale, istat)
 Add a bar plot. More...
 
subroutine add_imshow (me, x, xlim, ylim, exValues, istat)
 Add an image plot using imshow More...
 
subroutine optional_int_to_string (int_value, string_value, default_value)
 Integer to string, specifying the default value if the optional argument is not present. More...
 
subroutine optional_logical_to_string (logical_value, string_value, default_value)
 Logical to string, specifying the default value if the optional argument is not present. More...
 
subroutine integer_to_string (i, s)
 Integer to string conversion. More...
 
subroutine real_to_string (v, fmt, str)
 Integer to string conversion. More...
 
subroutine vec_to_string (v, fmt, str, use_numpy, is_tuple)
 Real vector to string. More...
 
subroutine matrix_to_string (v, fmt, str, use_numpy)
 Real matrix (rank 2) to string. More...
 
subroutine execute (me, pyfile, istat)
 Write the buffer to a specified file, then execute it with Python. More...
 
subroutine finish_ops (me)
 Some final things to add before saving or showing the figure. More...
 
subroutine savefig (me, figfile, pyfile, dpi, transparent, facecolor, edgecolor, orientation, istat)
 Save the figure. More...
 
subroutine showfig (me, pyfile, istat)
 Show the figure. More...
 

Variables

integer, parameter max_int_len = 10
 max string length for integers More...
 
integer, parameter max_real_len = 30
 max string length for reals More...
 

Detailed Description

Interface for plots in python (x-y plots).

Function/Subroutine Documentation

◆ add_3d_plot()

subroutine pyplot_module::add_3d_plot ( class(pyplot), intent(inout)  me,
real(dp), dimension(:), intent(in)  x,
real(dp), dimension(:), intent(in)  y,
real(dp), dimension(:), intent(in)  z,
character(len=*), intent(in)  label,
character(len=*), intent(in)  linestyle,
integer, intent(in), optional  markersize,
integer, intent(in), optional  linewidth,
integer, intent(out)  istat 
)
private

Add a 3D x, y, z plot.

Note
Must initialize the class with mplot3d=.true.
Parameters
[in,out]meclass handler
[in]xx values
[in]yy values
[in]zz values
[in]labelplot label
[in]linestylestyle of the plot line
[in]markersizesize of the plot markers
[in]linewidthwidth of the plot line
[out]istatstatus output

◆ add_bar()

subroutine pyplot_module::add_bar ( class(pyplot), intent(inout)  me,
real(dp), dimension(:), intent(in)  x,
real(dp), dimension(:), intent(in)  height,
character(len=*), intent(in)  label,
real(dp), dimension(:), intent(in), optional  width,
real(dp), dimension(:), intent(in), optional  bottom,
character(len=*), intent(in), optional  color,
real(dp), dimension(:), intent(in), optional  yerr,
character(len=*), intent(in), optional  align,
real(dp), dimension(2), intent(in), optional  xlim,
real(dp), dimension(2), intent(in), optional  ylim,
character(len=*), intent(in), optional  xscale,
character(len=*), intent(in), optional  yscale,
integer, intent(out)  istat 
)
private

Add a bar plot.

Parameters
[in,out]meclass handler
[in]xx bar values
[in]heightheight bar values
[in]labelplot label
[in]widthwidth values
[in]bottombottom values
[in]colorplot color
[in]yerryerr values
[in]aligndefault: 'center'
[in]xlimx-axis range
[in]ylimy-axis range
[in]xscaleexample: 'linear' (default), 'log'
[in]yscaleexample: 'linear' (default), 'log'
[out]istatstatus output (0 means no problems)

◆ add_contour()

subroutine pyplot_module::add_contour ( class(pyplot), intent(inout)  me,
real(dp), dimension(:), intent(in)  x,
real(dp), dimension(:), intent(in)  y,
real(dp), dimension(:,:), intent(in)  z,
character(len=*), intent(in)  label,
character(len=*), intent(in)  linestyle,
integer, intent(in), optional  linewidth,
real(dp), dimension(:), intent(in), optional  levels,
character(len=*), intent(in), optional  color,
logical, intent(in), optional  filled,
character(len=*), intent(in), optional  cmap,
logical, intent(in), optional  colorbar,
integer, intent(out)  istat 
)
private

Add a contour plot.

Note
This requires use_numpy to be True.
Parameters
[in,out]meclass handler
[in]xx values
[in]yy values
[in]zz values
[in]labelplot label
[in]linestylestyle of the plot line
[in]linewidthwidth of the plot line
[in]levelscontour levels to plot
[in]colorcolor of the contour line
[in]filleduse filled control (default=False)
[in]cmapcolormap if filled=True (examples: 'jet', 'bone')
[in]colorbaradd a colorbar (default=False)
[out]istatstatus output

◆ add_hist()

subroutine pyplot_module::add_hist ( class(pyplot), intent(inout)  me,
real(dp), dimension(:), intent(in)  x,
character(len=*), intent(in)  label,
real(dp), dimension(2), intent(in), optional  xlim,
real(dp), dimension(2), intent(in), optional  ylim,
character(len=*), intent(in), optional  xscale,
character(len=*), intent(in), optional  yscale,
integer, intent(in), optional  bins,
logical, intent(in), optional  normed,
logical, intent(in), optional  cumulative,
integer, intent(out)  istat 
)
private

Add an histogram plot.

Parameters
[in,out]meclass handler
[in]xx values
[in]labelplot label
[in]xlimx-axis range
[in]ylimy-axis range
[in]xscaleexample: 'linear' (default), 'log'
[in]yscaleexample: 'linear' (default), 'log'
[in]binsnumber of bins
[in]normedboolean flag that determines whether bin counts are normalized
[in]cumulativeboolean flag that determines whether histogram represents the cumulative density of dataset
[out]istatstatus output

◆ add_imshow()

subroutine pyplot_module::add_imshow ( class(pyplot), intent(inout)  me,
real(dp), dimension(:,:), intent(in)  x,
real(dp), dimension(2), intent(in), optional  xlim,
real(dp), dimension(2), intent(in), optional  ylim,
real(dp), dimension(4), intent(in), optional  exValues,
integer, intent(out)  istat 
)
private

Add an image plot using imshow

Parameters
[in,out]meclass handler
[in]xx values
[in]xlimx-axis range
[in]ylimy-axis range
[in]exValuesarray values to extent
[out]istatstatus output (0 means no problems)

◆ add_plot()

subroutine pyplot_module::add_plot ( class(pyplot), intent(inout)  me,
real(dp), dimension(:), intent(in)  x,
real(dp), dimension(:), intent(in)  y,
character(len=*), intent(in)  label,
character(len=*), intent(in)  linestyle,
integer, intent(in), optional  markersize,
integer, intent(in), optional  linewidth,
real(dp), dimension(2), intent(in), optional  xlim,
real(dp), dimension(2), intent(in), optional  ylim,
character(len=*), intent(in), optional  xscale,
character(len=*), intent(in), optional  yscale,
real(dp), dimension(:), intent(in), optional  color,
integer, intent(out)  istat 
)

Add an x,y plot.

Parameters
[in,out]meclass handler
[in]xx values
[in]yy values
[in]labelplot label
[in]linestylestyle of the plot line
[in]markersizesize of the plot markers
[in]linewidthwidth of the plot line
[in]xlimx-axis range
[in]ylimy-axis range
[in]xscaleexample: 'linear' (default), 'log'
[in]yscaleexample: 'linear' (default), 'log'
[in]colorRGB color tuple
[out]istatstatus output

◆ add_sphere()

subroutine pyplot_module::add_sphere ( class(pyplot), intent(inout)  me,
real(dp), intent(in)  r,
real(dp), intent(in)  xc,
real(dp), intent(in)  yc,
real(dp), intent(in)  zc,
integer, intent(in), optional  n_facets,
integer, intent(in), optional  linewidth,
logical, intent(in), optional  antialiased,
character(len=*), intent(in), optional  color,
integer, intent(out)  istat 
)
private

Add a sphere to a 3D x,y,z plot.

Note
Must initialize the class with mplot3d=.true. and use_numpy=.true..
Parameters
[in,out]meclass handler
[in]rradius of the sphere
[in]xcx value of sphere center
[in]ycy value of sphere center
[in]zcz value of sphere center
[in]n_facets[default is 100]
[in]linewidthline width
[in]antialiasedenabled anti-aliasing
[in]colorcolor of the contour line
[out]istatstatus output (0 means no problems)

◆ add_str()

subroutine pyplot_module::add_str ( class(pyplot), intent(inout)  me,
character(len=*), intent(in)  str 
)
private

Add a string to the string buffer.

Parameters
[in]meclass handler
[in]strstring buffer

◆ destroy()

subroutine pyplot_module::destroy ( class(pyplot), intent(inout)  me)

Destroys an instance of pyplot.

Parameters
[in]meclass handler

◆ execute()

subroutine pyplot_module::execute ( class(pyplot), intent(in)  me,
character(len=*), intent(in)  pyfile,
integer, intent(out)  istat 
)
private

Write the buffer to a specified file, then execute it with Python.

Parameters
[in]mepython plot handler
[in]pyfilename of the python script to generate
[out]istatstatus output (0 means no problems)

◆ finish_ops()

subroutine pyplot_module::finish_ops ( class(pyplot), intent(inout)  me)

Some final things to add before saving or showing the figure.

Parameters
[in,out]mepytplot handler

◆ initialize()

subroutine pyplot_module::initialize ( class(pyplot), intent(inout)  me,
logical, intent(in), optional  grid,
character(len=*), intent(in), optional  xlabel,
character(len=*), intent(in), optional  ylabel,
character(len=*), intent(in), optional  zlabel,
character(len=*), intent(in), optional  title,
logical, intent(in), optional  legend,
logical, intent(in), optional  use_numpy,
integer, dimension(2), intent(in), optional  figsize,
integer, intent(in), optional  font_size,
integer, intent(in), optional  axes_labelsize,
integer, intent(in), optional  xtick_labelsize,
integer, intent(in), optional  ytick_labelsize,
integer, intent(in), optional  ztick_labelsize,
integer, intent(in), optional  legend_fontsize,
logical, intent(in), optional  mplot3d,
logical, intent(in), optional  axis_equal,
logical, intent(in), optional  polar,
character(len=*), intent(in), optional  real_fmt,
logical, intent(in), optional  use_oo_api,
logical, intent(in), optional  axisbelow,
logical, intent(in), optional  tight_layout,
integer, intent(out)  istat 
)
private

Initializes curve plots.

Parameters
[in,out]meclass handler
[in]gridflag for grid drawing
[in]xlabelx axis label
[in]ylabely axis label
[in]zlabelz axis label
[in]titledrawing title
[in]legenddrawing legend
[in]use_numpyflag for using numpy
[in]figsizefigure dimesnion
[in]font_sizefont size
[in]axes_labelsizeaxis label size
[in]xtick_labelsizesize of x axis tick lables
[in]ytick_labelsizesize of y axis tick lables
[in]ztick_labelsizesize of z axis tick lables
[in]legend_fontsizesize of legend font
[in]mplot3dset true for 3d plots
[in]axis_equalset true for axis = 'equal'
[in]polarset true for polar plots
[in]real_fmtformat string for real numbers
[in]use_oo_apiavoid matplotlib's GUI by using the OO interface
[in]axisbelowto put the grid lines below the other chart elements
[in]tight_layoutenable tight layout
[out]istatNon-zero if python cannot be invoked

◆ integer_to_string()

subroutine pyplot_module::integer_to_string ( integer, intent(in), optional  i,
character(len=*), intent(out)  s 
)
private

Integer to string conversion.

Parameters
[in]iinteger
[out]sinteger value stringified

◆ matrix_to_string()

subroutine pyplot_module::matrix_to_string ( real(dp), dimension(:,:), intent(in)  v,
character(len=*), intent(in)  fmt,
character(len=:), intent(out), allocatable  str,
logical, intent(in)  use_numpy 
)
private

Real matrix (rank 2) to string.

Parameters
[in]vreal
[in]fmtreal format string
[out]strreal values stringified
[in]use_numpyactivate numpy python module usage

◆ optional_int_to_string()

subroutine pyplot_module::optional_int_to_string ( integer, intent(in), optional  int_value,
character(len=*), intent(out)  string_value,
character(len=*), intent(in)  default_value 
)
private

Integer to string, specifying the default value if the optional argument is not present.

Parameters
[in]int_valueinteger
[out]string_valueinteger value stringified
[in]default_valuedefault integer value

◆ optional_logical_to_string()

subroutine pyplot_module::optional_logical_to_string ( logical, intent(in), optional  logical_value,
character(len=:), intent(out), allocatable  string_value,
character(len=*), intent(in)  default_value 
)
private

Logical to string, specifying the default value if the optional argument is not present.

Parameters
[in]logical_valuelogical value
[out]string_valueinteger value stringified
[in]default_valuedefault integer value

◆ real_to_string()

subroutine pyplot_module::real_to_string ( real(dp), intent(in)  v,
character(len=*), intent(in)  fmt,
character(len=:), intent(out), allocatable  str 
)
private

Integer to string conversion.

Parameters
[in]vreal
[in]fmtreal format string
[out]strreal values stringified

◆ savefig()

subroutine pyplot_module::savefig ( class(pyplot), intent(inout)  me,
character(len=*), intent(in)  figfile,
character(len=*), intent(in), optional  pyfile,
character(len=*), intent(in), optional  dpi,
logical, intent(in), optional  transparent,
character(len=*), intent(in), optional  facecolor,
character(len=*), intent(in), optional  edgecolor,
character(len=*), intent(in), optional  orientation,
integer, intent(out)  istat 
)
private

Save the figure.

Parameters
[in,out]mepytplot handler
[in]figfilefile name for the figure
[in]pyfilename of the Python script to generate
[in]dpiresolution of the figure for png
[in]transparenttransparent background (T/F)
[in]facecolorthe colors of the figure rectangle
[in]edgecolorthe colors of the figure rectangle
[in]orientation'landscape' or 'portrait'
[out]istatstatus output (0 means no problems)

◆ showfig()

subroutine pyplot_module::showfig ( class(pyplot), intent(inout)  me,
character(len=*), intent(in), optional  pyfile,
integer, intent(out)  istat 
)

Show the figure.

Parameters
[in,out]mepytplot handler
[in]pyfilename of the Python script to generate
[out]istatstatus output (0 means no problems)

◆ vec_to_string()

subroutine pyplot_module::vec_to_string ( real(dp), dimension(:), intent(in)  v,
character(len=*), intent(in)  fmt,
character(len=:), intent(out), allocatable  str,
logical, intent(in)  use_numpy,
logical, intent(in), optional  is_tuple 
)
private

Real vector to string.

Parameters
[in]vreal
[out]fmtreal format string
[out]strreal values stringified
[in]use_numpyactivate numpy python module usage
[in]is_tupleif true [default], use '()', if false use '[]'

Variable Documentation

◆ max_int_len

integer, parameter pyplot_module::max_int_len = 10
private

max string length for integers

◆ max_real_len

integer, parameter pyplot_module::max_real_len = 30
private

max string length for reals