Skip to contents

Charts

Numerical variable

tm_shape(World) + 
  tm_polygons("HPI", 
    fill.scale = tm_scale_intervals(), 
    fill.chart = tm_chart_histogram())
#> [plot mode] legend/component: Some components or legends are too "high" and are
#> therefore rescaled.
#>  Set the tmap option `component.autoscale = FALSE` to disable rescaling.

tm_shape(World) + 
    tm_polygons("HPI", 
                fill.scale = tm_scale_continuous(), 
                fill.chart = tm_chart_histogram(
                    position = tm_pos_out("center", "bottom"),
                    width = 30)
                )
#> [plot mode] fit legend/component: Some legend items or map compoments do not
#> fit well, and are therefore rescaled.
#>  Set the tmap option `component.autoscale = FALSE` to disable rescaling.

tm_shape(World) + 
    tm_polygons("HPI", 
                fill.scale = tm_scale_intervals(), 
                fill.chart = tm_chart_donut())
#> [plot mode] legend/component: Some components or legends are too "high" and are
#> therefore rescaled.
#>  Set the tmap option `component.autoscale = FALSE` to disable rescaling.

tm_shape(World) + 
    tm_polygons("HPI", 
                fill.scale = tm_scale_intervals(), 
                fill.chart = tm_chart_box())
#> [plot mode] legend/component: Some components or legends are too "high" and are
#> therefore rescaled.
#>  Set the tmap option `component.autoscale = FALSE` to disable rescaling.

tm_shape(World) + 
    tm_polygons("HPI", 
                fill.scale = tm_scale_intervals(), 
                fill.chart = tm_chart_violin())
#> [plot mode] legend/component: Some components or legends are too "high" and are
#> therefore rescaled.
#>  Set the tmap option `component.autoscale = FALSE` to disable rescaling.

# with additional ggplot2 code
require(ggplot2)
#> Loading required package: ggplot2
tm_shape(World) + 
    tm_polygons("HPI", 
                fill.scale = tm_scale_intervals(), 
                fill.chart = tm_chart_bar(
                    extra.ggplot2 = theme(
                        panel.grid.major.y = element_line(colour = "red")
                    ))
                )
#> [plot mode] legend/component: Some components or legends are too "high" and are
#> therefore rescaled.
#>  Set the tmap option `component.autoscale = FALSE` to disable rescaling.

tm_shape(land) +
    tm_raster("trees",
              col.chart = tm_chart_histogram())
#> [plot mode] legend/component: Some components or legends are too "high" and are
#> therefore rescaled.
#>  Set the tmap option `component.autoscale = FALSE` to disable rescaling.

Categorical variable

tm_shape(World) + 
    tm_polygons("economy", 
                fill.scale = tm_scale_categorical(), 
                fill.chart = tm_chart_bar())
#> [plot mode] legend/component: Some components or legends are too "high" and are
#> therefore rescaled.
#>  Set the tmap option `component.autoscale = FALSE` to disable rescaling.

tm_shape(World) + 
    tm_polygons("economy", 
                fill.scale = tm_scale_categorical(), 
                fill.chart = tm_chart_donut())
#> [plot mode] legend/component: Some components or legends are too "high" and are
#> therefore rescaled.
#>  Set the tmap option `component.autoscale = FALSE` to disable rescaling.

tm_shape(World) +
    tm_polygons(tm_vars(c("HPI", "well_being"), multivariate = TRUE),
                fill.chart = tm_chart_heatmap())
#> [plot mode] legend/component: Some components or legends are too "high" and are
#> therefore rescaled.
#>  Set the tmap option `component.autoscale = FALSE` to disable rescaling.
#> Labels abbreviated by the first letters, e.g.: "2 to 3" => "2"