ggplot2我如何更改轴刻度

时间:2020-03-31 11:17:27

标签: r ggplot2

修复我的图表的几个问题: 如何更改轴标签的大小,以便数字不重叠。 如何更改Yaxis刻度,使其以小数点表示,而不是科学数字。

GGplot2出现一个错误,说我的值是离散的,为什么R认为列表是离散的而不是连续的,我该如何更改呢?

这是我的代码:

chart <- ggplot( data = alpha, aes(x = `Gini_coefficient_2016`, y = `GVA_per_worker_2017__£`,  color = `Region`), size = 10) 
    chart + geom_point(shape = 19,
                       alpha = 0.25,
                       position = position_jitter(width = 1, height = 0.5)) +     theme(axis.text=element_text(size=12),
            axis.title=element_text(size=5,face="bold")) + 
      theme(axis.title.x = element_text(size = 5), panel.grid.major = element_blank(), panel.grid =     element_blank(), panel.background = element_rect(fill = 'white', colour = 'white'))

这是图表当前的外观。问题中所有证明的问题都可以在这里找到。

pic

谢谢!

1 个答案:

答案 0 :(得分:0)

如果要在变量周围插入as.numeric(),例如

ggplot( data = alpha, aes(x = as.numeric(`Gini_coefficient_2016`), y = as.numeric(`GVA_per_worker_2017__£`),  color = `Region`), size = 10) 
chart + geom_point(shape = 19,
                   alpha = 0.25,
                   position = position_jitter(width = 1, height = 0.5)) +     theme(axis.text=element_text(size=12),
        axis.title=element_text(size=5,face="bold")) + 
  theme(axis.title.x = element_text(size = 5), panel.grid.major = element_blank(), panel.grid =     element_blank(), panel.background = element_rect(fill = 'white', colour = 'white'))

我想这将解决您的问题,而无需访问数据/可复制的示例。