I have a model and a graph in R:
fit.lmer = lmer(std_brain ~ std_beh*type*taught + (1|subject/run), data=avg_data)
graph_lmer = emmip(fit.lmer, type~std_beh | taught , at=list(type=type, std_beh=std_beh,
taught=taught), CIs=FALSE)
I always set CIs to false because the default style of the CIs makes the graph totally illegible -- there's a colorful vertical bar at every marking point on three different lines. You can't see the actual lines on the graph. But I see examples of the kind of bands I'd like using geom_smooth and stat_smooth with ggplot. Here's an example -- there's a solid band, rather than bars on points, and it's gray: However, I am not graphing points, I'm graphing marginal means, and so I don't think geom_smooth or stat_smooth are appropriate. What I really want is just to apply that style to my emmip graph. I can't find an example.
Related
In the below script, outliers on the boxplot are shown as individual scatter points. Instead, I would like the creation of the boxplot to include these and to not treat these points as outliers. Consequently, the box would be extended to include them.
ggplot(imp,aes(Group,LWG,fill=Group))+geom_boxplot()
As per the below picture, the bottom of the left boxplot would extend downwards further.
That would be inappropriate to extend the boxplot. The main thing about them is to show the quantiles, therefor an extension would make the boxplot statically wrong in its interpretation.
But you can remove the outliers with:
geom_boxplot(outlier.shape = NA)
I am currently working on curves generated in tensile tests of polymer specimens. Here, I try to generate a mean curve of five data sets generated at the same composition of the samples. Unfortunately, the resulting curve is not a function but has a vertical section which is why a simple smooth is not sufficient. Is there a way to fix the smoothed curve to a defined end point in R? Or an even better way that I did not see yet?
I already tried a geometric_smooth() from ggplot2 on all data points but it did not work as wished.
My current approach:
data <- read.csv("data.csv", header = TRUE, sep = ";")
ggplot(data, aes(y=stress, x=strain))+geom_point()+geom_smooth()
In the figure, you can see that the blue average curve does not fit the actual curves near their end points, probably due to the vertical sections. That's why I want to fix it to the mean end point. Additionally, I would like to fix it to (0|0) as the blue mean curve starts somewhere above it which does not fit the actual behaviour.
I often have to use plots mixing lines and points (ggplot2), with the colors of the line representing one variable (here, "Dose"), and the shape of the points another one (here, "Treatment). Figure 1 shows what I typically get:
Figure 1: what I get
I like having different legends for the two variables, but would like to remove the round markers from the color scale, to only show the colors (see legend mockup below, made with Gimp). Doing so would allow me to have a clean legend, with colors and shapes clearly segregated.
Figure 2 (mockup): what I would like
Would anyone know if there is a way to do that? Any help would be much appreciated.
Note: the plots above show means and error bars, but I have the same problem with any plot mixing geom_line and geom_point, even simple ones.
Thanks in advance !
I'm using plot.kde in library(ks) to extract contour levels of kernel density plots. I'd like to overlay multiple plots so I'm making the contour fills semi-transparent. However, there is a border/contour line whose color I just can't seem to control.
I have tried changing all of the different col,cont.col,color (etc) options in the plot.kde function and just can't seem to hone in on the color of the contour itself. I could probably use some work around by extracting the coordinates of the contour from the kde object and then plotting this using the polygon() function, but I'd really like to control this from within plot.kde. It's something I'll be running many times.
This is likely super simple but I'm just missing it! In the figure below, it's the thicker red line I'm trying to control.
Thanks!!!
library(ks)
data(unicef)
H.scv <- Hscv(x=unicef)
fhat <- kde(x=unicef, H=H.scv, compute.cont=TRUE)
plot(fhat, display="filled.contour2", cont=c(10),col=c(NA,rgb(1,0,0,0.5)))
I am trying to plot average ROC curves from different models using ROCR package.
I actually made it work, with each curve in different colors. However, in a black and white printing, I need to plot different curves with different symbols, rather than colors. I tried using type="o" and pch options in plot. However, I guess because the ROCR performance creates so many points for plotting an accurate roc curve, the curves just look like a very thick solid lines - you cannot tell which symbol used for each curve.
And here is the code that I used:
pred_our_update<-prediction(prob_our_update,label)
perf_our_update<-performance(pred_our_update,"tpr","fpr")
plot(perf_our_update,avg="vertical",spread.estimate="stderror",type="o", pch=1,add=TRUE)
Anyone know how to resolve this?
One easy solution is using the downsampling option to cut down the amount of data actually plotted, which may let the symbols stand out more without making any material difference to the shape of the curves. I don't know your data set size, but perhaps start with:
plot(perf_our_update,avg="vertical",spread.estimate="stderror",downsampling=0.1,type="o", pch=1,add=TRUE)