Formatting the border between lattice panels in R - r

When making a multi-panel plot in lattice, each panel is by default bordered by a black line. I would like to be able to adjust the color and width of these panel borders. Bonus points if you can show how to add a colored border around specific panel(s).
For instance, this code makes a plot with three panels, one for each unique value of df$gears. Each panel is bordered by a black line.
library(lattice)
xyplot(mpg~hp|factor(gear), mtcars, layout=c(3,1), between=list(x=c(1))
,par.settings=list(axis.line=list(col="lightgray")))
This code almost does what I want. It changes the borders (and tick marks) of all panels to light gray. Is there a way to change the color of components independently (e.g., left and right axes)? Is there a way to address the formatting for each sub-panel independently?
Thanks,
Bryan

Related

Is there a way to make a ggplot legend resize to the width and length of the viewport it is in?

I am building a grid of geom_treemaps. There are 2 plots, side by side in one row. I want to have the legend (a continuous color gradient) span underneath the length of the entire window. To do this, I am extracting the legend from another geom with get_legend(plot) and drawing it in its own viewport. When I draw the legend, it shows no regard for the constraints of the viewport. I can adjust the legend.key.width parameter in the theme() of the plot I extracted the legend from, but that process is very manual. Is there a way to coerce this legend to fit (specifically lengthwise) into a viewport?
Thank you for any responses.

Can ggplot2 Produce Flowcharts?

I would like to draw a simple flowchart in R. As shown in the example below, I would like to be able to determine:
the shape of the boxes
the color of the boxes
the position of the boxes
the text within the boxes
the direction of the arrows between the boxes
the text beside the boxes
There are several packages, that are able to draw such a flowchart (e.g. DiagrammeR). However, I am wondering if this is possible with ggplot2, since I would like to use the ggplot2 themes etc.

How to change the width of the boxplot frame in R

I am trying to change the thickness of the border containing the boxplot figure. Is there a way to do this in R? Attached is the image with an arrow pointing to the border that I am talking about whose thickness I would like to change illustration image
Thanks!
You can do that by overwriting the existing box with a heavier one.
boxplot(iris$Sepal.Length ~ iris$Species)
box(lwd=3)

ggplot2 "borders" of filled points

So first: I'm wholly new to programming and this is my second(?) week of R, so apologies in advance.
I'm using pch=21 and using a fill color to show a factor, but I'd like to control the border size of the points.
Is there any way to increase the border size of pch 21? Or is there another way of adding borders to points that will allow me to control border size?
ggplot(mpg, aes(x=model,y=cty))+
geom_point(color="black",size=3,pch=21,aes(fill=manufacturer))
The reason this is a problem is because I'd like to use white filled points on a white background (it's just a common style in my field), but they're too hard to see unless I make the black border more distinct.

How to change the background color of the plot title in ggplot2?

I am going to change the background color of the title which is plot by gglot2, making it look like using facet. Actually, it seems I could plot just using one facet. But are there any other parameters that could change the background color of a title of a plot?

Resources