# Line plot with multiple groups # Change line types and colors by groups (sex) ggplot(df2, aes(x=time, y=bill, group=sex)) + geom_line(aes(linetype = sex, color = sex))+ geom_point(aes(color=sex))+ theme(legend.position="top") 1. 2. 3. 4. 5. 6. 同点一样,线也可以类...
# Change line types, colors and sizes ggplot(df2, aes(x=time, y=bill, group=sex)) + geom_line(aes(linetype=sex, color=sex, size=sex))+ geom_point()+ scale_linetype_manual(values=c("twodash", "dotted"))+ scale_color_manual(values=c('#999999','#E69F00'))+ scale_size_manua...
ggplot(data = economics, aes(x = date, y = psavert))+ geom_line() Plot with multiple lines Well plot both ‘psavert’ and ‘uempmed’ on the same line chart. Solution 1: Make two calls to geom_line(): ggplot(economics, aes(x=date)) + geom_line(aes(y = psavert), color ...
###library(ggplot2)# 加载包library(faraway)data(worldcup)head(worldcup)wc_plot<-ggplot(worldcup,aes(x=Time,y=Passes))+geom_point()grid.draw(wc_plot)grid.draw(my_circle) 当前生成的图形可能并不实用,但通过使用视图窗口(viewports)和坐标系统,可以使其更具功能性。 编辑ggplot对象:可以使用grid图形...
ggplot(data, aes(x, y))+# Draw ggplot2 plotgeom_line()+geom_point() As shown in Figure 1, we created a line and point plot (i.e. a graph where the lines connect the points) using the ggplot2 package with the previously shown R syntax. ...
geom_line():用于绘制线图,将所有的数据点按照x轴上的顺序进行连接,展示数据随时间或其他连续变量的...
By executing the previous code we have plotted Figure 1, i.e. a ggplot2 bargraph without any lines or secondary y-axes. Let’s modify this plot! Example 1: Add Line to ggplot2 Barplot Example 1 illustrates how to overlay a line on top of a ggplot2 barchart. To achieve this, we ...
分面:在一个图形中绘制多个图(Faceting: Draw multiple plots within one figure) 修改图背景,长轴和短轴(Modifying Plot Background, Major and Minor Axis) 参考文档 http://r-statistics.co/Complete-Ggplot2-Tutorial-Part1-With-R-Code.html 让我们从midwest数据集中的人口相对于面积的散点图开始。点的颜色...
### second plot: 2 colors, jagged lines ggplot(dat) + geom_line(aes(x = t, y = y)) + theme_bw() + theme(panel.grid = element_blank()) # ggsave("tmp/line1b.eps", device = "eps", # width = 6, height = 6) 在显示zoomed-in线的屏幕截图中,我们观察到第一个图中的线是平滑...
options(repr.plot.width=4, repr.plot.height=4) labs(x ="Log2 fold change",y ="-Log10(P-value)", title = my_title) + # geom_hline(aes(yintercept=1), colour="grey50", linetype="dashed", size=0.2) + # geom_vline(aes(xintercept=0.5), colour="red", linetype="dashed", si...