examples_prg Program

program~~examples_prg~~UsesGraph program~examples_prg examples_prg module~kinds_mod kinds_mod module~kinds_mod->program~examples_prg module~plplotlib_mod plplotlib_mod module~kinds_mod->module~plplotlib_mod module~array_mod array_mod module~kinds_mod->module~array_mod module~text_mod text_mod module~kinds_mod->module~text_mod module~time_mod time_mod module~kinds_mod->module~time_mod module~plplotlib_mod->program~examples_prg module~array_mod->program~examples_prg module~array_mod->module~plplotlib_mod plplot plplot plplot->module~plplotlib_mod module~text_mod->module~plplotlib_mod module~time_mod->module~text_mod iso_fortran_env iso_fortran_env iso_fortran_env->module~text_mod iso_c_binding iso_c_binding iso_c_binding->module~time_mod
Help


A collection of example plots

Calls

program~~examples_prg~~CallsGraph program~examples_prg examples_prg proc~doerror doError program~examples_prg->proc~doerror proc~dobar doBar program~examples_prg->proc~dobar proc~dologplot doLogPlot program~examples_prg->proc~dologplot proc~docontour doContour program~examples_prg->proc~docontour proc~dohist doHist program~examples_prg->proc~dohist proc~setup setup program~examples_prg->proc~setup proc~dofillbetween doFillBetween program~examples_prg->proc~dofillbetween proc~dolegend doLegend program~examples_prg->proc~dolegend proc~show show program~examples_prg->proc~show proc~dosurface doSurface program~examples_prg->proc~dosurface proc~doquiver doQuiver program~examples_prg->proc~doquiver proc~doplot doPlot program~examples_prg->proc~doplot proc~doscatter doScatter program~examples_prg->proc~doscatter proc~xylim xylim proc~doerror->proc~xylim proc~subplot subplot proc~doerror->proc~subplot proc~linspace linspace proc~doerror->proc~linspace proc~ticks ticks proc~doerror->proc~ticks proc~figure figure proc~doerror->proc~figure proc~errorbar errorbar proc~doerror->proc~errorbar interface~mixval mixval proc~doerror->interface~mixval proc~labels labels proc~doerror->proc~labels proc~plot plot proc~doerror->proc~plot proc~dobar->proc~xylim proc~dobar->proc~subplot proc~dobar->proc~linspace proc~dobar->proc~ticks proc~dobar->proc~figure proc~dobar->interface~mixval proc~dobar->proc~labels proc~barh barh proc~dobar->proc~barh proc~bar bar proc~dobar->proc~bar proc~dologplot->proc~xylim proc~dologplot->proc~subplot proc~dologplot->proc~linspace proc~dologplot->proc~ticks proc~dologplot->proc~figure proc~dologplot->interface~mixval proc~dologplot->proc~labels proc~dologplot->proc~plot proc~docontour->proc~xylim proc~docontour->proc~subplot proc~docontour->proc~linspace proc~docontour->proc~ticks proc~docontour->proc~figure proc~docontour->interface~mixval proc~docontour->proc~labels proc~contourf contourf proc~docontour->proc~contourf proc~contour contour proc~docontour->proc~contour proc~colorbar colorbar proc~docontour->proc~colorbar proc~dohist->proc~xylim proc~dohist->proc~subplot proc~dohist->proc~ticks proc~dohist->proc~figure proc~dohist->interface~mixval proc~dohist->proc~bar proc~bindata binData proc~dohist->proc~bindata proc~hist hist proc~dohist->proc~hist plsfnam plsfnam proc~setup->plsfnam plsetopt plsetopt proc~setup->plsetopt plsfam plsfam proc~setup->plsfam plfontld plfontld proc~setup->plfontld plinit plinit proc~setup->plinit plsdev plsdev proc~setup->plsdev proc~dofillbetween->proc~xylim proc~dofillbetween->proc~subplot proc~dofillbetween->proc~linspace proc~dofillbetween->proc~ticks proc~dofillbetween->proc~figure proc~dofillbetween->interface~mixval proc~dofillbetween->proc~labels proc~dofillbetween->proc~plot proc~fillbetween fillBetween proc~dofillbetween->proc~fillbetween proc~dolegend->proc~xylim proc~dolegend->proc~subplot proc~dolegend->proc~linspace proc~dolegend->proc~ticks proc~dolegend->proc~figure proc~dolegend->interface~mixval proc~dolegend->proc~labels proc~dolegend->proc~plot proc~legend legend proc~dolegend->proc~legend plend plend proc~show->plend proc~dosurface->proc~subplot proc~dosurface->proc~linspace proc~dosurface->proc~figure proc~dosurface->interface~mixval proc~xyzlim xyzlim proc~dosurface->proc~xyzlim proc~surface surface proc~dosurface->proc~surface proc~box box proc~dosurface->proc~box proc~doquiver->proc~xylim proc~doquiver->proc~subplot proc~doquiver->proc~linspace proc~doquiver->proc~ticks proc~doquiver->proc~figure proc~doquiver->interface~mixval proc~doquiver->proc~labels proc~doquiver->proc~colorbar proc~quiver quiver proc~doquiver->proc~quiver proc~doplot->proc~xylim proc~doplot->proc~subplot proc~doplot->proc~linspace proc~doplot->proc~figure proc~doplot->interface~mixval proc~doplot->proc~plot proc~title title proc~doplot->proc~title proc~xticks xticks proc~doplot->proc~xticks proc~yticks yticks proc~doplot->proc~yticks proc~xlabel xlabel proc~doplot->proc~xlabel proc~ylabel ylabel proc~doplot->proc~ylabel proc~doscatter->proc~xylim proc~doscatter->proc~subplot proc~doscatter->proc~ticks proc~doscatter->proc~figure proc~doscatter->proc~labels proc~scatter scatter proc~doscatter->proc~scatter plwind plwind proc~xylim->plwind pladv pladv proc~subplot->pladv plvasp plvasp proc~subplot->plvasp plssub plssub proc~subplot->plssub plvpor plvpor proc~subplot->plvpor plvsta plvsta proc~subplot->plvsta plbox plbox proc~ticks->plbox proc~figure->pladv proc~figure->plssub plbop plbop proc~figure->plbop pleop pleop proc~figure->pleop plerry plerry proc~errorbar->plerry plerrx plerrx proc~errorbar->plerrx pllab pllab proc~labels->pllab plline plline proc~plot->plline plptex plptex proc~plot->plptex plssym plssym proc~plot->plssym proc~barh->interface~mixval proc~barh->plline plcol1 plcol1 proc~barh->plcol1 plfill plfill proc~barh->plfill proc~bar->interface~mixval proc~bar->plline proc~bar->plcol1 proc~bar->plfill proc~contourf->proc~linspace plshades plshades proc~contourf->plshades plcont plcont proc~contour->plcont plcolorbar plcolorbar proc~colorbar->plcolorbar proc~bindata->proc~linspace proc~hist->interface~mixval proc~hist->proc~bar proc~hist->proc~bindata proc~fillbetween->plfill pllegend pllegend proc~legend->pllegend proc~xyzlim->plwind plw3d plw3d proc~xyzlim->plw3d proc~surface->proc~linspace plsurf3d plsurf3d proc~surface->plsurf3d plbox3 plbox3 proc~box->plbox3 proc~quiver->interface~mixval proc~quiver->plcol1 plvect plvect proc~quiver->plvect plmtex plmtex proc~title->plmtex proc~xticks->plbox proc~yticks->plbox proc~xlabel->plmtex proc~ylabel->plmtex proc~scatter->interface~mixval proc~scatter->plptex proc~scatter->plssym proc~scatter->plcol1 plschr plschr proc~scatter->plschr
Help

