Create a bar graph
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=wp), | intent(in), | dimension(:) | :: | x | x-positions of the bars' centers |
|
real(kind=wp), | intent(in), | dimension(:) | :: | y | y-positions of the bars' tops |
|
real(kind=wp), | intent(in), | optional | dimension(:) | :: | c | Color scale for bars |
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 bar(x,y,c,relWidth,fillColor,fillPattern,lineColor,lineWidth)
!! Create a bar graph
real(wp),dimension(:),intent(in)::x
!! x-positions of the bars' centers
real(wp),dimension(:),intent(in)::y
!! y-positions of the bars' tops
real(wp),dimension(:),intent(in),optional::c
!! Color scale for bars
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(pp),dimension(4)::xl,yl
real(pp),dimension(2)::cb
real(pp)::dx,dxs
integer::k
cb = 0.0_wp
if(present(c)) cb = real(mixval(c),pp)
dxs = 0.8_pp
if(present(relWidth)) dxs = real(relWidth,pp)
if(size(x)>1) then
dx = dxs*real(x(2)-x(1),pp)/2.0_pp
else
dx = dxs
end if
if(present(lineWidth)) call setLineWidth(lineWidth)
do k=1,size(x)
xl = real([x(k)-dx,x(k)-dx,x(k)+dx,x(k)+dx],pp)
yl = real([0.0_wp,y(k),y(k),0.0_wp],pp)
if(present(fillColor)) call setColor(fillColor)
if(present(fillPattern)) call setFillPattern(fillPattern)
if(present(c)) call plcol1( real( (c(k)-cb(1))/(cb(2)-cb(1)) ,pp) )
call plfill(xl,yl)
if(present(lineColor)) call setColor(lineColor)
call plline(xl,yl)
end do
call resetPen()
end subroutine bar