Skip to content
Discussion options

You must be logged in to vote

See https://stackoverflow.com/a/45765225/7877917 use show.legend = TRUE in the geom and drop = FALSE in the scale:

library(tidyterra)
#> 
#> Adjuntando el paquete: 'tidyterra'
#> The following object is masked from 'package:stats':
#> 
#>     filter
library(tidyverse)
library(terra)
#> terra 1.8.42
#> 
#> Adjuntando el paquete: 'terra'
#> The following object is masked from 'package:tidyr':
#> 
#>     extract
library(ggplot2)


r_init <- rast(system.file("ex/elev.tif", package = "terra"))

r1 <- r_init %>%
  mutate(
    cats = scales::rescale(elevation, to = c(0, 60)),
    lyr.1 = cut(cats,
      breaks = c(0, 10, 30, 60, 90, 120),
      labels = c("0-10", "10-30", "30-60", "60-90", "90-120"

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by mooibroekd
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
📊 ggplot2 Issues related with the implementation of ggplot2 functionalities ❔ q&a Questions on the usage of tidyterra
2 participants
Converted from issue

This discussion was converted from issue #176 on April 24, 2025 11:20.