Description Usage Arguments Details Value Author(s) Examples
The function will produce a map with bars centred on country centroids (or other chosen points). The length of the bars is determined by the sum of the attribute columns and each section is coloured.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | mapBars(dF = ""         
        , nameX="longitude", nameY="latitude" 
        , nameZs=c(names(dF)[3],names(dF)[4])
        , zColours=c(1:length(nameZs))
  
        , barWidth = 1
        , barOrient = 'vert' 
        , barRelative = TRUE
  
        , ratio = 1
        , addCatLegend = TRUE
        , addSizeLegend = TRUE
        
        , symbolSize = 1 
        , maxZVal=NA
        , xlim=NA
        , ylim=NA                        
        , mapRegion = "world"                                                      
        , borderCol = "grey"
        , oceanCol=NA
        , landCol=NA
        , add=FALSE                        
        , main=''
        , lwd=0.5
        , lwdSymbols=1
        ,... )          
          
 | 
| dF | data frame or SpatialPolygonsDataFrame | 
| nameX | name of column containing the X variable (longitude), not needed if dF is a SpatialPolygonsDataFrame | 
| nameY | name of column containing the Y variable (lattitude), not needed if dF is a SpatialPolygonsDataFrame | 
| nameZs | name of columns containing numeric variables to determine bar sections | 
| zColours | colours to apply to the bar section for each attribute column | 
| barWidth | multiple for the width of bar symbols, relative to barOrient see below | 
| barOrient | orientation of bars, options 'horiz' and 'vert' | 
| barRelative | default is TRUE, each variable (column) is scaled to it's maximum value | 
| ratio | the ratio of Y to N in the output map, set to 1 as default | 
| addCatLegend | whether to add a legend for categories | 
| addSizeLegend | whether to add a legend for symbol size | 
| symbolSize | multiplier of default symbol size | 
| maxZVal | the attribute value corresponding to the maximum symbol size, this can be used to set the scaling the same between multiple plots | 
| xlim | map extents c(west,east), can be overidden by mapRegion | 
| ylim | map extents c(south,north), can be overidden by mapRegion | 
| mapRegion | a country name from getMap()[['NAME']] or 'world','africa','oceania','eurasia','uk' sets map extents, overrides xlim,ylim | 
| borderCol | the colour for country borders | 
| oceanCol | a colour for the ocean | 
| landCol | a colour to fill countries | 
| add | whether to add the symbols to an existing map, TRUE/FALSE | 
| main | title for the map | 
| lwd | line width for country borders | 
| lwdSymbols | line width for symbols | 
| ... | any extra arguments to points() | 
Horizontal or vertical bars can be achieved by using the barOrient argument 'horiz' or 'vert'.
currently doesn't return anything
andy south
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | #getting example data
#dF <- getMap()@data  
sPDF <- getMap()
  
## these examples repeat the same column in 'nameZs' to show that equal sized bars are created 
#mapBars( dF,nameX="LON", nameY="LAT",nameZs=c('POP_EST','POP_EST') )
#mapBars( dF,nameX="LON", nameY="LAT",nameZs=c('POP_EST','POP_EST'),mapRegion='africa' )
#mapBars( dF,nameX="LON", nameY="LAT"
#       , nameZs=c('POP_EST','POP_EST','POP_EST','POP_EST'),mapRegion='africa' )
#mapBars( dF,nameX="LON", nameY="LAT"
#       , nameZs=c('POP_EST','POP_EST','POP_EST','POP_EST'),mapRegion='africa',symbolSize=2 )
mapBars( sPDF, 
       , nameZs=c('POP_EST','GDP_MD_EST')
       , mapRegion='africa'
       , symbolSize=4 )
# this does work too
#mapBars( dF,nameX="LON", nameY="LAT" 
#       , nameZs=c('POP_EST','GDP_MD_EST')
#       , mapRegion='africa'
#       , symbolSize=4 )       
  
 | 
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.