繁体   English   中英

缩放gglot r中x轴上刻度线之间的距离

[英]Scale the distance between ticks on x-axis in gglot r

我有这样的图表。 我感兴趣的是范围(-3.5,0.5)之间的微小变化,然而,仅占据了x轴的一小部分,因此很难解释。

我尝试使用变换来记录比例以获得更好的可视化,但是,它显然不适用于负值。

那么是否有任何方法来扩展这个区域以使图形看起来更好?

码:

ggplot() + geom_line(data = Final_diction, aes(x = Final_diction[,1], y 
= Final_diction[,4])) +
xlim(-3.5,20) +
geom_vline(xintercept=c(-0.5,0.5), linetype="dashed", color = "red") +
geom_vline(xintercept=c(-0.25,0.25), linetype="dashed", color = "blue") +
theme_bw() +
theme(axis.title = element_text(size = 20)) +
theme(axis.text = element_text(size = 18))

在此输入图像描述

像这样的东西

library(ggforce)
library(ggolot2)
ggplot(mtcars, aes(x=mpg, y=disp, group=1)) +
  geom_line() + facet_zoom(xlim = c(15, 20))

您可以尝试添加xlim = c(minor value, major value)选项,并使用更适合您的范围

像这样的东西:

ggplot() + geom_line(data = Final_diction, aes(x = Final_diction[,1], y 
= Final_diction[,4])) +
xlim(-3.5,20) +
geom_vline(xintercept=c(-0.5,0.5), linetype="dashed", color = "red") +
geom_vline(xintercept=c(-0.25,0.25), linetype="dashed", color = "blue") +
theme_bw() +
theme(axis.title = element_text(size = 20)) +
theme(axis.text = element_text(size = 18)) +
xlim = c(-4, 1)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM