# Specific sections with coplot in r

I coded a coplot function to create a separated graph depending on z. First, is it possible to create graphs depending on specific section of z, say i want a section from 0 to 150, 150 to 200, 200 to 250 and so on?

all_pit_data<- read.table("ALL_PIT_DATA.csv",header=TRUE,sep=",") cols <- terrain.colors(462) windows() coplot(all_pit_data$x1 ~ all_pit_data$y1 | all_pit_data$z1, number = 9, overlap = 0, col = cols[all_pit_data$z1], xlab= c("x", "z"), ylab="y")

Second, I would like to obtain a color filling like on this picture. the filling depends on the z variable. Any idea how it is possible?

## Answers

To answer your first question: The "given.values" argument in coplot lets you define the conditioning variable intervals (a in the formula y ~ x | a), but the input format is specific. It must be a matrix with 2 columns and n rows - the first column has the start points for each interval, and the second column has the ending points for each interval.

To break z into the intervals you stated above:

Create the matrix with the intervals:

given.z <- matrix(c(0, 150, 200, 250, 300, 350, 400, 450, 150, 200, 250, 300, 350, 400, 450, 500), nrow = 8, ncol = 2)

Create the plot:

coplot(x1 ~ y1 | z1, data = all_pit_data, given.values = given.z, xlab= c("x", "z"), ylab="y")