[英]RStudio: How to convert the horizontal axis to a natural log-scale in ggplot2?
我正在使用包 tidyverse 並希望將下圖的 X 軸縮放到值的自然對數。
require(tidyverse)
require(gapminder)
gapminder07 <- dplyr::filter(gapminder, year == 2007)
ggplot(data = gapminder07) +
geom_text(mapping = aes(x = gdpPercap, y = lifeExp, label = country))
它必須縮放到自然對數。
+ scale_x_continuous(trans = scales::log_trans(),
breaks = scales::log_breaks())
應該這樣做。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.