What is the simplest way to make just this plot grayscale (or perhaps black and white) rather than the default multi-colour:
xyplot(y1 + y2 ~ x, mydata, auto.key=TRUE)
I've seen discussion of creating new graphics devices or changing options for all plots, but is there an option that I can include perhaps in the xyplot()
function itself that will convert the plot to grayscale?
The xyplot () function can be used to create a scatter plot in R using the lattice package. The iris dataset is perfectly suited for this example. We can color the points of the scatter plot based on the categories. We can change the x and y labels and also add smoothing lines to the plot using the arguments in the xyplot () function.
Strip plots can be created in R using the stripplot () function of the lattice package. We will be using the same ToothGrowth dataset. 6. Density Plots in the Lattice Package We can create density plots in R using the densityplot () function of the lattice package.
The main focus of the package is multivariate data. It has a wide variety of functions that enable it to create basic plots of the base R package as well as enhance on them. Let us start looking at all the functions and graphs in the lattice package, one-by-one.
Now, we can use the ggplot and geom_point functions to draw a ggplot2 scatterplot in R: Figure 9: Scatterplot Created with the ggplot2 Package. Figure 9 contains the same XYplot as already shown in Example 1. This time, however, the scatterplot is visualized in the typical ggplot2 style.
library(lattice)
bwtheme <- standard.theme("pdf", color=FALSE)
mydata <- data.frame(y1=rnorm(10), y2=rnorm(10), x=1:10)
xyplot(y1 + y2 ~ x, mydata, auto.key=TRUE, par.settings=bwtheme)
For comparison:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With