file.txt:
comp col chr pch
0.0256626 black MT 20
0.03112212 black MT 20
0.03295112 black MT 20
0.03294942 black 1 20
0.02806124 black 1 20
0.03224467 black 1 20
0.03153024 black 1 20
0.0333732 black 1 20
0.03294344 black 1 20
0.02285203 black 1 20
0.03283011 black 1 20
0.0334126 blue 1 20
0.02593233 black 2 20
0.0297971 red 2 20
0.02666644 black 2 20
0.02882936 black 2 20
0.02870307 black 2 20
0.03222953 black 2 20
0.03314435 black 2 20
0.03346504 black 2 20
0.03131088 black 2 20
0.02862249 black 3 20
0.02477703 black 3 20
0.02890272 black 3 20
0.02822164 black 3 20
0.02886585 black 3 20
0.02753727 black 3 20
0.03026732 black 3 20
0.02918728 black 4 20
0.03045214 black 4 20
plot(file$comp, ylim = c(0,0.2), col=file$col,
cex=file$cex, pch = file$pch, xaxt="n")
Instead of getting a graph in which the X axis
is set to the number of observations (1:30)
, I want suppress that (xaxt="n")
and label the axis according to the column heading chr
. Thus, 3 observations under MT
, 9 under "1"
, and so on.
I'm sure there's a simple solution, any help is appreciated. Thanks!
You can use axis
df <- data.frame(
comp = c(0.0256626, 0.03112212, 0.03295112, 0.03294942, 0.02806124,
0.03224467, 0.03153024, 0.0333732,0.03294344, 0.02285203,
0.03283011, 0.0334126, 0.02593233, 0.0297971, 0.02666644,
0.02882936, 0.02870307, 0.03222953, 0.03314435, 0.03346504,
0.03131088, 0.02862249, 0.02477703, 0.02890272, 0.02822164,
0.02886585, 0.02753727, 0.03026732, 0.02918728, 0.03045214 ),
col = c(rep("black", 11), "blue", "black", "red", rep("black", 16)),
chr = c(rep("MT", 3), rep("1", 9), rep("2", 9), rep("3", 7), rep("4",2)),
pch = c(20))
plot(df$comp, ylim = c(0,0.2), col=df$col,
cex=df$cex, pch = df$pch, xaxt="n")
axis(1, at =1:nrow(df), labels = df$chr)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.