You want to use different shapes and line types in your graph.
Solution
Note that with bitmap output, the filled symbols 15-18 may render without proper anti-aliasing; they can appear jagged, pixelated, and not properly centered, though this varies among platforms. Symbols 19 and 21-25 have an outline around the filled area, and will render with smoothed edges on most platforms. For symbols 21-25 to appear solid, you will also need to specify a fill (bg) color that is the same as the outline color (col); otherwise they will be hollow.
Standard graphics
Use the pch option to set the shape, and use lty and lwd to set the line type and width. The line type can be specified by name or by number.
set.seed(331)# Plot some points withlines
# Set up the plotting area
par(mar=c(3,3,2,2))plot(NA,xlim=c(1,4),ylim=c(0,1))# Plot solid circles with solid linespoints(1:4,runif(4),type="b",pch=19)# Addopen squares with dashed line, with heavier line width
points(1:4,runif(4),type="b",pch=0,lty=2,lwd=3)points(1:4,runif(4),type="b",pch=23,# Diamond shape
lty="dotted",cex=2,# Dotted line, double-size shapes
col="#000099",bg="#FF6666")# blue line, red fill
ggplot2
With ggplot2, shapes and line types can be assigned overall (e.g., if you want all points to be squares, or all lines to be dashed), or they can be conditioned on a variable.
# Sample datadf<-read.table(header=T,text='
cond xval yval
A 1 2.0
A 2 2.5
B 1 3.0
B 2 2.0
')library(ggplot2)# Plot with standard lines and points# group = cond tells it which points to connect with linesggplot(df,aes(x=xval,y=yval,group=cond))+geom_line()+geom_point()# Set overall shapes and line typeggplot(df,aes(x=xval,y=yval,group=cond))+geom_line(linetype="dashed",# Dashed linesize=1.5)+# Thicker linegeom_point(shape=0,# Hollow squaressize=4)# Large points# Condition shapes and line type on variable condggplot(df,aes(x=xval,y=yval,group=cond))+geom_line(aes(linetype=cond),# Line type depends on condsize=1.5)+# Thicker linegeom_point(aes(shape=cond),# Shape depends on condsize=4)# Large points# Same as previous, but also change the specific linetypes and# shapes that are usedggplot(df,aes(x=xval,y=yval,group=cond))+geom_line(aes(linetype=cond),# Line type depends on condsize=1.5)+# Thicker linegeom_point(aes(shape=cond),# Shape depends on condsize=4)+# Large pointsscale_shape_manual(values=c(6,5))+# Change shapesscale_linetype_manual(values=c("dotdash","dotted"))# Change linetypes
By default, ggplot2 uses solid shapes. If you want to use hollow shapes, without manually declaring each shape, you can use scale_shape(solid=FALSE). Note, however, that the lines will visible inside the shape. To avoid this, you can use shapes 21-25 and specify a white fill.
# Hollow shapesggplot(df,aes(x=xval,y=yval,group=cond))+geom_line(aes(linetype=cond),# Line type depends on condsize=1.5)+# Thicker linegeom_point(aes(shape=cond),# Shape depends on condsize=4)+# Large pointsscale_shape(solid=FALSE)# Shapes with white fillggplot(df,aes(x=xval,y=yval,group=cond))+geom_line(aes(linetype=cond),# Line type depends on condsize=1.5)+# Thicker linegeom_point(aes(shape=cond),# Shape depends on condfill="white",# White fillsize=4)+# Large pointsscale_shape_manual(values=c(21,24))# Shapes: Filled circle, triangle
Note
This code will generate the chart of line types seen at the top.
par(mar=c(0,0,0,0))# Set up the plotting area
plot(NA,xlim=c(0,1),ylim=c(6.5,-0.5),xaxt="n",yaxt="n",xlab=NA,ylab=NA)# Draw the linesfor(iin0:6){points(c(0.25,1),c(i,i),lty=i,lwd=2,type="l")}# Add labels
text(0,0,"0. 'blank'",adj=c(0,.5))text(0,1,"1. 'solid'",adj=c(0,.5))text(0,2,"2. 'dashed'",adj=c(0,.5))text(0,3,"3. 'dotted'",adj=c(0,.5))text(0,4,"4. 'dotdash'",adj=c(0,.5))text(0,5,"5. 'longdash'",adj=c(0,.5))text(0,6,"6. 'twodash'",adj=c(0,.5))
Multivariate data analysis and graphical display of microarray data. Functions include between group analysis and coinertia analysis. It contains functions that require ADE4.
Author: Aedin Culhane
Maintainer: Aedin Culhane <Aedin at jimmy.harvard.edu>
Citation (from within R, enter citation(“made4”)):
AC C, J T, G P, DG H (2005). “MADE4:an R package for multivariate analysis of gene expression data.” Bioinformatics, 21(11), 2789-90.
Installation
To install this package, start R and enter: ## try http:// if https:// URLs are not supported
source("https://bioconductor.org/biocLite.R")
biocLite("made4")
Documentation
To view documentation for the version of this package installed in your system, start R and enter: browseVignettes("made4")
During startup – Warning messages:
1: Setting LC_CTYPE failed, using “C”
2: Setting LC_COLLATE failed, using “C”
3: Setting LC_TIME failed, using “C”
4: Setting LC_MESSAGES failed, using “C”
5: Setting LC_PAPER failed, using “C”
[R.app GUI 1.50 (6126) x86_64-apple-darwin9.8.0]
WARNING: You’re using a non-UTF8 locale, therefore only ASCII characters will work. Please read R for Mac OS X FAQ (see Help) section 9 and adjust your system preferences accordingly.
answer:
Open Terminal
Write or paste in: defaults write org.R-project.R force.LANG en_US.UTF-8