ggplot2 "borders" of filled points - r

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.

Related

Plot legend text doesn't fit

I have problem with size of my legend. The values in this legend are very small like 2e-18 (an example below) and they take up a lot of space. What can I do in this situation?
You can play with the keywidth property, to make the legend take up more space, or set a smaller font via the label.theme setting (see the online help).

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)

How to make grids covered by figures?

I am new to RRDtool. I generated a graph with grid(--grid-dash 1:0), a LINE(LINE1:rt#4e9a06) and I also have the area between the line and the x-axis coloured (AREA:rt#4e9a06 ). I notice the grid still shows up in the colored-area. I am wondering if there is any way to cover the grid with the colored-area.
Also, I am also wondering if there is any good-looking rrdtool samples/examples available online? Thanks.
I have no way of testing this currently, but here's what the documentation says (emphasis mine) :
[-c|--color COLORTAG#rrggbb[aa]]
Override the default colors for the standard elements of the graph.
The COLORTAG is one of BACK background, CANVAS for the background of
the actual graph, SHADEA for the left and top border, SHADEB for the
right and bottom border, GRID, MGRID for the major grid, FONT for the
color of the font, AXIS for the axis of the graph, FRAME for the line
around the color spots, and finally ARROW for the arrow head pointing
up and forward. Each color is composed out of three hexadecimal
numbers specifying its rgb color component (00 is off, FF is maximum)
of red, green and blue. Optionally you may add another hexadecimal
number specifying the transparency (FF is solid). You may set this
option several times to alter multiple defaults.
What about making an almost transparent grid with arguments like these (note the extra 7F parameter which translates to 127 in decimal):
-c MGRID#<hex triplet>7F -c GRID#<hex triplet>7F
It should still be visible in the background but be invisible (or barely noticeable) once any graph covers it.
Note that this answer from the developer of RRDTool says that the grid is always painted after the graph, so in the end you'll always have it in the foreground, your only solution is to either totally disable it or tinker with color/transparency parameters to make it invisible when covered by the graphed data.

Formatting the border between lattice panels in 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

mschart: Different background colors for different y-value ranges?

Is there any way I can create a line chart using mschart where the chart area's background color changes for different ranges of y values?
For instance, a line chart would have a green background for y values 0 - 10, a yellow background for y values 10 - 20 and a red background for y values 20 - 30.
A gradient will not work, the colors must be solid.
I might have to use a background image, but I think there might be a better way. Unfortunately, web searches haven't turned anything up.
I've decided the only way to do this is to use a background image. Where needed I can use GDI+ to create the image at runtime with the proper height and width.
you can also use custom labels feature of MSchart.
int element = Chart1.ChartAreas["Default"].AxisY.CustomLabels.Add(0, 10,"Low");
element = Chart1.ChartAreas["Default"].AxisY.CustomLabels.Add(10, 20, "Medium");
element = Chart1.ChartAreas["Default"].AxisY.CustomLabels.Add(20,30,"High");

Resources