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~utilities_mod utilities_mod module~kinds_mod->module~utilities_mod module~plplotlib_mod->program~examples_prg plplot plplot plplot->module~plplotlib_mod module~utilities_mod->module~plplotlib_mod iso_fortran_env iso_fortran_env iso_fortran_env->module~utilities_mod
Help


A collection of example plots

Calls

program~~examples_prg~~CallsGraph program~examples_prg examples_prg proc~doplot doPlot program~examples_prg->proc~doplot proc~dolegend doLegend program~examples_prg->proc~dolegend proc~dobar doBar program~examples_prg->proc~dobar 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~doerror doError program~examples_prg->proc~doerror proc~doquiver doQuiver program~examples_prg->proc~doquiver proc~dosurface doSurface program~examples_prg->proc~dosurface proc~dofillbetween doFillBetween program~examples_prg->proc~dofillbetween proc~show show program~examples_prg->proc~show proc~doscatter doScatter program~examples_prg->proc~doscatter proc~dologplot doLogPlot program~examples_prg->proc~dologplot proc~title title proc~doplot->proc~title proc~plot plot proc~doplot->proc~plot proc~yticks yticks proc~doplot->proc~yticks proc~xylim xylim proc~doplot->proc~xylim proc~xlabel xlabel proc~doplot->proc~xlabel proc~linspace linspace proc~doplot->proc~linspace interface~mixval mixval proc~doplot->interface~mixval proc~ylabel ylabel proc~doplot->proc~ylabel proc~xticks xticks proc~doplot->proc~xticks proc~figure figure proc~doplot->proc~figure proc~subplot subplot proc~doplot->proc~subplot proc~dolegend->proc~plot proc~dolegend->proc~xylim proc~dolegend->proc~linspace proc~dolegend->interface~mixval proc~dolegend->proc~figure proc~dolegend->proc~subplot proc~ticks ticks proc~dolegend->proc~ticks proc~legend legend proc~dolegend->proc~legend proc~labels labels proc~dolegend->proc~labels proc~dobar->proc~xylim proc~dobar->proc~linspace proc~dobar->interface~mixval proc~dobar->proc~figure proc~dobar->proc~subplot proc~dobar->proc~ticks proc~dobar->proc~labels proc~bar bar proc~dobar->proc~bar proc~barh barh proc~dobar->proc~barh proc~docontour->proc~xylim proc~docontour->proc~linspace proc~docontour->interface~mixval proc~docontour->proc~figure proc~docontour->proc~subplot proc~docontour->proc~ticks proc~docontour->proc~labels proc~contour contour proc~docontour->proc~contour proc~colorbar colorbar proc~docontour->proc~colorbar proc~contourf contourf proc~docontour->proc~contourf proc~dohist->proc~xylim proc~dohist->interface~mixval proc~dohist->proc~figure proc~dohist->proc~subplot proc~dohist->proc~ticks proc~dohist->proc~bar proc~hist hist proc~dohist->proc~hist proc~bindata binData proc~dohist->proc~bindata plfontld plfontld proc~setup->plfontld plsetopt plsetopt proc~setup->plsetopt plinit plinit proc~setup->plinit plsdev plsdev proc~setup->plsdev plsfam plsfam proc~setup->plsfam plsfnam plsfnam proc~setup->plsfnam proc~doerror->proc~plot proc~doerror->proc~xylim proc~doerror->proc~linspace proc~doerror->interface~mixval proc~doerror->proc~figure proc~doerror->proc~subplot proc~doerror->proc~ticks proc~doerror->proc~labels proc~errorbar errorbar proc~doerror->proc~errorbar proc~doquiver->proc~xylim proc~doquiver->proc~linspace proc~doquiver->interface~mixval proc~doquiver->proc~figure proc~doquiver->proc~subplot proc~doquiver->proc~ticks proc~doquiver->proc~labels proc~doquiver->proc~colorbar proc~quiver quiver proc~doquiver->proc~quiver proc~dosurface->proc~linspace proc~dosurface->interface~mixval proc~dosurface->proc~figure proc~dosurface->proc~subplot proc~box box proc~dosurface->proc~box proc~surface surface proc~dosurface->proc~surface proc~xyzlim xyzlim proc~dosurface->proc~xyzlim proc~dofillbetween->proc~plot proc~dofillbetween->proc~xylim proc~dofillbetween->proc~linspace proc~dofillbetween->interface~mixval proc~dofillbetween->proc~figure proc~dofillbetween->proc~subplot proc~dofillbetween->proc~ticks proc~dofillbetween->proc~labels proc~fillbetween fillBetween proc~dofillbetween->proc~fillbetween plend plend proc~show->plend proc~doscatter->proc~xylim proc~doscatter->proc~figure proc~doscatter->proc~subplot proc~doscatter->proc~ticks proc~doscatter->proc~labels proc~scatter scatter proc~doscatter->proc~scatter proc~dologplot->proc~plot proc~dologplot->proc~xylim proc~dologplot->proc~linspace proc~dologplot->interface~mixval proc~dologplot->proc~figure proc~dologplot->proc~subplot proc~dologplot->proc~ticks proc~dologplot->proc~labels plmtex plmtex proc~title->plmtex plline plline proc~plot->plline plssym plssym proc~plot->plssym plptex plptex proc~plot->plptex plbox plbox proc~yticks->plbox plwind plwind proc~xylim->plwind proc~xlabel->plmtex proc~ylabel->plmtex proc~xticks->plbox pleop pleop proc~figure->pleop plbop plbop proc~figure->plbop pladv pladv proc~figure->pladv plssub plssub proc~figure->plssub proc~subplot->pladv proc~subplot->plssub plvasp plvasp proc~subplot->plvasp plvsta plvsta proc~subplot->plvsta plvpor plvpor proc~subplot->plvpor proc~ticks->plbox none~dolines doLines proc~legend->none~dolines pllegend pllegend proc~legend->pllegend none~domarkers doMarkers proc~legend->none~domarkers none~dolegendbox doLegendBox proc~legend->none~dolegendbox none~dotext doText proc~legend->none~dotext none~doboxes doBoxes proc~legend->none~doboxes pllab pllab proc~labels->pllab series series none~dolines->series none~domarkers->series none~getcorner getCorner none~dolegendbox->none~getcorner none~dotext->series none~doboxes->series proc~startswith startsWith none~getcorner->proc~startswith proc~endswith endsWith none~getcorner->proc~endswith proc~bar->interface~mixval proc~bar->plline plcol1 plcol1 proc~bar->plcol1 plfill plfill proc~bar->plfill proc~barh->interface~mixval proc~barh->plline proc~barh->plcol1 proc~barh->plfill plcont plcont proc~contour->plcont plcolorbar plcolorbar proc~colorbar->plcolorbar proc~contourf->proc~linspace plshades plshades proc~contourf->plshades proc~hist->interface~mixval proc~hist->proc~bar proc~hist->proc~bindata proc~bindata->proc~linspace plerry plerry proc~errorbar->plerry plerrx plerrx proc~errorbar->plerrx proc~quiver->interface~mixval proc~quiver->plcol1 plvect plvect proc~quiver->plvect plbox3 plbox3 proc~box->plbox3 proc~surface->proc~linspace plsurf3d plsurf3d proc~surface->plsurf3d proc~xyzlim->plwind plw3d plw3d proc~xyzlim->plw3d proc~fillbetween->plfill proc~scatter->interface~mixval proc~scatter->plssym proc~scatter->plptex proc~scatter->plcol1 plschr plschr proc~scatter->plschr
Help

Subroutines

subroutine doPlot()

Arguments

None

Description

plot

subroutine doScatter()

Arguments

None

Description

scatter

subroutine doContour()

Arguments

None

Description

contour

subroutine doLegend()

Arguments

None

Description

legend

subroutine doQuiver()

Arguments

None

Description

quiver

subroutine doBar()

Arguments

None

Description

bar

subroutine doFillBetween()

Arguments

None

Description

fillBetween

subroutine doHist()

Arguments

None

Description

hist

subroutine doSurface()

Arguments

None

Description

surface

subroutine doError()

Arguments

None

Description

error

subroutine doLogPlot()

Arguments

None

Description

logPlot

Source Code

program examples_prg
	!! A collection of example plots
	use kinds_mod
	use plplotlib_mod
	implicit none
	
	call setup(device='svgqt',fileName='examples/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