The main pyplot class.
Type | Visibility | Attributes | Name | Initial | |||
---|---|---|---|---|---|---|---|
character(len=:), | private, | allocatable | :: | str |
string buffer |
||
character(len=1), | private | :: | raw_str_token | = | ' ' |
will be 'r' if using raw strings |
|
logical, | private | :: | show_legend | = | .false. |
show legend into plot |
|
logical, | private | :: | use_numpy | = | .true. |
use numpy python module |
|
logical, | private | :: | use_oo_api | = | .false. |
use OO interface of matplotlib (incopatible with showfig subroutine) |
|
logical, | private | :: | mplot3d | = | .false. |
it is a 3d plot |
|
logical, | private | :: | polar | = | .false. |
it is a polar plot |
|
logical, | private | :: | axis_equal | = | .false. |
equal scale on each axis |
|
logical, | private | :: | axisbelow | = | .true. |
axis below other chart elements |
|
logical, | private | :: | tight_layout | = | .false. |
tight layout option |
|
logical, | private | :: | usetex | = | .false. |
enable LaTeX |
|
character(len=:), | private, | allocatable | :: | xaxis_date_fmt |
date format for the x-axis. Example: |
||
character(len=:), | private, | allocatable | :: | yaxis_date_fmt |
date format for the y-axis. Example: |
||
character(len=:), | private, | allocatable | :: | real_fmt |
real number formatting |
initialize pyplot instance
Initialize a plot
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(pyplot), | intent(inout) | :: | me |
pyplot handler |
||
logical, | intent(in), | optional | :: | grid |
activate grid drawing |
|
character(len=*), | intent(in), | optional | :: | xlabel |
label of x axis |
|
character(len=*), | intent(in), | optional | :: | ylabel |
label of y axis |
|
character(len=*), | intent(in), | optional | :: | zlabel |
label of z axis |
|
character(len=*), | intent(in), | optional | :: | title |
plot title |
|
logical, | intent(in), | optional | :: | legend |
plot legend |
|
logical, | intent(in), | optional | :: | use_numpy |
activate usage of numpy python module |
|
integer, | intent(in), | optional, | dimension(2) | :: | figsize |
dimension of the figure |
integer, | intent(in), | optional | :: | font_size |
font size |
|
integer, | intent(in), | optional | :: | axes_labelsize |
size of axis labels |
|
integer, | intent(in), | optional | :: | xtick_labelsize |
size of x axis tick lables |
|
integer, | intent(in), | optional | :: | ytick_labelsize |
size of y axis tick lables |
|
integer, | intent(in), | optional | :: | ztick_labelsize |
size of z axis tick lables |
|
integer, | intent(in), | optional | :: | legend_fontsize |
size of legend font |
|
logical, | intent(in), | optional | :: | mplot3d |
set true for 3d plots (cannot use with polar) |
|
logical, | intent(in), | optional | :: | axis_equal |
set true for axis = 'equal' |
|
logical, | intent(in), | optional | :: | polar |
set true for polar plots (cannot use with mplot3d) |
|
character(len=*), | intent(in), | optional | :: | real_fmt |
format string for real numbers (examples: '(E30.16)' [default], '*') |
|
logical, | intent(in), | optional | :: | use_oo_api |
avoid matplotlib's GUI by using the OO interface (cannot use with showfig) |
|
logical, | intent(in), | optional | :: | axisbelow |
to put the grid lines below the other chart elements [default is true] |
|
logical, | intent(in), | optional | :: | tight_layout |
enable tight layout [default is false] |
|
logical, | intent(in), | optional | :: | raw_strings |
if True, all strings sent to Python are treated as raw strings (e.g., r'str'). Default is False. |
|
logical, | intent(in), | optional | :: | usetex |
if True, enable LaTeX. (default if false) |
|
character(len=*), | intent(in), | optional | :: | xaxis_date_fmt |
if present, used to set the date format for the x-axis |
|
character(len=*), | intent(in), | optional | :: | yaxis_date_fmt |
if present, used to set the date format for the y-axis |
add a 2d plot to pyplot instance
Add an x,y plot.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(pyplot), | intent(inout) | :: | me |
pyplot handler |
||
real(kind=wp), | intent(in), | dimension(:) | :: | x |
x values |
|
real(kind=wp), | intent(in), | dimension(:) | :: | y |
y values |
|
character(len=*), | intent(in) | :: | label |
plot label |
||
character(len=*), | intent(in) | :: | linestyle |
style of the plot line |
||
integer, | intent(in), | optional | :: | markersize |
size of the plot markers |
|
integer, | intent(in), | optional | :: | linewidth |
width of the plot line |
|
real(kind=wp), | intent(in), | optional, | dimension(2) | :: | xlim |
x-axis range |
real(kind=wp), | intent(in), | optional, | dimension(2) | :: | ylim |
y-axis range |
character(len=*), | intent(in), | optional | :: | xscale |
example: 'linear' (default), 'log' |
|
character(len=*), | intent(in), | optional | :: | yscale |
example: 'linear' (default), 'log' |
|
real(kind=wp), | intent(in), | optional, | dimension(:) | :: | color |
RGB color tuple [0-1,0-1,0-1] |
integer, | intent(out), | optional | :: | istat |
status output (0 means no problems) |
add a 2d error bar plot to pyplot instance
Add an x,y plot with errorbars.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(pyplot), | intent(inout) | :: | me |
pyplot handler |
||
real(kind=wp), | intent(in), | dimension(:) | :: | x |
x values |
|
real(kind=wp), | intent(in), | dimension(:) | :: | y |
y values |
|
character(len=*), | intent(in) | :: | label |
plot label |
||
character(len=*), | intent(in) | :: | linestyle |
style of the plot line |
||
real(kind=wp), | intent(in), | optional, | dimension(:) | :: | xerr |
x errorbar sizes |
real(kind=wp), | intent(in), | optional, | dimension(:) | :: | yerr |
y errorbar sizes |
integer, | intent(in), | optional | :: | markersize |
size of the plot markers |
|
integer, | intent(in), | optional | :: | linewidth |
width of the plot line |
|
real(kind=wp), | intent(in), | optional, | dimension(2) | :: | xlim |
x-axis range |
real(kind=wp), | intent(in), | optional, | dimension(2) | :: | ylim |
y-axis range |
character(len=*), | intent(in), | optional | :: | xscale |
example: 'linear' (default), 'log' |
|
character(len=*), | intent(in), | optional | :: | yscale |
example: 'linear' (default), 'log' |
|
real(kind=wp), | intent(in), | optional, | dimension(:) | :: | color |
RGB color tuple [0-1,0-1,0-1] |
integer, | intent(out), | optional | :: | istat |
status output (0 means no problems) |
add a 3d plot to pyplot instance
Add a 3D x,y,z plot.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(pyplot), | intent(inout) | :: | me |
pyplot handler |
||
real(kind=wp), | intent(in), | dimension(:) | :: | x |
x values |
|
real(kind=wp), | intent(in), | dimension(:) | :: | y |
y values |
|
real(kind=wp), | intent(in), | dimension(:) | :: | z |
z values |
|
character(len=*), | intent(in) | :: | label |
plot label |
||
character(len=*), | intent(in) | :: | linestyle |
style of the plot line |
||
integer, | intent(in), | optional | :: | markersize |
size of the plot markers |
|
integer, | intent(in), | optional | :: | linewidth |
width of the plot line |
|
integer, | intent(out), | optional | :: | istat |
status output (0 means no problems) |
add a 3d sphere to pyplot instance
Add a sphere to a 3D x,y,z plot.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(pyplot), | intent(inout) | :: | me |
pyplot handler |
||
real(kind=wp), | intent(in) | :: | r |
radius of the sphere |
||
real(kind=wp), | intent(in) | :: | xc |
x value of sphere center |
||
real(kind=wp), | intent(in) | :: | yc |
y value of sphere center |
||
real(kind=wp), | intent(in) | :: | zc |
z value of sphere center |
||
integer, | intent(in), | optional | :: | n_facets |
[default is 100] |
|
integer, | intent(in), | optional | :: | linewidth |
line width |
|
logical, | intent(in), | optional | :: | antialiased |
enabled anti-aliasing |
|
character(len=*), | intent(in), | optional | :: | color |
color of the contour line |
|
integer, | intent(out), | optional | :: | istat |
status output (0 means no problems) |
add a contour plot to pyplot instance
Add a contour plot.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(pyplot), | intent(inout) | :: | me |
pyplot handler |
||
real(kind=wp), | intent(in), | dimension(:) | :: | x |
x values |
|
real(kind=wp), | intent(in), | dimension(:) | :: | y |
y values |
|
real(kind=wp), | intent(in), | dimension(:,:) | :: | z |
z values (a matrix) |
|
character(len=*), | intent(in) | :: | linestyle |
style of the plot line |
||
integer, | intent(in), | optional | :: | linewidth |
width of the plot line [only used when |
|
real(kind=wp), | intent(in), | optional, | dimension(:) | :: | levels |
contour levels to plot |
character(len=*), | intent(in), | optional | :: | color |
color of the contour line |
|
logical, | intent(in), | optional | :: | filled |
use filled control (default=False) |
|
character(len=*), | intent(in), | optional | :: | cmap |
colormap if filled=True (examples: 'jet', 'bone') |
|
logical, | intent(in), | optional | :: | colorbar |
add a colorbar (default=False) |
|
integer, | intent(out), | optional | :: | istat |
status output (0 means no problems) |
add a wireframe plot to pyplot instance
Add a wireframe plot.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(pyplot), | intent(inout) | :: | me |
pyplot handler |
||
real(kind=wp), | intent(in), | dimension(:) | :: | x |
x values |
|
real(kind=wp), | intent(in), | dimension(:) | :: | y |
y values |
|
real(kind=wp), | intent(in), | dimension(:,:) | :: | z |
z values (a matrix) |
|
character(len=*), | intent(in) | :: | label |
plot label |
||
character(len=*), | intent(in) | :: | linestyle |
style of the plot line |
||
integer, | intent(in), | optional | :: | linewidth |
width of the plot line |
|
real(kind=wp), | intent(in), | optional, | dimension(:) | :: | levels |
contour levels to plot |
character(len=*), | intent(in), | optional | :: | color |
Color of the surface patches |
|
character(len=*), | intent(in), | optional | :: | cmap |
colormap if filled=True (examples: 'jet', 'bone') |
|
logical, | intent(in), | optional | :: | colorbar |
add a colorbar (default=False) |
|
logical, | intent(in), | optional | :: | antialiased |
The surface is made opaque by using antialiased=False |
|
integer, | intent(out), | optional | :: | istat |
status output (0 means no problems) |
add a surface plot to pyplot instance
Add a surface plot.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(pyplot), | intent(inout) | :: | me |
pyplot handler |
||
real(kind=wp), | intent(in), | dimension(:) | :: | x |
x values |
|
real(kind=wp), | intent(in), | dimension(:) | :: | y |
y values |
|
real(kind=wp), | intent(in), | dimension(:,:) | :: | z |
z values (a matrix) |
|
character(len=*), | intent(in) | :: | label |
plot label |
||
character(len=*), | intent(in) | :: | linestyle |
style of the plot line |
||
integer, | intent(in), | optional | :: | linewidth |
width of the plot line |
|
real(kind=wp), | intent(in), | optional, | dimension(:) | :: | levels |
contour levels to plot |
character(len=*), | intent(in), | optional | :: | color |
Color of the surface patches |
|
character(len=*), | intent(in), | optional | :: | cmap |
colormap if filled=True (examples: 'jet', 'bone') |
|
logical, | intent(in), | optional | :: | colorbar |
add a colorbar (default=False) |
|
logical, | intent(in), | optional | :: | antialiased |
The surface is made opaque by using antialiased=False |
|
integer, | intent(out), | optional | :: | istat |
status output (0 means no problems) |
add a barplot to pyplot instance
Add a bar plot.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(pyplot), | intent(inout) | :: | me |
pyplot handler |
||
real(kind=wp), | intent(in), | dimension(:) | :: | x |
x bar values |
|
real(kind=wp), | intent(in), | dimension(:) | :: | height |
height bar values |
|
character(len=*), | intent(in) | :: | label |
plot label |
||
real(kind=wp), | intent(in), | optional, | dimension(:) | :: | width |
width values |
real(kind=wp), | intent(in), | optional, | dimension(:) | :: | bottom |
bottom values |
character(len=*), | intent(in), | optional | :: | color |
plot color |
|
real(kind=wp), | intent(in), | optional, | dimension(:) | :: | yerr |
yerr values |
character(len=*), | intent(in), | optional | :: | align |
default: 'center' |
|
real(kind=wp), | intent(in), | optional, | dimension(2) | :: | xlim |
x-axis range |
real(kind=wp), | intent(in), | optional, | dimension(2) | :: | ylim |
y-axis range |
character(len=*), | intent(in), | optional | :: | xscale |
example: 'linear' (default), 'log' |
|
character(len=*), | intent(in), | optional | :: | yscale |
example: 'linear' (default), 'log' |
|
integer, | intent(out), | optional | :: | istat |
status output (0 means no problems) |
add an image plot (using imshow
)
Add an image plot using imshow
.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(pyplot), | intent(inout) | :: | me |
pyplot handler |
||
real(kind=wp), | intent(in), | dimension(:,:) | :: | x |
x values |
|
real(kind=wp), | intent(in), | optional, | dimension(2) | :: | xlim |
x-axis range |
real(kind=wp), | intent(in), | optional, | dimension(2) | :: | ylim |
y-axis range |
integer, | intent(out), | optional | :: | istat |
status output (0 means no problems) |
add a histogram plot to pyplot instance
Add a histogram plot.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(pyplot), | intent(inout) | :: | me |
pyplot handler |
||
real(kind=wp), | intent(in), | dimension(:) | :: | x |
array of data |
|
character(len=*), | intent(in) | :: | label |
plot label |
||
real(kind=wp), | intent(in), | optional, | dimension(2) | :: | xlim |
x-axis range |
real(kind=wp), | intent(in), | optional, | dimension(2) | :: | ylim |
y-axis range |
character(len=*), | intent(in), | optional | :: | xscale |
example: 'linear' (default), 'log' |
|
character(len=*), | intent(in), | optional | :: | yscale |
example: 'linear' (default), 'log' |
|
integer, | intent(in), | optional | :: | bins |
number of bins |
|
logical, | intent(in), | optional | :: | normed |
boolean flag that determines whether bin counts are normalized [NO LONGER USED] |
|
logical, | intent(in), | optional | :: | cumulative |
boolean flag that determines whether histogram represents the cumulative density of dataset |
|
integer, | intent(out), | optional | :: | istat |
status output (0 means no problems) |
save plots of pyplot instance
Save the figure.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(pyplot), | intent(inout) | :: | me |
pyplot handler |
||
character(len=*), | intent(in) | :: | figfile |
file name for the figure |
||
character(len=*), | intent(in), | optional | :: | pyfile |
name of the Python script to generate |
|
character(len=*), | intent(in), | optional | :: | dpi |
resolution of the figure for png [note this is a string] |
|
logical, | intent(in), | optional | :: | transparent |
transparent background (T/F) |
|
character(len=*), | intent(in), | optional | :: | facecolor |
the colors of the figure rectangle |
|
character(len=*), | intent(in), | optional | :: | edgecolor |
the colors of the figure rectangle |
|
character(len=*), | intent(in), | optional | :: | orientation |
'landscape' or 'portrait' |
|
integer, | intent(out), | optional | :: | istat |
status output (0 means no problems) |
|
character(len=*), | intent(in), | optional | :: | python |
python executable to use. (by default, this is 'python') |
show plots of pyplot instance
Shows the figure.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(pyplot), | intent(inout) | :: | me |
pyplot handler |
||
character(len=*), | intent(in), | optional | :: | pyfile |
name of the Python script to generate |
|
integer, | intent(out), | optional | :: | istat |
status output (0 means no problems) |
|
character(len=*), | intent(in), | optional | :: | python |
python executable to use. (by default, this is 'python') |
execute pyplot commands
Write the buffer to a file, and then execute it with Python.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(pyplot), | intent(inout) | :: | me |
pytplot handler |
||
character(len=*), | intent(in), | optional | :: | pyfile |
name of the python script to generate |
|
integer, | intent(out), | optional | :: | istat |
status output (0 means no problems) |
|
character(len=*), | intent(in), | optional | :: | python |
python executable to use. (by default, this is 'python') |
add string to pytplot instance buffer
some final ops before saving
Some final things to add before saving or showing the figure.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(pyplot), | intent(inout) | :: | me |
pyplot handler |
type, public :: pyplot !! The main pyplot class. private character(len=:), allocatable :: str !! string buffer character(len=1) :: raw_str_token = ' ' !! will be 'r' if using raw strings logical :: show_legend = .false. !! show legend into plot logical :: use_numpy = .true. !! use numpy python module logical :: use_oo_api = .false. !! use OO interface of matplotlib (incopatible with showfig subroutine) logical :: mplot3d = .false. !! it is a 3d plot logical :: polar = .false. !! it is a polar plot logical :: axis_equal = .false. !! equal scale on each axis logical :: axisbelow = .true. !! axis below other chart elements logical :: tight_layout = .false. !! tight layout option logical :: usetex = .false. !! enable LaTeX character(len=:),allocatable :: xaxis_date_fmt !! date format for the x-axis. Example: `"%m/%d/%y %H:%M:%S"` character(len=:),allocatable :: yaxis_date_fmt !! date format for the y-axis. Example: `"%m/%d/%y %H:%M:%S"` character(len=:),allocatable :: real_fmt !! real number formatting contains ! public methods procedure, public :: initialize !! initialize pyplot instance procedure, public :: add_plot !! add a 2d plot to pyplot instance procedure, public :: add_errorbar !! add a 2d error bar plot to pyplot instance procedure, public :: add_3d_plot !! add a 3d plot to pyplot instance procedure, public :: add_sphere !! add a 3d sphere to pyplot instance procedure, public :: add_contour !! add a contour plot to pyplot instance procedure, public :: plot_wireframe!! add a wireframe plot to pyplot instance procedure, public :: plot_surface !! add a surface plot to pyplot instance procedure, public :: add_bar !! add a barplot to pyplot instance procedure, public :: add_imshow !! add an image plot (using `imshow`) procedure, public :: add_hist !! add a histogram plot to pyplot instance procedure, public :: savefig !! save plots of pyplot instance procedure, public :: showfig !! show plots of pyplot instance procedure, public :: destroy !! destroy pyplot instance ! private methods procedure :: execute !! execute pyplot commands procedure :: add_str !! add string to pytplot instance buffer procedure :: finish_ops !! some final ops before saving end type pyplot