2

I am trying combine the multiple plots according to on of the thread here my problem is I want to separate based on coloured plot with different values can any one help me what I am missing, (Note: my original data i have some 30 column values)

data(iris)
list_data=c("Petal.Length", "Petal.Width")
# Make plots.
plot_list = list()
for (i in list_data) {
  p = ggplot(iris, aes(y=Sepal.Length, x=Sepal.Width)) +
    geom_point(size=3, aes(colour=i))
  plot_list[[i]] = p
}

pdf("plots.pdf")
for (i in list_data) {
  print(plot_list[[i]])
}

dev.off()
0

1 Answer 1

2

We may use .data[[i]] in colour

for (i in list_data) {
  p = ggplot(iris, aes(y=Sepal.Length, x=Sepal.Width)) +
    geom_point(size=3, aes(colour=.data[[i]]))
  plot_list[[i]] = p
}

-output

> plot_list[[1]]

enter image description here

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.