I need help, I have a question with doubleYScale

Hi, I'm very new to R.
I need help.
I want the first graph to look the same as the second graph.
These are my codes.

Code #1


obj1 <- xyplot(BLAmountFinished ~ Lotname, dataset, type = "l", lwd=2)
obj2 <- xyplot(BLScrap ~ Lotname, dataset, type = "l", lwd=2)

doubleYScale(obj1, obj2, text = c("obj1", "obj2") , add.ylab2 = TRUE)

Code #2


# create data
x <- 1:100
var1 <- cumsum(rnorm(100))
var2 <- var1^2
data <- data.frame(x,var1,var2)

# --> construct separate plots for each series
obj1 <- xyplot(var1 ~ x, data, type = "l" , lwd=2)
obj2 <- xyplot(var2 ~ x, data, type = "l", lwd=2)

# --> Make the plot with second y axis AND legend:
doubleYScale(obj1, obj2, text = c("obj1", "obj2") , add.ylab2 = TRUE)

What am I doing?

To help us help you, could you please turn this into a proper reproducible example (reprex) illustrating your issue, including sample data on a copy/paste friendly format? Please have a look at this guide, to see how to create one:

It looks like Lotname is a factor, and the plot is ordered by the factor index. Try changing Lotname to character.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.