Вопрос

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