簡體   English   中英

RStudio:如何在 ggplot2 中將水平軸轉換為自然對數刻度?

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM