legend Subroutine

public subroutine legend(corner, series, lineWidths, markScales, markCounts, ncol)

Arguments

Type IntentOptional AttributesName
character(len=*), intent(in) :: corner

Corner for legend

character(len=*), intent(in), dimension(:,:):: series

Data series in rows [name,textColor,lineStyle,lineColor,markStyle,markColor,boxColor]

real(kind=wp), intent(in), optional dimension(:):: lineWidths

Line widths for the plots

real(kind=wp), intent(in), optional dimension(:):: markScales

Marker sizes for the plots

integer, intent(in), optional dimension(:):: markCounts

Marker counts for the plots

integer, intent(in), optional :: ncol

Number of columns

Description

Create legend for plot data

FIXME: Text sizing should be modifiable

Calls

proc~~legend~~CallsGraph proc~legend legend 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 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
Help

Called By

proc~~legend~~CalledByGraph proc~legend legend proc~dolegend doLegend proc~dolegend->proc~legend program~examples_prg examples_prg program~examples_prg->proc~dolegend
Help

Variables

TypeVisibility AttributesNameInitial
real(kind=pp), public :: width
real(kind=pp), public :: height
real(kind=pp), public :: xoff
real(kind=pp), public :: yoff
real(kind=pp), public :: plotWidth
integer, public :: opt
integer, public :: cornerl
integer, public :: bg_color
integer, public :: bb_color
integer, public :: bb_style
integer, public :: lncol
integer, public :: lnrow
integer, public, dimension(size(series,1)):: opts
real(kind=pp), public, dimension(size(series,1)):: lwidths
real(kind=pp), public, dimension(size(series,1)):: mscales
integer, public, dimension(size(series,1)):: mcounts
integer, public, dimension(size(series,1)):: text_colors
real(kind=pp), public :: text_offset
real(kind=pp), public :: text_scale
real(kind=pp), public :: text_spacing
real(kind=pp), public :: text_justification
integer, public, dimension(size(series,1)):: box_colors
integer, public, dimension(size(series,1)):: box_patterns
real(kind=pp), public, dimension(size(series,1)):: box_scales
real(kind=pp), public, dimension(size(series,1)):: box_line_widths
integer, public, dimension(size(series,1)):: line_colors
integer, public, dimension(size(series,1)):: line_styles
integer, public, dimension(size(series,1)):: mark_colors
character(len=64), public, dimension(size(series,1)):: mark_styles
integer, public :: k

Functions

function getCorner(text) result(code)

Arguments

Type IntentOptional AttributesName
character(len=*), intent(in) :: text

Return Value integer


Subroutines

subroutine doLegendBox()

Arguments

None

subroutine doText()

Arguments

None

subroutine doBoxes()

Arguments

None

subroutine doLines()

Arguments

None

subroutine doMarkers()

Arguments

None

Source Code

	subroutine legend(corner,series,lineWidths,markScales,markCounts,ncol)
		!! Create legend for plot data
		!!
		!! FIXME: Text sizing should be modifiable
		character(*),intent(in)::corner
			!! Corner for legend
		character(*),dimension(:,:),intent(in)::series
			!! Data series in rows
			!! [name,textColor,lineStyle,lineColor,markStyle,markColor,boxColor]
		real(wp),dimension(:),intent(in),optional::lineWidths
			!! Line widths for the plots
		real(wp),dimension(:),intent(in),optional::markScales
			!! Marker sizes for the plots
		integer,dimension(:),intent(in),optional::markCounts
			!! Marker counts for the plots
		integer,intent(in),optional::ncol
			!! Number of columns
		
		real(pp)::width,height,xoff,yoff
		real(pp)::plotWidth
		integer::opt,cornerl
		integer::bg_color,bb_color,bb_style,lncol,lnrow
		integer,dimension(size(series,1))::opts
		real(pp),dimension(size(series,1))::lwidths,mscales
		integer,dimension(size(series,1))::mcounts,text_colors
		real(pp)::text_offset,text_scale,text_spacing,text_justification
		integer,dimension(size(series,1))::box_colors,box_patterns
		real(pp),dimension(size(series,1))::box_scales,box_line_widths
		integer,dimension(size(series,1))::line_colors,line_styles
		integer,dimension(size(series,1))::mark_colors
		character(64),dimension(size(series,1))::mark_styles
		integer::k
		
		call doLegendBox()
		
		opts = 0
		do k=1,size(series,1)
			if(series(k,3)/='') opts(k) = ior(opts(k),PL_LEGEND_LINE)
			if(series(k,5)/='') opts(k) = ior(opts(k),PL_LEGEND_SYMBOL)
			if(series(k,7)/='') opts(k) = ior(opts(k),PL_LEGEND_COLOR_BOX)
		end do
		
		call doText()
		call doBoxes()
		call doLines()
		call doMarkers()
		
		call pllegend(width,height,opt,cornerl,xoff,yoff,plotWidth, &
			& bg_color,bb_color,bb_style, &
			& lnrow,lncol,size(series,1),opts,text_offset, &
			& text_scale,text_spacing,text_justification,text_colors,series(:,1), &
			& box_colors,box_patterns,box_scales,box_line_widths, &
			& line_colors,line_styles,lwidths, &
			& mark_colors,mscales,mcounts,mark_styles)
		
	contains
	
		subroutine doLegendBox
			opt = PL_LEGEND_BACKGROUND+PL_LEGEND_BOUNDING_BOX
			cornerl = getCorner(corner)
			xoff = 0.0_pp
			yoff = 0.0_pp
			plotWidth = 0.05_pp
			bg_color = 0
			bb_color = 1
			bb_style = getLineStyleCode('-')
			
			lncol = 1
			if(present(ncol)) lncol = ncol
			lnrow = size(series,1)/lncol
		end subroutine doLegendBox
	
		subroutine doText
			text_offset  = 0.3_pp
			text_scale   = fontScale
			text_spacing = 3.0_pp
			text_justification = 0.0_pp
			
			do k=1,size(series,1)
				text_colors = getColorCode(series(k,2))
			end do
		end subroutine doText
	
		subroutine doBoxes
			do k=1,size(series,1)
				box_colors(k) = getColorCode(series(k,7))
			end do
			box_patterns = 0
			box_scales = 0.5_pp
			box_line_widths = 0.0_pp
		end subroutine doBoxes
	
		subroutine doLines
			lwidths = 1.0_pp
			if(present(lineWidths)) lwidths = real(lineWidths,pp)
			
			do k=1,size(series,1)
				line_colors(k) = getColorCode(series(k,4))
				line_styles(k) = getLineStyleCode(series(k,3))
			end do
		end subroutine doLines
	
		subroutine doMarkers
			mcounts = 2
			if(present(markCounts)) mcounts = markCounts
			mscales = 1.0_pp
			if(present(markScales)) mscales = real(markScales,pp)
			
			do k=1,size(series,1)
				mark_colors(k) = getColorCode(series(k,6))
				mark_styles(k) = getSymbolCode(series(k,5))
			end do
		end subroutine doMarkers
	
		function getCorner(text) result(code)
			character(*),intent(in)::text
			integer::code
			
			code = PL_POSITION_INSIDE
			if( startsWith(text,'upper') ) code = code+PL_POSITION_TOP
			if( startsWith(text,'lower') ) code = code+PL_POSITION_BOTTOM
			if(   endsWith(text,'right') ) code = code+PL_POSITION_RIGHT
			if(   endsWith(text,'left' ) ) code = code+PL_POSITION_LEFT
		end function getCorner
	
	end subroutine legend