Source Code


Subroutines

subroutine doPlot()

plot

Arguments

None

subroutine doScatter()

scatter

Arguments

None

subroutine doContour()

contour

Arguments

None

subroutine doLegend()

legend

Arguments

None

subroutine doQuiver()

quiver

Arguments

None

subroutine doBar()

bar

Arguments

None

subroutine doFillBetween()

fillBetween

Arguments

None

subroutine doHist()

hist

Arguments

None

subroutine doSurface()

surface

Arguments

None

subroutine doError()

error

Arguments

None

subroutine doLogPlot()

logPlot

Arguments

None

Source Code

program examples_prg
	!! A collection of example plots
	use kinds_mod
	use array_mod
	use plplotlib_mod
	implicit none
	
	call setup(device='svg',fileName='media/example-%n.svg',figSize=[320,240],transparent=.true.)
	
	call doPlot()
	call doScatter()
	call doContour()
	call doLegend()
	call doQuiver()
	call doBar()
	call doFillBetween()
	call doHist()
	call doSurface()
	call doError()
	call doLogPlot()
	
	call show()
	
contains

	subroutine doPlot
		!! ![plot](|media|/example-1.svg)
		integer,parameter::N = 20
		real(wp),dimension(N)::x,y
		
		x = linspace(0.0_wp,1.0_wp,N)
		y = x**2-1.0_wp
		
		call figure()
		call subplot(1,1,1)
		call xylim(mixval(x),mixval(y))
		
		call plot(x,y,lineColor='red',lineWidth=2.0_wp, &
			& markStyle='.',markColor='cyan',markSize=2.0_wp)
		
		call plot(x,-1.0_wp-y,lineColor='blue',lineStyle=':',lineWidth=2.0_wp, &
			& markStyle='+',markColor='green',markSize=1.0_wp)
		
