Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typescript/9.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
x轴刻度标签赢得';t在Rstudio中使用ggplot2进行拟合_R_Ggplot2_Rstudio - Fatal编程技术网

x轴刻度标签赢得';t在Rstudio中使用ggplot2进行拟合

x轴刻度标签赢得';t在Rstudio中使用ggplot2进行拟合,r,ggplot2,rstudio,R,Ggplot2,Rstudio,我试图在Rstudio中使用带有ggplot2的对数比例绘制一个图形,最后一个x轴刻度标签将无法在图形上显示 这是我的绘图代码 ggplot(data=user.counts, aes(x=counter, y=Number_obs)) + geom_line()+ scale_y_log10(breaks=c(1,10,100,1000,10000),labels=c(1,10,100,1000,10000))+ scale_x_log10(breaks=c(1,10,100,1000,100

我试图在Rstudio中使用带有ggplot2的对数比例绘制一个图形,最后一个x轴刻度标签将无法在图形上显示

这是我的绘图代码

ggplot(data=user.counts, aes(x=counter, y=Number_obs)) +
geom_line()+
scale_y_log10(breaks=c(1,10,100,1000,10000),labels=c(1,10,100,1000,10000))+
scale_x_log10(breaks=c(1,10,100,1000,10000),labels=c(1,10,100,1000,10000))+
labs(x="No. observers",y="No. observations",title="")+
theme_bw(base_size = 20)
这是我的图表截图:

我曾尝试在RStudio中放大绘图窗格并弹出绘图窗格,但这两种方法都没有效果


非常感谢选项1。右对齐x轴标签:

ggplot(data=user.counts, aes(x=counter, y=Number_obs)) +
  geom_line()+
  scale_y_log10(breaks=c(1,10,100,1000,10000), labels=c(1,10,100,1000,10000))+
  scale_x_log10(breaks=c(1,10,100,1000,10000), labels=c(1,10,100,1000,10000))+
  labs(x="No. observers",y="No. observations",title="")+
  theme_bw(base_size = 20) +
  theme(axis.text.x = element_text(hjust = 1)) # default is hjust = 0.5

选项2。增加膨胀常数:

ggplot(data=user.counts, aes(x=counter, y=Number_obs)) +
  geom_line()+
  scale_y_log10(breaks=c(1,10,100,1000,10000), labels=c(1,10,100,1000,10000))+
  scale_x_log10(breaks=c(1,10,100,1000,10000), labels=c(1,10,100,1000,10000),
                expand = c(0.1, 0))+ # default is c(0.05, 0) for continuous variable
  labs(x="No. observers", y="No. observations", title="")+
  theme_bw(base_size = 20)

使用的样本数据:

set.seed(1)
user.counts <- data.frame(
  counter = seq(1, 1000),
  Number_obs = seq(1000, 1) * 10 + rnorm(1000)
)
set.seed(1)

user.counts在1000到10000个观察者之间的可视范围(观察次数)中是否有任何数据?请在
theme\u bw()
中尝试较小的
base\u size