문제

I am using R to plot line chart, with the following command

data <- read.table("input_data.txt", header=T, sep="\t")

ind=seq(1,nrow(data),by=2)

pdf(file="result.pdf")

plot_colors <- c("black","red","green","blue","purple","red")

plot(data$column_one, type="l", lty=1, col=plot_colors[1], ann=FALSE)

lines(data$column_two, type="l", lty=2, col=plot_colors[2])

lines(data$column_three, type="o", pch=1, lty=0, col=plot_colors[3], cex=1)

lines(data$column_four, type="o", pch=3, lty=0, col=plot_colors[4], cex=1)

lines(data$column_five, type="o", pch=2, lty=0, col=plot_colors[5], cex=1)

lines(data$column_six, type="o", pch=4, lty=1, col=plot_colors[6], cex=1)

box()

dev.off()

The problem is, I have 500 data points, and the symbol markers are all mashed up on the line, tightly compact on the line. I could not see the symbols on the line.

Is there a way to just show the symbol markers at fixed interval, without them cluttering together?

enter image description here

도움이 되었습니까?

해결책

Use something like that:

lines(data$column_three, type="o", pch=c(1,NA,NA,NA,NA), lty=0, col=plot_colors[3], cex=1)

For the pch command: The number (here "1") defines your symbol as before. The "NA" means, that these points are plotted with no symbol. This vector will be repeatedly used until the end of your plot. Here, every 5th point is plotted with symbol 1.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top