Create a histogram
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=wp), | intent(in), | dimension(:) | :: | d | Data for binning |
|
integer, | intent(in), | optional | :: | N | Number of bins |
|
real(kind=wp), | intent(in), | optional | dimension(2) | :: | db | Boundaries of bin range |
real(kind=wp), | intent(in), | optional | :: | relWidth | Relative width of bars (default 0.8) |
|
character(len=*), | intent(in), | optional | :: | fillColor | Color of bar fills |
|
character(len=*), | intent(in), | optional | :: | fillPattern | Pattern of bar fills |
|
character(len=*), | intent(in), | optional | :: | lineColor | Color of lines around bars |
|
real(kind=wp), | optional | :: | lineWidth | Width of lines around bars |
subroutine hist(d,N,db,relWidth,fillColor,fillPattern,lineColor,lineWidth)
!! Create a histogram
real(wp),dimension(:),intent(in)::d
!! Data for binning
integer,intent(in),optional::N
!! Number of bins
real(wp),dimension(2),intent(in),optional::db
!! Boundaries of bin range
real(wp),intent(in),optional::relWidth
!! Relative width of bars (default 0.8)
character(*),intent(in),optional::fillColor
!! Color of bar fills
character(*),intent(in),optional::fillPattern
!! Pattern of bar fills
character(*),intent(in),optional::lineColor
!! Color of lines around bars
real(wp),optional::lineWidth
!! Width of lines around bars
real(wp),dimension(:,:),allocatable::h
real(wp),dimension(2)::dbl
integer::Nl
real(wp)::relWidthl
real(wp)::lineWidthl
Nl = 20
if(present(N)) Nl = N
if(present(db)) then
dbl = db
else
dbl = mixval(d)+[-1.0_wp,1.0_wp]*epsilon(1.0_wp)
end if
h = binData(d,Nl,dbl,normalize=3)
relWidthl = 1.0_wp
if(present(relWidth)) relWidthl = relWidth
lineWidthl = 0.5_wp
if(present(lineWidth)) lineWidthl = lineWidth
if(present(lineColor)) then
if(present(fillColor)) then
if(present(fillPattern)) then
call bar(h(:,1),h(:,2),relWidth=relWidthl,lineColor=lineColor,lineWidth=lineWidthl, &
& fillColor=fillColor,fillPattern=fillPattern)
else
call bar(h(:,1),h(:,2),relWidth=relWidthl,lineColor=lineColor,lineWidth=lineWidthl, &
& fillColor=fillColor)
end if
else
if(present(fillPattern)) then
call bar(h(:,1),h(:,2),h(:,2),relWidth=relWidthl,lineColor=lineColor,lineWidth=lineWidthl, &
& fillPattern=fillPattern)
else
call bar(h(:,1),h(:,2),h(:,2),relWidth=relWidthl,lineColor=lineColor,lineWidth=lineWidthl)
end if
end if
else
if(present(fillColor)) then
if(present(fillPattern)) then
call bar(h(:,1),h(:,2),relWidth=relWidthl,lineWidth=lineWidthl, &
& fillColor=fillColor,fillPattern=fillPattern)
else
call bar(h(:,1),h(:,2),relWidth=relWidthl,lineWidth=lineWidthl, &
& fillColor=fillColor)
end if
else
if(present(fillPattern)) then
call bar(h(:,1),h(:,2),h(:,2),relWidth=relWidthl,lineWidth=lineWidthl, &
& fillPattern=fillPattern)
else
call bar(h(:,1),h(:,2),h(:,2),relWidth=relWidthl,lineWidth=lineWidthl)
end if
end if
end if
call resetPen()
end subroutine hist