简体   繁体   English

ggplot2仅绘制轴-不绘制点

[英]ggplot2 only plotting axes - not the points

I have a CSV file like: 我有一个CSV文件,例如:

date;foo
2016-07-01;0,54
2016-08-01;0,54
2016-09-01;0,50
2016-10-01;0,49

but then read into R and plotted 但随后读入R并绘制

foo2 <- read.csv2("here")
ggplot(foo2, aes(x=date, y=foo))

The output is empty. 输出为空。 Ie axes are present but no points are plotted. 即,存在轴,但未绘制点。 A regular plot(foo2$foo) simply plots the points - what could be wrong here? 常规plot(foo2$foo)只是绘制点-这里可能出什么问题了?

You need to add a geom to your plot. 您需要在绘图中添加几何图形。 If you want a line plot add... 如果要添加线图...

ggplot(foo2, aes(x=date, y=foo)) + geom_line()

If you want a scatter plot... 如果要散点图...

ggplot(foo2, aes(x=date, y=foo)) + geom_point()

You can find more geoms here . 在这里可以找到更多的几何图形。

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

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