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) |
subroutine add_hist(me, x, label, xlim, ylim, xscale, yscale, bins, normed, cumulative, istat) class(pyplot), intent (inout) :: me !! pyplot handler real(wp), dimension(:), intent (in) :: x !! array of data character(len=*), intent (in) :: label !! plot label real(wp),dimension(2), intent (in), optional :: xlim !! x-axis range real(wp),dimension(2), intent (in), optional :: 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) character(len=*), parameter :: xname = 'x' !! x variable name for script character(len=:), allocatable :: xstr !! x values stringified character(len=:), allocatable :: xlimstr !! xlim values stringified character(len=:), allocatable :: ylimstr !! ylim values stringified character(len=:), allocatable :: cumulativestr !! character(len=max_int_len) :: binsstr !! if (allocated(me%str)) then if (present(istat)) istat = 0 !axis limits (optional): if (present(xlim)) call vec_to_string(xlim, me%real_fmt, xlimstr, me%use_numpy) if (present(ylim)) call vec_to_string(ylim, me%real_fmt, ylimstr, me%use_numpy) !convert the arrays to strings: call vec_to_string(x, me%real_fmt, xstr, me%use_numpy) !write the arrays: call me%add_str(trim(xname)//' = '//xstr) call me%add_str('') !get optional inputs (if not present, set default value): call optional_int_to_string(bins, binsstr, '10') call optional_logical_to_string(cumulative, cumulativestr, 'False') !write the plot statement: call me%add_str('ax.hist('//& trim(xname)//','//& 'label='//trim(me%raw_str_token)//'"'//trim(label)//'",'//& 'bins='//trim(binsstr)//','//& 'cumulative='//trim(cumulativestr)//')') !axis limits: if (allocated(xlimstr)) call me%add_str('ax.set_xlim('//xlimstr//')') if (allocated(ylimstr)) call me%add_str('ax.set_ylim('//ylimstr//')') !axis scales: if (present(xscale)) call me%add_str('ax.set_xscale('//trim(me%raw_str_token)//'"'//xscale//'")') if (present(yscale)) call me%add_str('ax.set_yscale('//trim(me%raw_str_token)//'"'//yscale//'")') call me%add_str('') else if (present(istat)) istat = -1 write(error_unit,'(A)') 'Error in add_plot: pyplot class not properly initialized.' end if end subroutine add_hist