Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tm_chart implemented (histogram, box plot, etc.); please review #842

Open
mtennekes opened this issue Mar 7, 2024 · 3 comments
Open

tm_chart implemented (histogram, box plot, etc.); please review #842

mtennekes opened this issue Mar 7, 2024 · 3 comments

Comments

@mtennekes
Copy link
Member

## numerical variable

tm_shape(World) + 
    tm_polygons ("HPI", 
                 fill.scale = tm_scale_intervals(), 
                 fill.chart = tm_chart_histogram())

tm_shape(World) + 
    tm_polygons ("HPI", 
                 fill.scale = tm_scale_continuous(), 
                 fill.chart = tm_chart_histogram(position = tm_pos_out("center", "bottom"), width = 30))
#> Warning: Some legend items or map compoments do not fit well (e.g. due to the
#> specified font size).

tm_shape(World) + 
    tm_polygons ("HPI", 
                 fill.scale = tm_scale_intervals(), 
                 fill.chart = tm_chart_donut())

tm_shape(World) + 
    tm_polygons ("HPI", 
                 fill.scale = tm_scale_intervals(), 
                 fill.chart = tm_chart_box())

tm_shape(World) + 
    tm_polygons ("HPI", 
                 fill.scale = tm_scale_intervals(), 
                 fill.chart = tm_chart_violin())

# 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"))))

tm_shape(land) +
    tm_raster("trees",
              col.chart = tm_chart_histogram())

## categorical variable
tm_shape(World) + 
    tm_polygons ("economy", 
                 fill.scale = tm_scale_categorical(), 
                 fill.chart = tm_chart_bar())

tm_shape(World) + 
    tm_polygons ("economy", 
                 fill.scale = tm_scale_categorical(), 
                 fill.chart = tm_chart_donut())

Created on 2024-03-07 with reprex v2.1.0

@LenLon
Copy link

LenLon commented Mar 11, 2024

Antarctica is a developing region? I had no idea :-D

@mtennekes
Copy link
Member Author

Antarctica is a developing region? I had no idea :-D

Me neither, but apparently that's what in the data is.

However, this brings up a question that comes back every now and then: in which CRS should the tmap example data be stored? In tmap3, World was in Eckert IV, but in tmap4 (so far) World is in 4326 (WGS84). Do we need to implement a "smart" automatic CRS, that is optimised for that bounding box? @Nowosad I thought this has been discussed, but I couldn't find the related issue.

@Nowosad
Copy link
Member

Nowosad commented Mar 13, 2024

@mtennekes I think you are looking for this discussion -- #457

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants