ggplot问题,以直线形式出现

时间:2019-03-30 14:08:30

标签: r ggplot2 plot

我正在寻找吃冰淇淋和玩游戏之间的关系。

我的代码:

sizedata = read.table(file.choose(), header= T, sep =',')
View(sizedata)
summary(sizedata)
lm(Icecream ~ Games, sizedata)

library(ggplot2)

ggplot(sizedata, aes(x=Icecream, y=Games)) + geom_point() + ylim(0,1000) + 
  stat_smooth(method='lm')

ggplot(sizedata, aes(x=Icecream, y=Games)) + geom_point() + ylim(0,1000) + 
  geom_smooth()

图形显示如下:

enter image description here

This is my CSV file with the data

1 个答案:

答案 0 :(得分:0)

@Russ Hyde和@camille指出-您的ylim参数太高。尝试将其更改为较低的值,例如ylim(0,100)ylim(0,50)