library(ggplot2) df = read.table("data.txt", header=T, sep="\t") data = df[order(df$length_bgi, decreasing=T), c(1,2,3)] input = melt(data, id='id') input$id = factor(input$id, levels = c(unique(input$id))) result = ggplot(input, aes(x=value, y=id)) + geom_li...
geom_line():折线图 ggplot(input,aes(x=Var2,y=value))+geom_boxplot(aes(color=Var2))+labs(x="指标(x轴)",y="值",color="指标(图例)")+theme(panel.grid=element_blank(),panel.background=element_rect(fill='transparent',color='black'))+geom_dotplot(binaxis='y',stackdir='center',dot...
Basic line chart with ggplot2 and geom_line() A line chart or line graph displays the evolution of one or several numeric variables. Data points are usually connected by straight line segments. You read an extensive definition here. The input data frame requires at least 2 columns: An ...
library(ggplot2) library(RColorBrewer) mydata<-read.csv("HighDensity_Scatter_Data.csv",stringsAsFactors=FALSE) head(mydata) 1. 2. 3. 4. 5. 我们利用ggplot()简单绘制二维数据的散点图,之后在对该数据进行聚类。 ggplot(data = mydata, aes(x,y)) + geom_point( colour="black",alpha=0.1)+ ...
library(ggplot2) # Basic line plot with points ggplot(data=df, aes(x=dose, y=len, group=1)) + geom_line()+ geom_point() # Change the line type ggplot(data=df, aes(x=dose, y=len, group=1)) + geom_line(linetype = "dashed")+ geom_point() # Change the color ggplot(d...
ggplot(aes(x=CAP1,y=CAP2))+ geom_point(aes(fill=Treatment), shape=21,size=5, color="gray", alpha=0.8)+ stat_ellipse(aes(group = Treatment), size = 0.5, level = 0.95, show.legend = F, lty="dashed")+ labs(x="CAP1 (22.6%)",y="CAP2 (6.8%)")+ ...
line(segmented.mod)$fit data1 <- data.frame(CL = CL, ChH = ChH, fit = fit) ggplot(data1, aes(x = CL, y = ChH)) + geom_point() + geom_line(aes(x = CL, y = fit), color = 'blue') 含义:将由segmented函数产生的分段线性模型的拟合值传递给先前创建的fit向量中。这里使用...
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 can apply the geom_line function as shown below. Note that we are multiplying the variable that we want to overlay as a line (i.e. responses) by ...
5. warming_plot <- ggplot(warming, aes(x = year, y = value)) + 6. geom_line(colour="black") + 7. geom_point(shape = 21, colour = "black", aes(fill = value), size=5, stroke=1) + 8. scale_x_continuous(limits = c(1880,2017)) + ...
(fm3_plot <- ggplot(env, aes(x = AP, y = pH, colour = tillage, shape = depth)) + geom_point(alpha = 0.8,size = 3.5) + theme_bw() + scale_color_manual(values = ggsci::pal_aaas()(4))+ scale_shape_manual(values = c(16,17,15))+ scale_linetype_manual(values = c(1,2...