Closed Joaobazzo closed 6 months ago
Obrigado, @Joaobazzo, vamos investigar. @PedroJorge7, por favor, coloque na sua fila de ajustes a serem feitos.
@PedroJorge7,
Acho que o problema está neste trecho do script e theme_ipea, alterado recentemente:
# y_var <- plot$mapping$x
# y_var <- rlang::eval_tidy(y_var, plot$data)
for (i in seq_along(plot$layers)) {
if ("fill" %in% names(plot$layers[[i]]$mapping)) {
x_var <- plot$layers[[i]]$mapping$x
x_var <- rlang::eval_tidy(x_var, plot$layers[[i]]$data)
break
} else {
x_var <- plot$mapping$x
x_var <- rlang::eval_tidy(x_var, plot$data)
}
}
for (i in seq_along(plot$layers)) {
if ("fill" %in% names(plot$layers[[i]]$mapping)) {
y_var <- plot$layers[[i]]$mapping$y
y_var <- rlang::eval_tidy(y_var, plot$layers[[i]]$data)
break
} else {
y_var <- plot$mapping$y
y_var <- rlang::eval_tidy(y_var, plot$data)
}
}
test <- NULL
for (i in seq_along(plot$layers)) {
temp <- grepl('bar',plot$layers[[i]]$constructor)
test <- rbind(test,temp)
}
test <- test[grepl('TRUE',test)]
breaks = args$x_breaks
if(length(test) > 0 & expand_y_limit == TRUE){
warning('Due to the existence of a bar chart, the `expand_y_limit` argument will be converted to FALSE')
expand_y_limit = FALSE
warning('Due to the existence of a bar chart, the `x_breaks ` argument will be converted to the number of options available')
breaks = length(unique(x_var))
}
Opa @Joaobazzo. Valeu pelo apontamento. Isso acontece porque as especificações do aes estão dentro do geomarea, mas a indicação da base esta dentro do ggplot. Fizemos a inclusão de busca para procurar a base dentro do ggplot() quando não tiver especificação da base dentro do geom*
library(ggplot2)
library(ipeaplot)
df <- data.frame(x1 = 1:10,y=1:10,z = c(rep(LETTERS[1],5)
,rep(LETTERS[2],5)))
df
#> x1 y z
#> 1 1 1 A
#> 2 2 2 A
#> 3 3 3 A
#> 4 4 4 A
#> 5 5 5 A
#> 6 6 6 B
#> 7 7 7 B
#> 8 8 8 B
#> 9 9 9 B
#> 10 10 10 B
p <- ggplot(df)+
geom_area(aes(x = x1,group = z,y = y,fill = z),
linewidth = 0.25
,color = "black") +
ipeaplot::theme_ipea(legend.position = "bottom")
p
Warning message:
Due to the existence of a Area graph, the `expand_y_limit` argument will be converted to FALSE
obrigado!
acredito que está relacionado ao #44 Ver reprex
Created on 2024-03-13 with reprex v2.1.0