I just used the function plot_model (package: sjPlot) and "ci.lvl = NA" to remove the red lines and add instead the three black ones with "geom_lines". Usually it works perfectly, but as you can see in fig. 1 there is sometimes still a small part of the red line left. How can I remove this one?
Example:
#model lmer
Jitter_Mikro_temporal<-lmer(cyano~pH
+(1|month)+
(1|StationID),
data=count_all)
summary(Jitter_Mikro_temporal)
#base
plot<-plot_model(Jitter_Mikro_temporal, type = "pred", terms = c("pH"),title="Microscopy", size=6, ci.lvl=NA)
plot.incl.full.SID
fig.incl.full.SID<-plot.incl.full.SID+theme_bw()+
ylab(expression("Cyanobacteria [%]"))+
xlab("pH")+
geom_jitter(data=count_all,aes
(x=pH,y=cyano,col=StationID),size=.1,alpha=1)
#second plot on top of first one
fig.pH.2<- fig.incl.full.SID +theme_bw()+
ylab(expression("Cyanobacteria [%]"))+
xlab("pH")+
xlim(7,9)+
geom_jitter(data=count_all,
aes(x=pH,y=cyano,col=StationID),size=.1,alpha=1)
#remove red lines, instead black ones:
raw.1.micro<-fig.pH.2+
geom_line(data=pH_K, aes(x=pH, y=fit), color="black",size=1.5)+
geom_line(data=pH_K, aes(x=pH, y=lower), color="black",size=1, linetype=2)+
geom_line(data=pH_K, aes(x=pH, y=upper), color="black",size=1, linetype=2)
raw.1.micro
Part of the data: dput(Jitter_Mikro_temporal)
Scaled residuals:
Min 1Q Median 3Q Max
-3.1299 -0.2447 -0.1149 0.0564 5.5750
Random effects:
Groups Name Variance Std.Dev.
month (Intercept) 74.194 8.614
StationID (Intercept) 5.507 2.347
Residual 63.855 7.991
Number of obs: 99, groups: month, 12; StationID, 4
Fixed effects:
Estimate Std. Error df t value Pr(>|t|)
(Intercept) 85.73 33.02 88.92 2.597 0.0110 *
pH -10.30 4.09 87.91 -2.519 0.0136 *
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Correlation of Fixed Effects:
(Intr)
pH -0.996
dput(count_all[1:50,])
structure(list(StationID = c("Bork_W_1", "Bork_W_1", "Bork_W_1",
"Bork_W_1", "Bork_W_1", "Bork_W_1", "Bork_W_1", "Bork_W_1", "Bork_W_1",
"Bork_W_1", "Bork_W_1", "Bork_W_1", "Bork_W_1", "Bork_W_1", "Bork_W_1",
"Bork_W_1", "Bork_W_1", "Bork_W_1", "Bork_W_1", "Bork_W_1", "Bork_W_1",
"Bork_W_1", "Bork_W_1", "Bork_W_1", "Bork_W_1", "Bork_W_1", "Bork_W_1",
"Bork_W_1", "Bork_W_1", "Bork_W_1", "Bork_W_1", "Bork_W_1", "Bork_W_1",
"Bork_W_1", "Bork_W_1", "Bork_W_1", "Bork_W_1", "Bork_W_1", "Bork_W_1",
"Bork_W_1", "Bork_W_1", "Bork_W_1", "Bork_W_1", "Bork_W_1", "Bork_W_1",
"Bork_W_1", "Bork_W_1", "Bork_W_1", "Bork_W_1", "Bork_W_1"),
date = structure(c(13558, 13640, 13724, 13822, 13913, 13956,
13984, 14007, 14013, 14046, 14074, 14082, 14179, 14298, 14389,
14431, 14550, 14665, 14739, 14830, 14930, 15049, 15078, 15106,
15154, 15180, 15196, 15245, 15271, 15404, 15490, 15551, 15656,
15789, 15804, 15847, 15869, 15894, 15924, 15950, 15980, 16141,
16176, 16202, 16252, 16267, 16293, 16323, 16511, 16533), class = "Date"),
X = c(27L, 28L, 29L, 30L, 31L, 32L, 33L, 34L, 35L, 36L, 38L,
39L, 40L, 42L, 43L, 44L, 45L, 46L, 47L, 48L, 49L, 51L, 52L,
53L, 55L, 56L, 57L, 58L, 59L, 60L, 61L, 62L, 63L, 64L, 65L,
66L, 67L, 68L, 69L, 71L, 72L, 74L, 75L, 76L, 77L, 78L, 80L,
82L, 84L, 85L), Country = c("Germany", "Germany", "Germany",
"Germany", "Germany", "Germany", "Germany", "Germany", "Germany",
"Germany", "Germany", "Germany", "Germany", "Germany", "Germany",
"Germany", "Germany", "Germany", "Germany", "Germany", "Germany",
"Germany", "Germany", "Germany", "Germany", "Germany", "Germany",
"Germany", "Germany", "Germany", "Germany", "Germany", "Germany",
"Germany", "Germany", "Germany", "Germany", "Germany", "Germany",
"Germany", "Germany", "Germany", "Germany", "Germany", "Germany",
"Germany", "Germany", "Germany", "Germany", "Germany"), month = c("Feb",
"May", "Jul", "Nov", "Feb", "Mar", "Apr", "May", "May", "Jun",
"Jul", "Jul", "Oct", "Feb", "May", "Jul", "Nov", "Feb", "May",
"Aug", "Nov", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep",
"Oct", "Mar", "May", "Jul", "Nov", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Mar", "Apr", "May", "Jul", "Jul",
"Aug", "Sep", "Mar", "Apr"), year.x = c(2007L, 2007L, 2007L,
2007L, 2008L, 2008L, 2008L, 2008L, 2008L, 2008L, 2008L, 2008L,
2008L, 2009L, 2009L, 2009L, 2009L, 2010L, 2010L, 2010L, 2010L,
2011L, 2011L, 2011L, 2011L, 2011L, 2011L, 2011L, 2011L, 2012L,
2012L, 2012L, 2012L, 2013L, 2013L, 2013L, 2013L, 2013L, 2013L,
2013L, 2013L, 2014L, 2014L, 2014L, 2014L, 2014L, 2014L, 2014L,
2015L, 2015L), total.p = c(7.1, NA, NA, 4.84, 3.87, NA, NA,
NA, NA, NA, NA, NA, NA, 4.19, NA, NA, 2.29, 4.52, NA, NA,
4.84, NA, 2.94, NA, NA, 4.84, NA, 3.55, 11.61, 6.13, 2.52,
2.74, 2.39, 4.19, 3.23, 4.19, 3.23, NA, NA, 3.55, 4.84, 5.48,
3.55, 2.35, 4.52, 4.84, 5.81, 4.19, 3.06, 5.16), total.n = c(178.57,
NA, NA, 107.14, 192.86, NA, NA, NA, NA, NA, NA, NA, NA, 85.71,
NA, NA, 57.86, 171.43, NA, NA, 85.71, NA, 128.57, NA, NA,
65.71, NA, 45, 121.43, 185.71, 35, 41.43, 40, 128.57, 150,
107.14, 78.57, NA, NA, 57.14, 85.71, 178.57, 85.71, 85.71,
85.71, 78.57, 78.57, 60.71, 135.71, 164.29), DIN = c(160.79,
NA, NA, 77.29, 157.5, NA, NA, NA, NA, NA, NA, NA, NA, 64.64,
NA, NA, 27.63, 155.71, NA, NA, 50.86, NA, 90.85, NA, NA,
37.64, NA, 24.86, 56.35, 141.43, 19.75, 19.43, 23.72, 83.57,
96.29, 14.63, 22.88, NA, NA, 17.64, 35.71, 109.43, 47.16,
35.85, 36.5, 43.64, 37.14, 8.47, 97.72, 106.78), DIP = c(1.45,
NA, NA, 2.55, 1.77, NA, NA, NA, NA, NA, NA, NA, NA, 1.19,
NA, NA, 1.55, 1.35, NA, NA, 1.48, NA, 1.06, NA, NA, 3.13,
NA, 2.19, 2.45, 1.48, 0.97, 1.9, 1.55, 1.16, 1.48, 0.81,
1.48, NA, NA, 2.52, 2.87, 1.42, 0.84, 1, 2.06, 2.9, 3.23,
1.71, 1.06, 1), silicon = c(4.52925339939235, NA, NA, 4.1043938980751,
4.44920230052569, NA, NA, NA, NA, NA, NA, NA, NA, 4.21744675935608,
NA, NA, 2.40423874672055, 4.45096950491079, NA, NA, 4.49188949952913,
NA, 3.67097003357037, NA, NA, 3.83794580203183, NA, 3.67097003357037,
4.45096950491079, 4.31748811353631, 1.26976054486394, 3.15997471694804,
3.55534806148941, 4.04550439680263, NA, 1.9643112344262,
NA, NA, NA, 2.86220088092947, 3.67097003357037, 4.04550439680263,
3.01357219168232, 2.46725171454928, 3.17513290192028, 3.57543076160636,
3.83794580203183, 3.40119738166216, 4.04550439680263, 3.75793899004543
), salinity = c(NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, 24.6, NA, 25.7, NA, NA, 26.7,
NA, NA, 25, 25.2, 27.8, 27.8, 28.6, 28.1, NA, 22.1), temperature = c(3.9,
NA, NA, 10, 4.3, NA, NA, NA, NA, NA, NA, NA, NA, 2.9, NA,
NA, 10.5, 0.4, NA, NA, 7.4, NA, 10.5, NA, NA, 16, NA, 17.4,
9.3, 5.6, 17.2, 18.7, 8.3, 0.6, 2.9, 11.7, 16.4, NA, NA,
18.9, 12.2, 7.1, 9.5, 12.3, 18.5, 23, 21.2, 17.2, 6.5, 8.3
), pH = c(7.85, NA, NA, 8.15, 8.2, NA, NA, NA, NA, NA, NA,
NA, NA, 8.05, NA, NA, 7.9, 8.05, NA, NA, 8.05, NA, 8.15,
NA, NA, 7.95, NA, 7.85, 7.95, 8, 8.2, 7.95, 7.85, 8.15, 8.01,
8.5, 8.02, NA, NA, 8.12, 8.09, 7.95, 8.11, 8.13, 8.05, 8,
8.05, 8.44, 8.04, 7.89), suspended.particulates = c(96, NA,
NA, 45, 41, NA, NA, NA, NA, NA, NA, NA, NA, 47, NA, NA, 45,
67, NA, NA, 72, NA, 82, NA, NA, 83, NA, 50, 19.8, 100, 49,
43, 50, 100, 141.67, 82, 56.404, NA, NA, 79.76, 90.47, 110,
146.68, 97.66, 150.65, 139.54, 145.84, 126.06, 113.39, 176.05
), sum_chl = c(NA, NA, NA, NA, 0.982078472412158, NA, NA,
1.52169899812609, NA, NA, NA, 2.03861954715958, NA, 1.41585316336144,
3.22565280914722, 1.87946504964716, 1.08518926833597, 1.84213567655312,
2.92798862146747, 2.58550584834412, 2.24918431626693, 2.81839825827108,
2.49072303510944, 2.60268968544438, 3.7000666435045, 2.31550131826059,
2.76190687389292, 1.79674701073909, 3.09376601382536, 1.94876321803772,
2.94127608775793, 1.49065437644413, 1.69193913394584, 2.04640168760164,
1.7630170003624, 4.23772314506745, 2.18380155700408, 2.85876641848083,
2.44755086324423, 2.278292400425, 2.28238238567653, 2.39880395073459,
2.94443897916644, 1.69561560867515, 2.45787797740008, 2.16561923792089,
2.38600670113312, 2.66305283517147, 2.69934576047206, 3.25924971900647
), sum_carbon_l = c(2.8, 286.38, 86.46, 12.4, 8.14, 73, 400.54,
1298.28, 859.47, 82.87, 6.63, 24.96, 80.87, 9.59, 869.76,
74.013262, 25.81, 9.92, 227.86, 105.3, 3.033875, 13.32, 37.59,
44.59, 747.62, 28.27, 38.94, 23.662976, 5.617917, 22.613875,
174.36, 162.88, 17.35, 9.55, 21.78, 1177.82, 129.3328123,
74.69, 125.6, 66.01, 67.09, 16.67, 93.41, 63.81, 21.63, 56.623875,
28.062187, 343.74, 24.556158, 27.93), year.y = c(2007L, 2007L,
2007L, 2007L, 2008L, 2008L, 2008L, 2008L, 2008L, 2008L, 2008L,
2008L, 2008L, 2009L, 2009L, 2009L, 2009L, 2010L, 2010L, 2010L,
2010L, 2011L, 2011L, 2011L, 2011L, 2011L, 2011L, 2011L, 2011L,
2012L, 2012L, 2012L, 2012L, 2013L, 2013L, 2013L, 2013L, 2013L,
2013L, 2013L, 2013L, 2014L, 2014L, 2014L, 2014L, 2014L, 2014L,
2014L, 2015L, 2015L), brown = c(92.9880228989228, 99.8905283406938,
99.5058162975032, 94.9239590983125, 58.0177821517937, 100,
99.9363246171939, 99.6949144206189, 99.776008487762, 97.8115521830828,
88.8674930167577, 99.2133297358188, 99.0995497560706, 99.9554799385939,
99.9888060652806, 98.6284282074288, 99.8617789945938, 99.9047759241436,
99.3622415022697, 99.8356396793778, 94.7182644058803, 99.6301660901836,
99.5170197381053, 99.3242178487055, 99.7674595890857, 97.5165241885194,
95.0338461668053, 99.4646761784891, 96.0330678347186, 99.9070020058111,
99.8504199312282, 99.9117020855413, 99.4132036522814, 98.2738944287577,
98.9242944222883, 99.949312643864, 99.5882261676724, 99.0857077009927,
99.3119586615885, 99.3580652345492, 99.6030825586065, 99.6176835050399,
99.8853263148806, 99.044471611608, 98.1468236537785, 99.8266504050154,
99.5254510814361, 99.896571796076, 99.9981313037722, 99.7447727759311
), chloro = c(0.576709536591652, NA, NA, 0.359420427914885,
35.1068966618305, NA, NA, 0.0158711468553466, NA, 0.256926052382457,
NA, 0.295865308221652, NA, NA, NA, 0.101761372209828, NA,
NA, NA, 0.0841654034780666, 5.28173559411972, NA, NA, NA,
NA, NA, 0.234085515093488, NA, 0.371470100715327, NA, NA,
NA, NA, NA, 0.0289997259999156, NA, 0.0078462884581209, 0.0537313344424304,
0.0572916650657928, 0.0197761487236812, NA, 0.0615811675823147,
NA, NA, 0.129171135017873, NA, NA, 0.00978738373472718, 0.00186869622778042,
NA), crypto = c(3.50350960336206, 0.109471659306231, 0.494183702496829,
3.36879466627627, 1.12895212402776, NA, 0.063675382806074,
0.289214432525736, 0.223991512237965, 1.93152176453475, 11.1325069832423,
0.490804955959565, 0.900450243929378, 0.0445200614061302,
0.0111939347194203, 1.2603071236382, 0.138221005406158, 0.0952240758564129,
0.637758497730338, 0.0801949171441453, NA, 0.369833909816428,
0.482980261894722, 0.675782151294491, 0.232540410914335,
2.48347581148056, 2.81183544405612, 0.432849873269954, 0.70625172721713,
0.0929979941889152, 0.149580068771827, 0.0882979144587052,
NA, 1.72610557124229, 1.04670585171183, 0.0506873561359592,
0.403927543869468, 0.860560964564873, 0.630749673345692,
0.622158616727086, 0.396917441393508, 0.320735327377743,
0.114673685119401, 0.955528388392047, 1.72400521120359, 0.17334959498459,
0.474548918563918, 0.0936408201893021, NA, 0.255227224068911
), cyano = c(2.93175796112351, NA, NA, 1.34782580749631,
5.74636906234805, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
0.00950329672317413, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, 1.92023287404511, 0.102473948240928, 2.88921033734898,
NA, NA, NA, 0.58679634771863, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA), ENS = c(14, 22,
17, 18, 13, 21, 30, 24, 27, 32, 20, 19, 24, 17, 22, 27, 22,
10, 19, 26, 14, 10, 17, 11, 17, 21, 24, 24, 16, 14, 19, 19,
23, 11, 14, 15, 17, 17, 29, 31, 29, 21, 27, 16, 19, 22, 30,
33, 16, 17), SPM = c(4.56434819146784, NA, NA, 3.80666248977032,
3.71357206670431, NA, NA, NA, NA, NA, NA, NA, NA, 3.85014760171006,
NA, NA, 3.80666248977032, 4.20469261939097, NA, NA, 4.27666611901606,
NA, 4.40671924726425, NA, NA, 4.4188406077966, NA, 3.91202300542815,
2.98568193770049, 4.60517018598809, 3.89182029811063, 3.76120011569356,
3.91202300542815, 4.60517018598809, 4.95350040939126, 4.40671924726425,
4.03254007797498, NA, NA, 4.37902212565358, 4.50501830403765,
4.70048036579242, 4.98825334320313, 4.58149205863351, 5.01495926557631,
4.93835129851109, 4.98251013037041, 4.83675798408496, 4.73083320398375,
5.17076804560106), color = c("#FFF5F0", "#FFF5F0", "#FFF5F0",
"#FFF5F0", "#FFF5F0", "#FFF5F0", "#FFF5F0", "#FFF5F0", "#FFF5F0",
"#FFF5F0", "#FFF5F0", "#FFF5F0", "#FFF5F0", "#FFF5F0", "#FFF5F0",
"#FFF5F0", "#FFF5F0", "#FFF5F0", "#FFF5F0", "#FFF5F0", "#FFF5F0",
"#FFF5F0", "#FFF5F0", "#FFF5F0", "#FFF5F0", "#FFF5F0", "#FFF5F0",
"#FFF5F0", "#FFF5F0", "#FFF5F0", "#FFF5F0", "#FFF5F0", "#FFF5F0",
"#FFF5F0", "#FFF5F0", "#FFF5F0", "#FFF5F0", "#FFF5F0", "#FFF5F0",
"#FFF5F0", "#FFF5F0", "#FFF5F0", "#FFF5F0", "#FFF5F0", "#FFF5F0",
"#FFF5F0", "#FFF5F0", "#FFF5F0", "#FFF5F0", "#FFF5F0")), row.names = c(NA,
50L), class = "data.frame")