

The dimensions of the scale must again be supplied for bi_scale_fill() (they should match the dimensions given for bi_class()!), and a palette must be given. We also want to remove the legend from the plot since it will not accurately communicate the complexity of the bivariate scale. This requires that the variable bi_class, created with bi_class(), is used as the fill variable in the aesthetic mapping. Louis, MO", subtitle = "Gray Pink (GrPink) Palette" ) + bi_theme ( ) # create map map <- ggplot ( ) + geom_sf (data = data, mapping = aes (fill = bi_class ), color = "white", size = 0.1, show.legend = FALSE ) + bi_scale_fill (pal = "GrPink", dim = 3 ) + labs ( title = "Race and Income in St. For an overview of these options, see the “Options for Breaks and Legends” vignette. Users should therefore choose methods for calculating breaks carefully as well as the number of dimensions mapped.Īs of v1.0, biscale now supports larger dimension maps as well as custom breaks for maps. Using one of the other approaches to calculating breaks yields a narrower range for the breaks and produces a map that does not overstate the percent of white residents living on the north side of St. Louis: With the sample data, this creates a very broad range for the percent white measure in particular. For a four-by-four map, breaks are created at the 25th, 50th (median), and 75th percentiles. The default "quantile" approach will create relatively equal “buckets” of data for mapping, with a break created at the median (50th percentile) for a two-by-two map or at the 33rd and 66th percentiles for a three-by-three map. The dim argument is used to control the extent of the legend - do you want to produce a two-by-two map ( dim = 2), a three-by-three map ( dim = 3), or a four-by-four map ( dim = 4)? Note that support for four-by-four mapping is new as of v1.0.0!Ĭlasses can be applied with the style parameter using four approaches for calculating breaks: "quantile" (default), "equal", "fisher", and "jenks". # load dependencies library ( biscale ) # create classes data <- bi_class ( stl_race_income, x = pctWhite, y = medInc, style = "quantile", dim = 3 )
#Biscale function rcode install#
If you want to use them, you can either install these packages individually (faster) or install all of the suggested dependencies at once (slower, will also give you a number of other packages you may or may not want):

Like sf, it is suggested because none of the functions in biscale call cowplot directly. All of the examples in the package documentation utilize it to construct final map images that combine the map with the legend. The other suggested dependency that users may want to consider installing is cowplot. Linux users will need to install several open source spatial libraries to get sf itself up and running.
#Biscale function rcode windows#
Windows and macOS users should be able to install sf without significant issues unless they are building from source. However, the most direct approach to using biscale is with sf objects, and we therefore recommend users install sf.

Since the package does not directly use functions from sf, it is a suggested dependency rather than a required one.
