我正在尝试使用ggplot2和自定义X轴缩放比例scales::trans_new()。但是,当我这样做时,某些轴标签会丢失。有人可以帮我找出原因吗?
设定:
library(tidyverse)
# the data
ds <- tibble(
myx = c(1, .5, .1, .01, .001, 0),
myy = 1:6
)
# the custom transformation
forth_root_trans_rev <- scales::trans_new(
name = "sign_fourth_root_rev",
transform = function (x) { - abs(x)^(1/4) },
inverse = function (x) { x^4 }
)
Run Code Online (Sandbox Code Playgroud)
当我尝试绘制此图x = 0时,迷路的标签会丢失。
# plot - missing x-label at `0`
ggplot(ds, aes(x = myx, y = myy)) +
geom_line() +
geom_point() +
scale_x_continuous(
trans = forth_root_trans_rev, …Run Code Online (Sandbox Code Playgroud)