!~ 		call ticks()
		call xticks(primary=.true.,secondary=.false.)
		call yticks(primary=.true.,secondary=.false.)
!~ 		call labels('x','y','f(x)=x#u2#d-1; g(x)=-x#u2#d')
		call xlabel('x')
		call ylabel('y')
		call title('f(x)=x#u2#d-1; g(x)=-x#u2#d')
	end subroutine doPlot

	subroutine doScatter
		!! ![scatter](|media|/example-2.svg)
		integer,parameter::N = 100
		real(wp),dimension(N)::x,y,z
		
		call random_number(x)
		call random_number(y)
		z = sqrt(x**2+y**2)
		
		call figure()
		
		call subplot(2,2,1)
		call xylim([0.0_wp,1.0_wp],[0.0_wp,1.0_wp])
		call scatter(x,y)
		call ticks()
		call labels('x','y','')
		
		call subplot(2,2,2)
		call xylim([0.0_wp,1.0_wp],[0.0_wp,1.0_wp])
		call scatter(x,y,c=z)
		call ticks()
		call labels('x','y','')
		
		call subplot(2,2,3)
		call xylim([0.0_wp,1.0_wp],[0.0_wp,1.0_wp])
		call scatter(x,y,s=(4.0_wp*z+1.0_wp),markColor='blue')
		call ticks()
		call labels('x','y','')
		
		call subplot(2,2,4)
		call xylim([0.0_wp,1.0_wp],[0.0_wp,1.0_wp])
		call scatter(x,y,c=z,s=(4.0_wp*z+1.0_wp))
		call ticks()
		call labels('x','y','')
	end subroutine doScatter

	subroutine doContour
		!! ![contour](|media|/example-3.svg)
		integer,parameter::N = 50
		real(wp),dimension(N)::x,y
		real(wp),dimension(N,N)::z
		integer::i,j
		
		x = linspace(-10.0_wp,10.0_wp,N)
		y = linspace(-10.0_wp,10.0_wp,N)
		forall(i=1:N,j=1:N)
			z(i,j) = sin( sqrt(x(i)**2+y(j)**2) )/sqrt(x(i)**2+y(j)**2)
		end forall
		
		call figure()
		
		call subplot(1,1,1,aspect=1.0_wp)
		call xylim(mixval(x),mixval(y))
		call contourf(x,y,z,10)
		call contour(x,y,z,10)
		call colorbar(z,5)
		call ticks()
		call labels('x','y','')
	end subroutine doContour

	subroutine doLegend
		!! ![legend](|media|/example-4.svg)
		integer,parameter::N = 20
		real(wp),dimension(N)::x,y
		character(32),dimension(3,7)::series
		
		x = linspace(0.0_wp,1.0_wp,N)
		y = x**2-1.0_wp
		
		call figure()
		call subplot(1,1,1)
		call xylim(mixval(x),mixval(y))
		
		call plot(x,y,lineColor='red',lineWidth=2.0_wp, &
			& markStyle='.',markColor='cyan',markSize=2.0_wp)
		
		call plot(x,-1.0_wp-y,lineColor='blue',lineStyle=':',lineWidth=2.0_wp, &
			& markStyle='+',markColor='green',markSize=1.0_wp)
		
		! [name,textColor,lineStyle,lineColor,markStyle,markColor]
		series(1,:) = [character(32)::'f(x)=x#u2#d-1','','-','r','.','c','']
		series(2,:) = [character(32)::'g(x)=-x#u2#d','',':','b','+','g','']
		series(3,:) = [character(32)::'Box','','','','','','r']
		
		call legend('center left',series)
		call ticks()
		call labels('x','y','')
	end subroutine doLegend

	subroutine doQuiver
		!! ![quiver](|media|/example-5.svg)
		integer,parameter::N = 20
		real(wp),dimension(N)::x,y
		real(wp),dimension(N,N)::u,v,m
		integer::i,j
		
		x = linspace(-10.0_wp,10.0_wp,N)
		y = linspace(-10.0_wp,10.0_wp,N)
		forall(i=1:N,j=1:N)
			u(i,j) = -y(j)
			v(i,j) =  x(i)
			m(i,j) = sqrt(u(i,j)**2+v(i,j)**2)
		end forall
		
		call figure()
		
		call subplot(1,1,1,aspect=1.0_wp)
		call xylim(mixval(x),mixval(y))
		call quiver(x,y,u,v,c=m,s=m,scaling=2.0_wp,lineWidth=2.0_wp)
		call colorbar(m,10)
		call ticks()
		call labels('x','y','')
	end subroutine doQuiver

	subroutine doBar
		!! ![bar](|media|/example-6.svg)
		integer,parameter::N = 21
		real(wp),dimension(N)::x,y
		
		x = linspace(-PI,PI,N)
		y = exp(-x**2)
		
		call figure()
		
		call subplot(1,2,1)
		call xylim(mixval(x)+[-0.1_wp,0.1_wp],mixval(y)+[ 0.0_wp,0.1_wp])
		call bar(x,y,c=y,relWidth=1.0_wp)
		call ticks()
		call labels('x','y','')
		
		call subplot(1,2,2)
		call xylim(mixval(y)+[ 0.0_wp,0.1_wp],mixval(x)+[-0.1_wp,0.1_wp])
		call barh(x,y,fillColor='r',relWidth=1.0_wp)
		call ticks()
		call labels('x','y','')
	end subroutine doBar

	subroutine doFillBetween
		!! ![fillBetween](|media|/example-7.svg)
		integer,parameter::N = 51
		real(wp),dimension(N)::x,y1,y2
		
		x = linspace(-3.0_wp,3.0_wp,N)
		y1 = x**2-1.0_wp
		y2 = x**3-1.0_wp
		
		call figure()
		call subplot(1,1,1)
		call xylim(mixval(x),mixval([y1,y2]))
		call fillBetween(x,y1,y2,fillColor='c',fillPattern='#',lineWidth=2.0_wp)
		call plot(x,y1,lineColor='k',lineWidth=3.0_wp)
		call plot(x,y2,lineColor='k',lineWidth=3.0_wp)
		call ticks(color='b',lineWidth=3.0_wp)
		call labels('x','y','f(x)=x#u2#d-1',color='r')
	end subroutine doFillBetween

	subroutine doHist
		!! ![hist](|media|/example-8.svg)
		integer,parameter::N = 10000
		real(wp),dimension(N,12)::r
		real(wp),dimension(N)::x
		real(wp),dimension(:,:),allocatable::h
		
		call random_number(r)
		x = sum(r,2)-6.0_wp
		call figure()
		
		call subplot(1,2,1)
		call xylim(mixval(x),[0.0_wp,1.05_wp])
		call hist(x,20)
		call ticks()
		
		h = binData(x,20,normalize=2)
		call subplot(1,2,2)
		call xylim(mixval(h(:,1)),[0.0_wp,1.05_wp*maxval(h(:,2))])
		call bar(h(:,1),h(:,2),c=h(:,2),relWidth=1.0_wp)
		call ticks()
	end subroutine doHist

	subroutine doSurface
		!! ![surface](|media|/example-9.svg)
		
		integer,parameter::N = 24
		real(wp),dimension(N)::x,y
		real(wp),dimension(N,N)::z
		integer::i,j
		
		x = linspace(-10.0_wp,10.0_wp,N)
		y = linspace(-10.0_wp,10.0_wp,N)
		forall(i=1:N,j=1:N)
			z(i,j) = sin( sqrt(x(i)**2+y(j)**2) )/sqrt(x(i)**2+y(j)**2)
		end forall
		
		call figure()
		
		call subplot(1,1,1,is3d=.true.)
		call xyzlim(mixval(x),mixval(y),mixval(z),zoom=1.1_wp)
		call surface(x,y,z,11)
!~ 		call wireframe(x,y,z,lineColor='k')
		call box('x','y','z')
		
	end subroutine doSurface

	subroutine doError
		!! ![error](|media|/example-10.svg)
		
		integer,parameter::N = 25
		real(wp),dimension(N)::x,y,xe,ye
		real(wp),dimension(12)::r
		real(wp)::m,s
		integer::k
		
		x = linspace(0.0_wp,5.0_wp,N)
		y = 1.0_wp/(x**2+1.0_wp)
		
		do k=1,N
			call random_number(r)
			r = 0.25_wp*(2.0_wp*r-1.0_wp)
			m = sum(r)/real(size(r))
			s = sqrt(sum((r-m)**2)/real(size(r)-1))
			x(k) = x(k)+m
			xe(k) = s
			
			call random_number(r)
			r = 0.15_wp*(2.0_wp*r-1.0_wp)
			m = sum(r)/real(size(r))
			s = sqrt(sum((r-m)**2)/real(size(r)-1))
			y(k) = y(k)+m
			ye(k) = s
		end do
		
		call figure()
		call subplot(1,1,1)
		call xylim(mixval([x-xe,x+xe])+[-0.5_wp,0.5_wp],mixval([y-ye,y+ye])+[-0.2_wp,0.2_wp])
		call errorbar(x,y,xerr=xe,yerr=ye,lineColor='b',lineWidth=1.0_wp)
		call plot(x,y,lineStyle='',markStyle='s',markColor='r',markSize=1.5_wp)
		call ticks()
		call labels('x','y','')
	end subroutine doError

	subroutine doLogPlot
		!! ![logPlot](|media|/example-11.svg)
		
		integer,parameter::N = 25
		real(wp),dimension(N)::x,y,yl
		
		x = linspace(0.0_wp,5.0_wp,N)
		y = exp(-x**2)
		yl = log10(y)
		
		call figure()
		call subplot(1,1,1)
		call xylim(mixval(x),mixval(yl))
		call plot(x,yl,lineColor='r',lineWidth=2.0_wp)
		call ticks(logy=.true.)
		call labels('x [linear]','y [log]','exp(-x#u2#d)')
	end subroutine doLogPlot

end program examples_prg