Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/78.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R 在不进行变换的情况下,在ggplot2中指定具有比例的打断数?_R_Ggplot2 - Fatal编程技术网

R 在不进行变换的情况下,在ggplot2中指定具有比例的打断数?

R 在不进行变换的情况下,在ggplot2中指定具有比例的打断数?,r,ggplot2,R,Ggplot2,如果我希望我的数据轴有更多的断点,但没有对值进行转换,那么如何在ggplot2中进行转换?例如: ... + scale_x_continuous(breaks=scales.trans_breaks("log2", function(x) 2^x, n=8), limits=limits) 如果您希望转换数据,则可以使用n=参数说明中断次数。如何在不转换数据的情况下指定中断?你只是给它一个标识函数吗 您可以给scale_x_continuous一个中断向量,如下所示: n=5 break

如果我希望我的数据轴有更多的断点,但没有对值进行转换,那么如何在ggplot2中进行转换?例如:

... + scale_x_continuous(breaks=scales.trans_breaks("log2", function(x) 2^x, n=8),   limits=limits)

如果您希望转换数据,则可以使用
n=
参数说明中断次数。如何在不转换数据的情况下指定中断?你只是给它一个标识函数吗

您可以给
scale_x_continuous
一个中断向量,如下所示:

n=5
breaks = seq(min(dat$x),max(dat$x), length.out = n)
m + scale_x_continuous(breaks=breaks)

我不希望根据数据中的计算给出明确的记号,因此我希望ggplot2仅在给定限制和记号数的情况下为我选取记号。此代码适用于我:

 library(scales)
 scale_x_continuous(breaks = trans_breaks(identity, identity, n = numticks))

当然,正如agstudy所写,您总是可以使用
breaks=…
明确地设置刻度线。

我知道,但我不想指定breaks值,只想指定数字,因为您不使用任何转换,您最好使用
pretty\u breaks
而不是
trans\u breaks