r@i@1290 m@iii@g oii @im@com
2019-Jun-06 15:49 UTC
[R] Plotting more than one regression line in ggplot
Hi Rui, Yes, you are right. It should be this, but I tried with only 3 colors, as you suggested: ggplot(subset(NewestdataUltra, L1 != 'onepctCO2MEDIAN'), aes(x, value, colour = L1)) + geom_point() + scale_color_manual(values =c("green", "blue" "red")) + geom_smooth(method = lm, se=FALSE) I still end up with the same error, however, when I specify only 3 colors. Why could this be? -----Original Message----- From: Rui Barradas <ruipbarradas at sapo.pt> To: rain1290 <rain1290 at aim.com>; r-help <r-help at R-project.org> Sent: Thu, Jun 6, 2019 11:18 am Subject: Re: [R] Plotting more than one regression line in ggplot Hello, 1) In the text you say your dataset is named NewestdataUltra but in the ggplot instruction it's Newestdata. One of these is wrong. 2) Is it onepctCO2MEDIAN or RCPonepctCO2MEDIAN? 3) You are filtering out the value in point ) above. So you only plot 3 regression lines, you don't need 4 colors. Hope this helps, Rui Barradas ?s 15:35 de 06/06/19, rain1290 at aim.com escreveu:> Hi Rui (and everyone), > > > Thank you for this! Yes, this did work fine, as I can see my scatter > plots and regression lines on the same plot, along with the appropriate > coloring scheme! :) > > Just one last question concerning this - I melted other dataframes into > my new "NewestdataUltra". I now have 4 objects listed in there in this > order (starting from the top of the list): "onepctCO2MEDIAN", > "RCP4.5MEDIAN", RCP8.5MEDIAN", and "HistoricalMEDIAN". I tried plotting > colored scattered plots and regression lines for these in this manner: > > ggplot(subset(Newestdata, L1 != 'RCPonepctCO2MEDIAN'), aes(x, value, > colour = L1)) + geom_point() + scale_color_manual(values =c("green", > "blue" "red", "black")) + geom_smooth(method = lm, se=FALSE) > > However, I received this error: > > Error: unexpected string constant in "ggplot(subset(NewestdataUltra, L1 > != 'RCPonepctCO2MEDIAN'), aes(x, value, colour = L1)) + geom_point() + > scale_color_manual(values =c("green", "blue" "red"" > > **//___^ > > Why would this error appear?? I think that I assigned the colors > correctly to each of the four objects in question, so why would this occur? > > Thank you, once again! > > -----Original Message----- > From: Rui Barradas <ruipbarradas at sapo.pt> > To: rain1290 <rain1290 at aim.com>; r-help <r-help at R-project.org> > Sent: Thu, Jun 6, 2019 6:52 am > Subject: Re: [R] Plotting more than one regression line in ggplot > > Hello, > > You are confusing some of the values of L1 with L1 itself. > If you just want two of those values in your plot, "onepctCO2MEDIAN" and > "RCP8.5MEDIAN", you need to subset the data filtering out the rows with > L1 == "RCP4.5MEDIAN". > > And please forget geom_jitter, it is completely inappropriate for the > type of scatter plot you are trying to graph. You jitter when there is > overplotting, not as a general purpose technique. > > Here is one way to do it. > > > ggplot(subset(NewestdataUltra, L1 != 'RCP4.5MEDIAN'), >? ? ? ? ? aes(x, value, colour = L1)) + >? ? geom_point() + >? ? scale_color_manual(values = c("green", "red")) + >? ? geom_smooth(method = lm) > > > Hope this helps, > > Rui Barradas > > ?s 22:37 de 05/06/19, rain1290 at aim.com <mailto:rain1290 at aim.com> escreveu: >? > Hi Rui (and everyone), >? > >? > Thank you so much for your response! Much appreciated! >? > >? > What if I wanted I create several regression lines and scatter plots in >? > the same ggplot using a "melted" dataset? I would like to create a >? > scatter plot and regression line for both the objects of >? > "onepctCO2MEDIAN" and "RCP8.5MEDIANThis melted dataset looks like this: >? > >? > >? >? >NewestdataUltra >? > >? > x variable value L1 1 0.000000000 y 0.00000000 onepctCO2MEDIAN 2 >? > 0.006794447 y 4.90024902 onepctCO2MEDIAN 3 0.014288058 y 0.16079999 >? > onepctCO2MEDIAN 4 0.022087920 y 6.63491326 onepctCO2MEDIAN 5 0.030797357 >? > y -1.24295056 onepctCO2MEDIAN 6 0.038451072 y 1.56433744 onepctCO2MEDIAN >? > 7 0.048087904 y -2.26590352 onepctCO2MEDIAN 8 0.058677729 y 2.20700446 >? > onepctCO2MEDIAN 9 0.069261406 y -2.36770013 onepctCO2MEDIAN 10 >? > 0.080524530 y -1.09135062 onepctCO2MEDIAN 11 0.092760246 y 0.40999399 >? > onepctCO2MEDIAN 12 0.103789609 y -0.12597268 onepctCO2MEDIAN 13 >? > 0.116953168 y -2.41382534 onepctCO2MEDIAN 14 0.129253298 y 7.08902570 >? > onepctCO2MEDIAN 15 0.141710050 y -0.75935388 onepctCO2MEDIAN 16 >? > 0.156002052 y 0.04544160 onepctCO2MEDIAN 17 0.170648172 y -1.53496826 >? > onepctCO2MEDIAN 18 0.185318425 y 6.55242014 onepctCO2MEDIAN 19 >? > 0.199463055 y -0.83125628 onepctCO2MEDIAN 20 0.213513337 y -2.50991826 >? > onepctCO2MEDIAN 21 0.228839271 y 0.13659682 onepctCO2MEDIAN 22 >? > 0.246981293 y -1.37198445 onepctCO2MEDIAN 23 0.263012767 y -0.87129883 >? > onepctCO2MEDIAN 24 0.278505564 y 0.66325836 onepctCO2MEDIAN 25 >? > 0.293658361 y 0.79380363 onepctCO2MEDIAN 26 0.310747266 y 3.48806374 >? > onepctCO2MEDIAN 27 0.325990349 y -4.46122081 onepctCO2MEDIAN 28 >? > 0.342517540 y 0.08717340 onepctCO2MEDIAN 29 0.362751633 y -1.41715777 >? > onepctCO2MEDIAN 30 0.380199537 y -0.99565082 onepctCO2MEDIAN 31 >? > 0.394992948 y 0.32155262 onepctCO2MEDIAN 32 0.414373398 y 3.14038657 >? > onepctCO2MEDIAN 33 0.430690214 y -0.73760988 onepctCO2MEDIAN 34 >? > 0.449738145 y -2.48605407 onepctCO2MEDIAN 35 0.470167458 y -3.42358584 >? > onepctCO2MEDIAN 36 0.489019871 y 0.48247475 onepctCO2MEDIAN 37 >? > 0.507242471 y -0.97853863 onepctCO2MEDIAN 38 0.524314284 y 8.53596838 >? > onepctCO2MEDIAN 39 0.543750525 y 5.48447420 onepctCO2MEDIAN 40 >? > 0.564234197 y 3.21493666 onepctCO2MEDIAN 41 0.583679616 y 3.91689160 >? > onepctCO2MEDIAN 42 0.601459444 y 4.49070196 onepctCO2MEDIAN 43 >? > 0.619924664 y 6.54104103 onepctCO2MEDIAN 44 0.639932007 y 4.80686500 >? > onepctCO2MEDIAN 45 0.661347181 y 8.15101701 onepctCO2MEDIAN 46 >? > 0.684117317 y 0.26974132 onepctCO2MEDIAN 47 0.704829752 y -0.18075007 >? > onepctCO2MEDIAN 48 0.725045770 y 9.71812491 onepctCO2MEDIAN 49 >? > 0.745165825 y 1.54064657 onepctCO2MEDIAN 50 0.765016139 y -1.64760409 >? > onepctCO2MEDIAN 51 0.783461511 y 4.80246029 onepctCO2MEDIAN 52 >? > 0.806382924 y 4.04215160 onepctCO2MEDIAN 53 0.829241335 y 9.37565122 >? > onepctCO2MEDIAN 54 0.849924415 y 5.33050497 onepctCO2MEDIAN 55 >? > 0.871352434 y 7.54458026 onepctCO2MEDIAN 56 0.893632233 y 6.46795471 >? > onepctCO2MEDIAN 57 0.916052133 y 2.80960651 onepctCO2MEDIAN 58 >? > 0.938579470 y 5.39216613 onepctCO2MEDIAN 59 0.959907651 y 7.20436888 >? > onepctCO2MEDIAN 60 0.981643587 y 3.33508065 onepctCO2MEDIAN 61 >? > 1.004116774 y 8.86907070 onepctCO2MEDIAN 62 1.028363466 y 1.78612989 >? > onepctCO2MEDIAN 63 1.054009140 y 6.25550382 onepctCO2MEDIAN 64 >? > 1.072440803 y 7.60792365 onepctCO2MEDIAN 65 1.094457805 y 7.68714831 >? > onepctCO2MEDIAN 66 1.123176277 y 4.77877639 onepctCO2MEDIAN 67 >? > 1.149430871 y 12.71105018 onepctCO2MEDIAN 68 1.170912921 y -0.71562844 >? > onepctCO2MEDIAN 69 1.196743071 y 1.64908992 onepctCO2MEDIAN 70 >? > 1.218625903 y 3.03630241 onepctCO2MEDIAN 71 1.241868377 y 4.29747688 >? > onepctCO2MEDIAN 72 1.267941594 y 1.95437781 onepctCO2MEDIAN 73 >? > 1.290708780 y 3.99869637 onepctCO2MEDIAN 74 1.313222289 y 4.51794725 >? > onepctCO2MEDIAN 75 1.339045882 y 0.93379048 onepctCO2MEDIAN 76 >? > 1.362803459 y 3.30507700 onepctCO2MEDIAN 77 1.384450197 y 3.54229702 >? > onepctCO2MEDIAN 78 1.409720302 y 5.99736597 onepctCO2MEDIAN 79 >? > 1.435851157 y 0.50818686 onepctCO2MEDIAN 80 1.455592215 y 7.96616301 >? > onepctCO2MEDIAN 81 1.479495347 y 9.94604963 onepctCO2MEDIAN 82 >? > 1.506051958 y 3.79083717 onepctCO2MEDIAN 83 1.525728464 y 2.57358469 >? > onepctCO2MEDIAN 84 1.549362063 y 10.14049742 onepctCO2MEDIAN 85 >? > 1.573440671 y 13.74083036 onepctCO2MEDIAN 86 1.600278735 y 0.93357712 >? > onepctCO2MEDIAN 87 1.623879492 y 9.75887417 onepctCO2MEDIAN 88 >? > 1.650029302 y 1.27693947 onepctCO2MEDIAN 89 1.672362328 y 13.49709060 >? > onepctCO2MEDIAN 90 1.700221121 y 10.20875018 onepctCO2MEDIAN 91 >? > 1.724793375 y 1.68112753 onepctCO2MEDIAN 92 1.751070559 y 6.11789915 >? > onepctCO2MEDIAN 93 1.778022110 y -0.15676262 onepctCO2MEDIAN 94 >? > 1.803022087 y 3.82374792 onepctCO2MEDIAN 95 1.830668867 y 4.43314679 >? > onepctCO2MEDIAN 96 1.855736911 y 5.97907067 onepctCO2MEDIAN 97 >? > 1.882615030 y 11.31043325 onepctCO2MEDIAN 98 1.909218490 y 8.21426074 >? > onepctCO2MEDIAN 99 1.938130021 y 15.32096736 onepctCO2MEDIAN 100 >? > 1.963727593 y 5.81782169 onepctCO2MEDIAN 101 1.993271947 y 9.60049074 >? > onepctCO2MEDIAN 102 2.022548139 y 3.40636456 onepctCO2MEDIAN 103 >? > 2.050679922 y 4.73750104 onepctCO2MEDIAN 104 2.078064442 y 3.01330195 >? > onepctCO2MEDIAN 105 2.104113460 y 5.56595225 onepctCO2MEDIAN 106 >? > 2.133597612 y 12.03463325 onepctCO2MEDIAN 107 2.164026260 y -0.40283200 >? > onepctCO2MEDIAN 108 2.194852829 y 10.59967795 onepctCO2MEDIAN 109 >? > 2.224257946 y 5.44795837 onepctCO2MEDIAN 110 2.252194643 y 4.70523736 >? > onepctCO2MEDIAN 111 2.277335048 y 14.09620189 onepctCO2MEDIAN 112 >? > 2.304058313 y 5.71490162 onepctCO2MEDIAN 113 2.330930233 y 3.77800721 >? > onepctCO2MEDIAN 114 2.357022762 y 4.41206201 onepctCO2MEDIAN 115 >? > 2.386489272 y 4.18660848 onepctCO2MEDIAN 116 2.417503953 y 6.90788020 >? > onepctCO2MEDIAN 117 2.448524356 y 2.78257393 onepctCO2MEDIAN 118 >? > 2.478698969 y 7.61717857 onepctCO2MEDIAN 119 2.510175705 y 10.24106026 >? > onepctCO2MEDIAN 120 2.539697886 y 8.18207107 onepctCO2MEDIAN 121 >? > 2.567915559 y 4.82754944 onepctCO2MEDIAN 122 2.597463250 y 19.16248829 >? > onepctCO2MEDIAN 123 2.627518773 y 16.06771094 onepctCO2MEDIAN 124 >? > 2.658759236 y 12.58970807 onepctCO2MEDIAN 125 2.692401528 y 9.29079880 >? > onepctCO2MEDIAN 126 2.721903205 y 7.42625020 onepctCO2MEDIAN 127 >? > 2.753021359 y 9.39025180 onepctCO2MEDIAN 128 2.786313415 y 12.61935503 >? > onepctCO2MEDIAN 129 2.819564104 y 11.11210397 onepctCO2MEDIAN 130 >? > 2.850823164 y 15.79070997 onepctCO2MEDIAN 131 2.880394101 y 10.74252868 >? > onepctCO2MEDIAN 132 2.911391258 y 7.79714300 onepctCO2MEDIAN 133 >? > 2.942965150 y 8.80608578 onepctCO2MEDIAN 134 2.974468350 y 17.56062663 >? > onepctCO2MEDIAN 135 3.008983612 y 17.30886049 onepctCO2MEDIAN 136 >? > 3.040015221 y 13.45005435 onepctCO2MEDIAN 137 3.072668672 y 14.63778842 >? > onepctCO2MEDIAN 138 3.105982423 y 8.07985518 onepctCO2MEDIAN 139 >? > 0.467429527 y -1.55704023 RCP4.5MEDIAN 140 0.478266196 y -3.19367515 >? > RCP4.5MEDIAN 141 0.489205229 y -2.44452679 RCP4.5MEDIAN 142 0.500039143 >? > y 0.87504367 RCP4.5MEDIAN 143 0.511021115 y -0.39185002 RCP4.5MEDIAN 144 >? > 0.519874968 y -4.18935168 RCP4.5MEDIAN 145 0.528508358 y -3.64179524 >? > RCP4.5MEDIAN 146 0.537377594 y -2.58167128 RCP4.5MEDIAN 147 0.546194211 >? > y 2.20583694 RCP4.5MEDIAN 148 0.554720591 y -8.57764597 RCP4.5MEDIAN 149 >? > 0.563289814 y 2.88442536 RCP4.5MEDIAN 150 0.572032790 y -3.90829882 >? > RCP4.5MEDIAN 151 0.580939066 y -3.39269048 RCP4.5MEDIAN 152 0.590921065 >? > y -4.60849867 RCP4.5MEDIAN 153 0.601575326 y -1.62572657 RCP4.5MEDIAN >? > 154 0.612425555 y 1.14198465 RCP4.5MEDIAN 155 0.623773319 y -3.38454122 >? > RCP4.5MEDIAN 156 0.635363359 y 2.43414265 RCP4.5MEDIAN 157 0.646722666 y >? > 3.30007615 RCP4.5MEDIAN 158 0.658285673 y -0.79555442 RCP4.5MEDIAN 159 >? > 0.670250852 y -2.05220500 RCP4.5MEDIAN 160 0.681702690 y -5.56808946 >? > RCP4.5MEDIAN 161 0.693531145 y 2.24168605 RCP4.5MEDIAN 162 0.706016061 y >? > -4.83673351 RCP4.5MEDIAN 163 0.718231249 y 0.40086819 RCP4.5MEDIAN 164 >? > 0.730190911 y -1.98026992 RCP4.5MEDIAN 165 0.741269845 y 0.39963115 >? > RCP4.5MEDIAN 166 0.751000321 y -0.83241777 RCP4.5MEDIAN 167 0.760886972 >? > y -1.66101404 RCP4.5MEDIAN 168 0.771137164 y -1.05452982 RCP4.5MEDIAN >? > 169 0.781856383 y -1.18338156 RCP4.5MEDIAN 170 0.792607542 y 0.22722653 >? > RCP4.5MEDIAN 171 0.803724128 y -1.90642564 RCP4.5MEDIAN 172 0.815066246 >? > y 0.75010550 RCP4.5MEDIAN 173 0.826027437 y -1.31108646 RCP4.5MEDIAN 174 >? > 0.836766732 y 1.05961515 RCP4.5MEDIAN 175 0.847553312 y -2.06588010 >? > RCP4.5MEDIAN 176 0.858331452 y 8.53403315 RCP4.5MEDIAN 177 0.869154422 y >? > 0.09979751 RCP4.5MEDIAN 178 0.879572539 y -2.50854353 RCP4.5MEDIAN 179 >? > 0.889426601 y 5.29550783 RCP4.5MEDIAN 180 0.899009805 y 2.02909481 >? > RCP4.5MEDIAN 181 0.908289566 y 2.66922982 RCP4.5MEDIAN 182 0.917284978 y >? > -4.17757196 RCP4.5MEDIAN 183 0.926128960 y 3.40202916 RCP4.5MEDIAN 184 >? > 0.934752874 y -1.92292218 RCP4.5MEDIAN 185 0.943010943 y 6.36969150 >? > RCP4.5MEDIAN 186 0.950999217 y 1.86490308 RCP4.5MEDIAN 187 0.958795701 y >? > 8.32126161 RCP4.5MEDIAN 188 0.966310396 y 10.15048356 RCP4.5MEDIAN 189 >? > 0.973635493 y 6.68925964 RCP4.5MEDIAN 190 0.980834088 y -1.01615369 >? > RCP4.5MEDIAN 191 0.987694790 y 0.20892853 RCP4.5MEDIAN 192 0.994548581 y >? > -1.52787222 RCP4.5MEDIAN 193 1.001274595 y -0.72374597 RCP4.5MEDIAN 194 >? > 1.007810612 y 2.26062309 RCP4.5MEDIAN 195 1.014270389 y -2.40270340 >? > RCP4.5MEDIAN 196 1.022719711 y -1.94548262 RCP4.5MEDIAN 197 1.032070810 >? > y -1.13053235 RCP4.5MEDIAN 198 1.041118812 y 0.56107969 RCP4.5MEDIAN 199 >? > 1.050189571 y 3.27941835 RCP4.5MEDIAN 200 1.059380475 y 3.01333588 >? > RCP4.5MEDIAN 201 1.067877585 y 4.87457336 RCP4.5MEDIAN 202 1.076078766 y >? > 1.02457895 RCP4.5MEDIAN 203 1.084707357 y 4.49174869 RCP4.5MEDIAN 204 >? > 1.093223180 y 8.24629303 RCP4.5MEDIAN 205 1.101414382 y -0.03364132 >? > RCP4.5MEDIAN 206 1.108886304 y 9.12509848 RCP4.5MEDIAN 207 1.115482896 y >? > 1.74254621 RCP4.5MEDIAN 208 1.121856558 y 2.27004536 RCP4.5MEDIAN 209 >? > 1.127809421 y -0.65627179 RCP4.5MEDIAN 210 1.133265961 y 12.02566969 >? > RCP4.5MEDIAN 211 1.138549712 y -1.04260843 RCP4.5MEDIAN 212 1.143910237 >? > y -6.47611327 RCP4.5MEDIAN 213 1.149437787 y 8.88410567 RCP4.5MEDIAN 214 >? > 1.154488347 y -4.24916247 RCP4.5MEDIAN 215 1.159872903 y 7.90741918 >? > RCP4.5MEDIAN 216 1.165477487 y -3.91386711 RCP4.5MEDIAN 217 1.171103424 >? > y 1.02370701 RCP4.5MEDIAN 218 1.177498256 y -3.71206616 RCP4.5MEDIAN 219 >? > 1.184003888 y -1.05694182 RCP4.5MEDIAN 220 1.190395856 y 1.10501459 >? > RCP4.5MEDIAN 221 1.197284280 y 2.67668639 RCP4.5MEDIAN 222 1.204590551 y >? > 2.21693031 RCP4.5MEDIAN 223 1.210807614 y 2.90252830 RCP4.5MEDIAN 224 >? > 1.216470664 y 2.75093766 RCP4.5MEDIAN 225 1.221914148 y -0.73815245 >? > RCP4.5MEDIAN 226 1.227580480 y 3.58554626 RCP4.5MEDIAN 227 1.233317788 y >? > 10.89961658 RCP4.5MEDIAN 228 1.238093406 y 3.23374387 RCP4.5MEDIAN 229 >? > 0.466622908 y -1.92366466 RCP8.5MEDIAN 230 0.474211509 y 4.09292949 >? > RCP8.5MEDIAN 231 0.480383051 y -0.84736312 RCP8.5MEDIAN 232 0.486304903 >? > y -0.80597889 RCP8.5MEDIAN 233 0.492151615 y -0.50244413 RCP8.5MEDIAN >? > 234 0.499312643 y 3.07785701 RCP8.5MEDIAN 235 0.508859905 y -6.15175322 >? > RCP8.5MEDIAN 236 0.518758845 y -0.51590144 RCP8.5MEDIAN 237 0.528675758 >? > y 3.33135956 RCP8.5MEDIAN 238 0.538928423 y 2.62280891 RCP8.5MEDIAN 239 >? > 0.549621221 y -6.90096009 RCP8.5MEDIAN 240 0.560062840 y -3.45706029 >? > RCP8.5MEDIAN 241 0.570860791 y 1.36192518 RCP8.5MEDIAN 242 0.581923368 y >? > 0.34822359 RCP8.5MEDIAN 243 0.592628298 y 3.06882935 RCP8.5MEDIAN 244 >? > 0.604230648 y -3.56142825 RCP8.5MEDIAN 245 0.615975167 y 10.35932554 >? > RCP8.5MEDIAN 246 0.627448279 y 10.21751629 RCP8.5MEDIAN 247 0.639401050 >? > y 3.31040335 RCP8.5MEDIAN 248 0.651949591 y -0.53558775 RCP8.5MEDIAN 249 >? > 0.664634427 y 2.66081860 RCP8.5MEDIAN 250 0.677343552 y 3.21379656 >? > RCP8.5MEDIAN Maybe something like this? >? > >? > lusher<-ggplot(NewestdataULTRA) + >? > geom_jitter(aes(x,value,onepctCO2MEDIAN=L1), colour="green") + >? > geom_smooth(aes(x, value, onepctCO2MEDIAN=L1), method=lm) + >? > geom_jitter(aes(x, value, RCP8.5MEDIAN=L1), colour="red")**//___^ >? > **//___^ >? > I receive this warning, however: >? > >? > Warning:Ignoring unknown aesthetics: onepctCO2MEDIAN Warning:Ignoring >? > unknown aesthetics: onepctCO2MEDIAN >? > >? > **//___^ >? > Perhaps I am not assigning the columns properly? Essentially, I just >? > want create two scatter plots and two regression lines for these two >? > objects. >? > >? > Once again, any assistance would be greatly appreciated! >? > >? > -----Original Message----- >? > From: Rui Barradas <ruipbarradas at sapo.pt <mailto:ruipbarradas at sapo.pt>> >? > To: rain1290 <rain1290 at aim.com <mailto:rain1290 at aim.com>>; r-help > <r-help at R-project.org <mailto:r-help at R-project.org>>; >? > r-sig-geo <r-sig-geo at r-project.org <mailto:r-sig-geo at r-project.org>> >? > Sent: Wed, Jun 5, 2019 10:52 am >? > Subject: Re: [R] Plotting more than one regression line in ggplot >? > >? > Hello, >? > >? > This is pretty basic ggplot. >? > >? > >? > lm1 <- ggplot(onepctCO2MEDIAN, aes(x, y)) + >? >? ? geom_point(colour = 'blue') + >? >? ? geom_smooth(method = 'lm') >? > >? > lm1 >? > >? > >? > If you want to combine several datasets, you will have to have a >? > variable telling which dataset is which. In the example below, this is >? > column 'id'. >? > >? > >? > onepctCO2MEDIAN2 <- onepctCO2MEDIAN >? > onepctCO2MEDIAN2$y <- jitter(onepctCO2MEDIAN2$y) + 2 >? > onepctCO2MEDIAN$id <- 1 >? > onepctCO2MEDIAN2$id <- 2 >? > df2 <- rbind(onepctCO2MEDIAN, onepctCO2MEDIAN2) >? > >? > ggplot(df2, aes(x, y, group = id, colour = factor(id))) + >? >? ? geom_point() + >? >? ? geom_smooth(method = 'lm') >? > >? > >? > Hope this helps, >? > >? > Rui Barradas >? > >? > ?s 15:21 de 05/06/19, rain1290--- via R-help escreveu: >? >? > I am trying to plot, using ggplot, a series of scatter plots with >? > regression lines for several datasets. I started with the following >? > dataset, "onepectCO2MEDIAN". The data for this dataset is as follows: >? >? >? ??? onepctCO2MEDIAN >? >? >? ??????????????????? x????????? y >? >? >? ??? layer.1?? 0.000000000? 0.0000000 >? >? >? ??? layer.2?? 0.006794447? 4.9002490 >? >? >? ??? layer.3?? 0.014288058? 0.1608000 >? >? >? ??? layer.4?? 0.022087920? 6.6349133 >? >? >? ??? layer.5?? 0.030797357 -1.2429506 >? >? >? ??? layer.6?? 0.038451072? 1.5643374 >? >? >? ??? layer.7?? 0.048087904 -2.2659035 >? >? >? ??? layer.8?? 0.058677729? 2.2070045 >? >? >? ??? layer.9?? 0.069261406 -2.3677001 >? >? >? ??? layer.10? 0.080524530 -1.0913506 >? >? >? ??? layer.11? 0.092760246? 0.4099940 >? >? >? ??? layer.12? 0.103789609 -0.1259727 >? >? >? ??? layer.13? 0.116953168 -2.4138253 >? >? >? ??? layer.14? 0.129253298? 7.0890257 >? >? >? ??? layer.15? 0.141710050 -0.7593539 >? >? >? ??? layer.16? 0.156002052? 0.0454416 >? >? >? ??? layer.17? 0.170648172 -1.5349683 >? >? >? ??? layer.18? 0.185318425? 6.5524201 >? >? >? ??? layer.19? 0.199463055 -0.8312563 >? >? >? ??? layer.20? 0.213513337 -2.5099183 >? >? >? ??? layer.21? 0.228839271? 0.1365968 >? >? >? ??? layer.22? 0.246981293 -1.3719845 >? >? >? ??? layer.23? 0.263012767 -0.8712988 >? >? >? ??? layer.24? 0.278505564? 0.6632584 >? >? >? ??? layer.25? 0.293658361? 0.7938036 >? >? >? ??? layer.26? 0.310747266? 3.4880637 >? >? >? ??? layer.27? 0.325990349 -4.4612208 >? >? >? ??? layer.28? 0.342517540? 0.0871734 >? >? >? ??? layer.29? 0.362751633 -1.4171578 >? >? >? ??? layer.30? 0.380199537 -0.9956508 >? >? >? ??? layer.31? 0.394992948? 0.3215526 >? >? >? ??? layer.32? 0.414373398? 3.1403866 >? >? >? ??? layer.33? 0.430690214 -0.7376099 >? >? >? ??? layer.34? 0.449738145 -2.4860541 >? >? >? ??? layer.35? 0.470167458 -3.4235858 >? >? >? ??? layer.36? 0.489019871? 0.4824748 >? >? >? ??? layer.37? 0.507242471 -0.9785386 >? >? >? ??? layer.38? 0.524314284? 8.5359684 >? >? >? ??? layer.39? 0.543750525? 5.4844742 >? >? >? ??? layer.40? 0.564234197? 3.2149367 >? >? >? ??? layer.41? 0.583679616? 3.9168916 >? >? >? ??? layer.42? 0.601459444? 4.4907020 >? >? >? ??? layer.43? 0.619924664? 6.5410410 >? >? >? ??? layer.44? 0.639932007? 4.8068650 >? >? >? ??? layer.45? 0.661347181? 8.1510170 >? >? >? ??? layer.46? 0.684117317? 0.2697413 >? >? >? ??? layer.47? 0.704829752 -0.1807501 >? >? >? ??? layer.48? 0.725045770? 9.7181249 >? >? >? ??? layer.49? 0.745165825? 1.5406466 >? >? >? ??? layer.50? 0.765016139 -1.6476041 >? >? >? ??? layer.51? 0.783461511? 4.8024603 >? >? >? ??? layer.52? 0.806382924? 4.0421516 >? >? >? ??? layer.53? 0.829241335? 9.3756512 >? >? >? ??? layer.54? 0.849924415? 5.3305050 >? >? >? ??? layer.55? 0.871352434? 7.5445803 >? >? >? ??? layer.56? 0.893632233? 6.4679547 >? >? >? ??? layer.57? 0.916052133? 2.8096065 >? >? >? ??? layer.58? 0.938579470? 5.3921661 >? >? >? ??? layer.59? 0.959907651? 7.2043689 >? >? >? ??? layer.60? 0.981643587? 3.3350806 >? >? >? ??? layer.61? 1.004116774? 8.8690707 >? >? >? ??? layer.62? 1.028363466? 1.7861299 >? >? >? ??? layer.63? 1.054009140? 6.2555038 >? >? >? ??? layer.64? 1.072440803? 7.6079236 >? >? >? ??? layer.65? 1.094457805? 7.6871483 >? >? >? ??? layer.66? 1.123176277? 4.7787764 >? >? >? ??? layer.67? 1.149430871 12.7110502 >? >? >? ??? layer.68? 1.170912921 -0.7156284 >? >? >? ??? layer.69? 1.196743071? 1.6490899 >? >? >? ??? layer.70? 1.218625903? 3.0363024 >? >? >? ??? layer.71? 1.241868377? 4.2974769 >? >? >? ??? layer.72? 1.267941594? 1.9543778 >? >? >? ??? layer.73? 1.290708780? 3.9986964 >? >? >? ??? layer.74? 1.313222289? 4.5179472 >? >? >? ??? layer.75? 1.339045882? 0.9337905 >? >? >? ??? layer.76? 1.362803459? 3.3050770 >? >? >? ??? layer.77? 1.384450197? 3.5422970 >? >? >? ??? layer.78? 1.409720302? 5.9973660 >? >? >? ??? layer.79? 1.435851157? 0.5081869 >? >? >? ??? layer.80? 1.455592215? 7.9661630 >? >? >? ??? layer.81? 1.479495347? 9.9460496 >? >? >? ??? layer.82? 1.506051958? 3.7908372 >? >? >? ??? layer.83? 1.525728464? 2.5735847 >? >? >? ??? layer.84? 1.549362063 10.1404974 >? >? >? ??? layer.85? 1.573440671 13.7408304 >? >? >? ??? layer.86? 1.600278735? 0.9335771 >? >? >? ??? layer.87? 1.623879492? 9.7588742 >? >? >? ??? layer.88? 1.650029302? 1.2769395 >? >? >? ??? layer.89? 1.672362328 13.4970906 >? >? >? ??? layer.90? 1.700221121 10.2087502 >? >? >? ??? layer.91? 1.724793375? 1.6811275 >? >? >? ??? layer.92? 1.751070559? 6.1178992 >? >? >? ??? layer.93? 1.778022110 -0.1567626 >? >? >? ??? layer.94? 1.803022087? 3.8237479 >? >? >? ??? layer.95? 1.830668867? 4.4331468 >? >? >? ??? layer.96? 1.855736911? 5.9790707 >? >? >? ??? layer.97? 1.882615030 11.3104333 >? >? >? ??? layer.98? 1.909218490? 8.2142607 >? >? >? ??? layer.99? 1.938130021 15.3209674 >? >? >? ??? layer.100 1.963727593? 5.8178217 >? >? >? ??? layer.101 1.993271947? 9.6004907 >? >? >? ??? layer.102 2.022548139? 3.4063646 >? >? >? ??? layer.103 2.050679922? 4.7375010 >? >? >? ??? layer.104 2.078064442? 3.0133019 >? >? >? ??? layer.105 2.104113460? 5.5659522 >? >? >? ??? layer.106 2.133597612 12.0346333 >? >? >? ??? layer.107 2.164026260 -0.4028320 >? >? >? ??? layer.108 2.194852829 10.5996780 >? >? >? ??? layer.109 2.224257946? 5.4479584 >? >? >? ??? layer.110 2.252194643? 4.7052374 >? >? >? ??? layer.111 2.277335048 14.0962019 >? >? >? ??? layer.112 2.304058313? 5.7149016 >? >? >? ??? layer.113 2.330930233? 3.7780072 >? >? >? ??? layer.114 2.357022762? 4.4120620 >? >? >? ??? layer.115 2.386489272? 4.1866085 >? >? >? ??? layer.116 2.417503953? 6.9078802 >? >? >? ??? layer.117 2.448524356? 2.7825739 >? >? >? ??? layer.118 2.478698969? 7.6171786 >? >? >? ??? layer.119 2.510175705 10.2410603 >? >? >? ??? layer.120 2.539697886? 8.1820711 >? >? >? ??? layer.121 2.567915559? 4.8275494 >? >? >? ??? layer.122 2.597463250 19.1624883 >? >? >? ??? layer.123 2.627518773 16.0677109 >? >? >? ??? layer.124 2.658759236 12.5897081 >? >? >? ??? layer.125 2.692401528? 9.2907988 >? >? >? ??? layer.126 2.721903205? 7.4262502 >? >? >? ??? layer.127 2.753021359? 9.3902518 >? >? >? ??? layer.128 2.786313415 12.6193550 >? >? >? ??? layer.129 2.819564104 11.1121040 >? >? >? ??? layer.130 2.850823164 15.7907100 >? >? >? ??? layer.131 2.880394101 10.7425287 >? >? >? ??? layer.132 2.911391258? 7.7971430 >? >? >? ??? layer.133 2.942965150? 8.8060858 >? >? >? ??? layer.134 2.974468350 17.5606266 >? >? >? ??? layer.135 3.008983612 17.3088605 >? >? >? ??? layer.136 3.040015221 13.4500543 >? >? >? ??? layer.137 3.072668672 14.6377884 >? >? >? ??? layer.138 3.105982423? 8.0798552dput(onepctCO2MEDIAN) >? > dput(onepctCO2MEDIAN) >? >? >? ??? structure(list(x = c(0, 0.00679444684647024, 0.014288058038801, >? >? >? ??? 0.0220879195258021, >? > 0.0307973567396402,0.0384510718286037,0.0480879042297602, >? >? >? ??? 0.0586777292191982, 0.0692614056169987, >? > 0.080524530261755,0.0927602462470531, >? >? >? ??? 0.103789608925581, 0.116953168064356, 0.129253298044205, >? > 0.141710050404072, >? >? >? ??? 0.156002052128315, 0.170648172497749, 0.185318425297737, >? > 0.199463054537773, >? >? >? ??? 0.21351333707571, 0.22883927077055, 0.246981292963028, >? > 0.263012766838074, >? >? >? ??? 0.278505563735962, 0.29365836083889, 0.310747265815735, >? > 0.325990349054337, >? >? >? ??? 0.342517539858818, 0.362751632928848, 0.380199536681175, >? > 0.39499294757843, >? >? >? ??? 0.414373397827148, 0.430690214037895, 0.449738144874573, >? > 0.470167458057404, >? >? >? ??? 0.489019870758057, 0.507242470979691, 0.524314284324646, >? > 0.543750524520874, >? >? >? ??? 0.56423419713974, 0.583679616451263, 0.601459443569183, >? > 0.619924664497375, >? >? >? ??? 0.639932006597519, 0.661347180604935, 0.684117317199707, >? > 0.704829752445221, >? >? >? ??? 0.725045770406723, 0.745165824890137, 0.765016138553619, >? > 0.783461511135101, >? >? >? ??? 0.806382924318314, 0.829241335391998, 0.84992441534996, >? > 0.871352434158325, >? >? >? ??? 0.893632233142853, 0.916052132844925, 0.938579469919205, >? > 0.959907650947571, >? >? >? ??? 0.981643587350845, 1.00411677360535, 1.02836346626282, >? > 1.05400913953781, >? >? >? ??? 1.07244080305099, 1.09445780515671, 1.12317627668381, >? > 1.14943087100983, >? >? >? ??? 1.17091292142868, 1.19674307107925, 1.21862590312958, >? > 1.24186837673187, >? >? >? ??? 1.26794159412384, 1.2907087802887, 1.31322228908539, >? > 1.33904588222504, >? >? >? ??? 1.36280345916748, 1.38445019721985, 1.40972030162811, >? > 1.43585115671158, >? >? >? ??? 1.45559221506119, 1.47949534654617, 1.50605195760727, >? > 1.52572846412659, >? >? >? ??? 1.5493620634079, 1.5734406709671, 1.60027873516083, >? > 1.62387949228287, >? >? >? ??? 1.65002930164337, 1.67236232757568, 1.70022112131119, >? > 1.72479337453842, >? >? >? ??? 1.75107055902481, 1.77802211046219, 1.80302208662033, >? > 1.83066886663437, >? >? >? ??? 1.85573691129684, 1.88261502981186, 1.90921849012375, >? > 1.93813002109528, >? >? >? ??? 1.96372759342194, 1.99327194690704, 2.02254813909531, >? > 2.05067992210388, >? >? >? ??? 2.07806444168091, 2.1041134595871, 2.13359761238098, >? > 2.16402626037598, >? >? >? ??? 2.19485282897949, 2.2242579460144, 2.25219464302063, >? > 2.27733504772186, >? >? >? ??? 2.30405831336975, 2.33093023300171, 2.35702276229858, >? > 2.38648927211761, >? >? >? ??? 2.41750395298004, 2.44852435588837, 2.47869896888733, >? > 2.51017570495605, >? >? >? ??? 2.53969788551331, 2.567915558815, 2.59746325016022, >? > 2.62751877307892, >? >? >? ??? 2.65875923633575, 2.69240152835846, 2.72190320491791, >? > 2.75302135944366, >? >? >? ??? 2.78631341457367, 2.8195641040802, 2.85082316398621, >? > 2.88039410114288, >? >? >? ??? 2.91139125823975, 2.94296514987946, 2.97446835041046, >? > 3.00898361206055, >? >? >? ??? 3.04001522064209, 3.07266867160797, 3.10598242282867), y = c(0, >? >? >? ??? 4.90024901723162, 0.160799993152722, 6.63491326258641, >? > -1.24295055804536, >? >? >? ??? 1.56433744259162, -2.26590352245208, 2.20700446463354, >? > -2.36770012911069, >? >? >? ??? -1.09135061899174, 0.409993989292701, -0.125972681525582, >? > -2.41382533818026, >? >? >? ??? 7.08902570153028, -0.759353880417294, 0.0454415959640926, >? > -1.53496826259972, >? >? >? ??? 6.55242014096194, -0.831256280861552, -2.50991825629084, >? > 0.136596820654013, >? >? >? ??? -1.37198445498419, -0.871298832596736, 0.663258363762466, >? > 0.793803634291308, >? >? >? ??? 3.48806373666998, -4.46122081238949, 0.0871733966938564, >? > -1.41715777257774, >? >? >? ??? -0.995650815648318, 0.32155262317503, 3.14038657369241, >? > -0.737609879885404, >? >? >? ??? -2.48605406511292, -3.423585843908, 0.482474753780281, >? > -0.978538630093809, >? >? >? ??? 8.53596837794201, 5.48447420320695, 3.21493665820644, >? > 3.91689160157513, >? >? >? ??? 4.49070195980797, 6.54104103157039, 4.80686500146557, >? > 8.15101701282067, >? >? >? ??? 0.26974132191657, -0.180750068063062, 9.71812491230244, >? > 1.54064657400204, >? >? >? ??? -1.64760408795688, 4.80246028991894, 4.04215159914344, >? > 9.37565121768513, >? >? >? ??? 5.33050496938428, 7.54458026088508, 6.46795470819342, >? > 2.80960651433971, >? >? >? ??? 5.39216613235986, 7.20436888038562, 3.3350806460997, >? > 8.86907069895943, >? >? >? ??? 1.78612988613659, 6.25550382050395, 7.60792364896564, >? > 7.68714830528144, >? >? >? ??? 4.77877638957615, 12.7110501777314, -0.715628443181046, >? > 1.64908991824022, >? >? >? ??? 3.03630240714679, 4.29747688442346, 1.95437780501881, >? > 3.99869636910933, >? >? >? ??? 4.51794724689848, 0.933790484492299, 3.30507700050003, >? > 3.5422970157433, >? >? >? ??? 5.99736597322524, 0.508186860060022, 7.96616300581067, >? > 9.94604963036295, >? >? >? ??? 3.79083717222623, 2.57358468532258, 10.1404974171776, >? > 13.7408303595752, >? >? >? ??? 0.933577123801399, 9.75887417074129, 1.27693947132921, >? > 13.4970905965787, >? >? >? ??? 10.2087501765735, 1.68112753028756, 6.1178991508927, >? > -0.156762622680077, >? >? >? ??? 3.82374791691426, 4.43314678736265, 5.97907067167507, >? > 11.3104332518482, >? >? >? ??? 8.21426074201525, 15.320967360602, 5.81782169471483, >? > 9.6004907412354, >? >? >? ??? 3.40636455909704, 4.73750103921864, 3.0133019468806, >? > 5.56595224859066, >? >? >? ??? 12.0346332527215, -0.40283199827104, 10.5996779538754, >? > 5.44795836991128, >? >? >? ??? 4.70523736412729, 14.096201892183, 5.71490161813391, >? > 3.77800720810782, >? >? >? ??? 4.41206200639436, 4.18660847858423, 6.90788020044911, >? > 2.78257393345915, >? >? >? ??? 7.61717857379431, 10.2410602647684, 8.18207106836167, >? > 4.82754943871433, >? >? >? ??? 19.1624882857155, 16.0677109398509, 12.589708067017, >? > 9.29079879799404, >? >? >? ??? 7.42625019725314, 9.39025179806185, 12.6193550331438, >? > 11.1121039747257, >? >? >? ??? 15.7907099734986, 10.7425286789233, 7.79714300307344, >? > 8.80608578166101, >? >? >? ??? 17.5606266346039, 17.3088604929222, 13.4500543478523, >? > 14.6377884248645, >? >? >? ??? 8.07985518296064)), class = "data.frame", row.names = > c("layer.1", >? >? >? ??? "layer.2", "layer.3", "layer.4", "layer.5", "layer.6", "layer.7", >? >? >? ??? "layer.8", "layer.9", "layer.10", "layer.11", "layer.12", >? > "layer.13", >? >? >? ??? "layer.14", "layer.15", "layer.16", "layer.17", "layer.18", >? > "layer.19", >? >? >? ??? "layer.20", "layer.21", "layer.22", "layer.23", "layer.24", >? > "layer.25", >? >? >? ??? "layer.26", "layer.27", "layer.28", "layer.29", "layer.30", >? > "layer.31", >? >? >? ??? "layer.32", "layer.33", "layer.34", "layer.35", "layer.36", >? > "layer.37", >? >? >? ??? "layer.38", "layer.39", "layer.40", "layer.41", "layer.42", >? > "layer.43", >? >? >? ??? "layer.44", "layer.45", "layer.46", "layer.47", "layer.48", >? > "layer.49", >? >? >? ??? "layer.50", "layer.51", "layer.52", "layer.53", "layer.54", >? > "layer.55", >? >? >? ??? "layer.56", "layer.57", "layer.58", "layer.59", "layer.60", >? > "layer.61", >? >? >? ??? "layer.62", "layer.63", "layer.64", "layer.65", "layer.66", >? > "layer.67", >? >? >? ??? "layer.68", "layer.69", "layer.70", "layer.71", "layer.72", >? > "layer.73", >? >? >? ??? "layer.74", "layer.75", "layer.76", "layer.77", "layer.78", >? > "layer.79", >? >? >? ??? "layer.80", "layer.81", "layer.82", "layer.83", "layer.84", >? > "layer.85", >? >? >? ??? "layer.86", "layer.87", "layer.88", "layer.89", "layer.90", >? > "layer.91", >? >? >? ??? "layer.92", "layer.93", "layer.94", "layer.95", "layer.96", >? > "layer.97", >? >? >? ??? "layer.98", "layer.99", "layer.100", "layer.101", "layer.102", >? >? >? ??? "layer.103", "layer.104", "layer.105", "layer.106", "layer.107", >? >? >? ??? "layer.108", "layer.109", "layer.110", "layer.111", "layer.112", >? >? >? ??? "layer.113", "layer.114", "layer.115", "layer.116", "layer.117", >? >? >? ??? "layer.118", "layer.119", "layer.120", "layer.121", "layer.122", >? >? >? ??? "layer.123", "layer.124", "layer.125", "layer.126", "layer.127", >? >? >? ??? "layer.128", "layer.129", "layer.130", "layer.131", "layer.132", >? >? >? ??? "layer.133", "layer.134", "layer.135", "layer.136", "layer.137", >? >? >? ??? "layer.138")) >? >? > I started with the following to generate the first regression line >? > and scatter plot:??? lm<-ggplot(onepctCO2MEDIAN) + >? >? >? ??? geom_jitter(aes(RCP1pctCO2cumulativeMedian[1:138], departurea), >? >? >? ??? colour="blue") + > geom_smooth(aes(RCP1pctCO2cumulativeMedian[1:138], >? >? >? ??? departurea), method=lm) >? >? > But I receive this error:? ??Warning message: >? >? >? ??? Computation failed in `stat_smooth()`: >? >? >? ??? 'what' must be a function or character string >? >? > A blue scatter plot is successfully generated, but the problem is >? > that the regression line does not appear, presumably related to the >? > above warning. >? >? > Is there a reason for this? I would appreciate any assistance! >? >? > ??? [[alternative HTML version deleted]] >? > >? >? > >? >? > ______________________________________________ >? >? > R-help at r-project.org <mailto:R-help at r-project.org> mailing list -- > To UNSUBSCRIBE and more, see >? >? > https://stat.ethz.ch/mailman/listinfo/r-help >? >? > PLEASE do read the posting guide >? > http://www.R-project.org/posting-guide.html >? >? > and provide commented, minimal, self-contained, reproducible code. >? > >? >? >[[alternative HTML version deleted]]
Hello, It's impossible to say without seeing the data. What is the return value of df_tmp <- subset(NewestdataUltra, L1 != 'onepctCO2MEDIAN') unique(df_tmp$L1) The number of colors must be the same as length(unique(df_tmp$L1)) Hope this helps, Rui Barradas ?s 16:49 de 06/06/19, rain1290 at aim.com escreveu:> Hi Rui, > > Yes, you are right. It should be this, but I tried with only 3 colors, > as you suggested: > > ggplot(subset(NewestdataUltra, L1 != 'onepctCO2MEDIAN'), aes(x, value, > colour = L1)) + geom_point() + scale_color_manual(values =c("green", > "blue" "red")) + geom_smooth(method = lm, se=FALSE) > > **//___^ > **//___^I still end up with the same error, however, when I specify only > 3 colors. Why could this be? > > > -----Original Message----- > From: Rui Barradas <ruipbarradas at sapo.pt> > To: rain1290 <rain1290 at aim.com>; r-help <r-help at R-project.org> > Sent: Thu, Jun 6, 2019 11:18 am > Subject: Re: [R] Plotting more than one regression line in ggplot > > Hello, > > 1) In the text you say your dataset is named NewestdataUltra but in the > ggplot instruction it's Newestdata. One of these is wrong. > > 2) Is it onepctCO2MEDIAN or RCPonepctCO2MEDIAN? > > 3) You are filtering out the value in point ) above. So you only plot 3 > regression lines, you don't need 4 colors. > > > Hope this helps, > > Rui Barradas > > ?s 15:35 de 06/06/19, rain1290 at aim.com <mailto:rain1290 at aim.com> escreveu: > > Hi Rui (and everyone), > > > > > > Thank you for this! Yes, this did work fine, as I can see my scatter > > plots and regression lines on the same plot, along with the appropriate > > coloring scheme! :) > > > > Just one last question concerning this - I melted other dataframes into > > my new "NewestdataUltra". I now have 4 objects listed in there in this > > order (starting from the top of the list): "onepctCO2MEDIAN", > > "RCP4.5MEDIAN", RCP8.5MEDIAN", and "HistoricalMEDIAN". I tried plotting > > colored scattered plots and regression lines for these in this manner: > > > > ggplot(subset(Newestdata, L1 != 'RCPonepctCO2MEDIAN'), aes(x, value, > > colour = L1)) + geom_point() + scale_color_manual(values =c("green", > > "blue" "red", "black")) + geom_smooth(method = lm, se=FALSE) > > > > However, I received this error: > > > > Error: unexpected string constant in "ggplot(subset(NewestdataUltra, L1 > > != 'RCPonepctCO2MEDIAN'), aes(x, value, colour = L1)) + geom_point() + > > scale_color_manual(values =c("green", "blue" "red"" > > > > **//___^ > > > > Why would this error appear?? I think that I assigned the colors > > correctly to each of the four objects in question, so why would this > occur? > > > > Thank you, once again! > > > > -----Original Message----- > > From: Rui Barradas <ruipbarradas at sapo.pt <mailto:ruipbarradas at sapo.pt>> > > To: rain1290 <rain1290 at aim.com <mailto:rain1290 at aim.com>>; r-help > <r-help at R-project.org <mailto:r-help at R-project.org>> > > Sent: Thu, Jun 6, 2019 6:52 am > > Subject: Re: [R] Plotting more than one regression line in ggplot > > > > Hello, > > > > You are confusing some of the values of L1 with L1 itself. > > If you just want two of those values in your plot, "onepctCO2MEDIAN" and > > "RCP8.5MEDIAN", you need to subset the data filtering out the rows with > > L1 == "RCP4.5MEDIAN". > > > > And please forget geom_jitter, it is completely inappropriate for the > > type of scatter plot you are trying to graph. You jitter when there is > > overplotting, not as a general purpose technique. > > > > Here is one way to do it. > > > > > > ggplot(subset(NewestdataUltra, L1 != 'RCP4.5MEDIAN'), > >? ? ? ? ? aes(x, value, colour = L1)) + > >? ? geom_point() + > >? ? scale_color_manual(values = c("green", "red")) + > >? ? geom_smooth(method = lm) > > > > > > Hope this helps, > > > > Rui Barradas > > > > ?s 22:37 de 05/06/19, rain1290 at aim.com <mailto:rain1290 at aim.com> > <mailto:rain1290 at aim.com <mailto:rain1290 at aim.com>> escreveu: > >? > Hi Rui (and everyone), > >? > > >? > Thank you so much for your response! Much appreciated! > >? > > >? > What if I wanted I create several regression lines and scatter > plots in > >? > the same ggplot using a "melted" dataset? I would like to create a > >? > scatter plot and regression line for both the objects of > >? > "onepctCO2MEDIAN" and "RCP8.5MEDIANThis melted dataset looks like > this: > >? > > >? > > >? >? >NewestdataUltra > >? > > >? > x variable value L1 1 0.000000000 y 0.00000000 onepctCO2MEDIAN 2 > >? > 0.006794447 y 4.90024902 onepctCO2MEDIAN 3 0.014288058 y 0.16079999 > >? > onepctCO2MEDIAN 4 0.022087920 y 6.63491326 onepctCO2MEDIAN 5 > 0.030797357 > >? > y -1.24295056 onepctCO2MEDIAN 6 0.038451072 y 1.56433744 > onepctCO2MEDIAN > >? > 7 0.048087904 y -2.26590352 onepctCO2MEDIAN 8 0.058677729 y 2.20700446 > >? > onepctCO2MEDIAN 9 0.069261406 y -2.36770013 onepctCO2MEDIAN 10 > >? > 0.080524530 y -1.09135062 onepctCO2MEDIAN 11 0.092760246 y 0.40999399 > >? > onepctCO2MEDIAN 12 0.103789609 y -0.12597268 onepctCO2MEDIAN 13 > >? > 0.116953168 y -2.41382534 onepctCO2MEDIAN 14 0.129253298 y 7.08902570 > >? > onepctCO2MEDIAN 15 0.141710050 y -0.75935388 onepctCO2MEDIAN 16 > >? > 0.156002052 y 0.04544160 onepctCO2MEDIAN 17 0.170648172 y -1.53496826 > >? > onepctCO2MEDIAN 18 0.185318425 y 6.55242014 onepctCO2MEDIAN 19 > >? > 0.199463055 y -0.83125628 onepctCO2MEDIAN 20 0.213513337 y -2.50991826 > >? > onepctCO2MEDIAN 21 0.228839271 y 0.13659682 onepctCO2MEDIAN 22 > >? > 0.246981293 y -1.37198445 onepctCO2MEDIAN 23 0.263012767 y -0.87129883 > >? > onepctCO2MEDIAN 24 0.278505564 y 0.66325836 onepctCO2MEDIAN 25 > >? > 0.293658361 y 0.79380363 onepctCO2MEDIAN 26 0.310747266 y 3.48806374 > >? > onepctCO2MEDIAN 27 0.325990349 y -4.46122081 onepctCO2MEDIAN 28 > >? > 0.342517540 y 0.08717340 onepctCO2MEDIAN 29 0.362751633 y -1.41715777 > >? > onepctCO2MEDIAN 30 0.380199537 y -0.99565082 onepctCO2MEDIAN 31 > >? > 0.394992948 y 0.32155262 onepctCO2MEDIAN 32 0.414373398 y 3.14038657 > >? > onepctCO2MEDIAN 33 0.430690214 y -0.73760988 onepctCO2MEDIAN 34 > >? > 0.449738145 y -2.48605407 onepctCO2MEDIAN 35 0.470167458 y -3.42358584 > >? > onepctCO2MEDIAN 36 0.489019871 y 0.48247475 onepctCO2MEDIAN 37 > >? > 0.507242471 y -0.97853863 onepctCO2MEDIAN 38 0.524314284 y 8.53596838 > >? > onepctCO2MEDIAN 39 0.543750525 y 5.48447420 onepctCO2MEDIAN 40 > >? > 0.564234197 y 3.21493666 onepctCO2MEDIAN 41 0.583679616 y 3.91689160 > >? > onepctCO2MEDIAN 42 0.601459444 y 4.49070196 onepctCO2MEDIAN 43 > >? > 0.619924664 y 6.54104103 onepctCO2MEDIAN 44 0.639932007 y 4.80686500 > >? > onepctCO2MEDIAN 45 0.661347181 y 8.15101701 onepctCO2MEDIAN 46 > >? > 0.684117317 y 0.26974132 onepctCO2MEDIAN 47 0.704829752 y -0.18075007 > >? > onepctCO2MEDIAN 48 0.725045770 y 9.71812491 onepctCO2MEDIAN 49 > >? > 0.745165825 y 1.54064657 onepctCO2MEDIAN 50 0.765016139 y -1.64760409 > >? > onepctCO2MEDIAN 51 0.783461511 y 4.80246029 onepctCO2MEDIAN 52 > >? > 0.806382924 y 4.04215160 onepctCO2MEDIAN 53 0.829241335 y 9.37565122 > >? > onepctCO2MEDIAN 54 0.849924415 y 5.33050497 onepctCO2MEDIAN 55 > >? > 0.871352434 y 7.54458026 onepctCO2MEDIAN 56 0.893632233 y 6.46795471 > >? > onepctCO2MEDIAN 57 0.916052133 y 2.80960651 onepctCO2MEDIAN 58 > >? > 0.938579470 y 5.39216613 onepctCO2MEDIAN 59 0.959907651 y 7.20436888 > >? > onepctCO2MEDIAN 60 0.981643587 y 3.33508065 onepctCO2MEDIAN 61 > >? > 1.004116774 y 8.86907070 onepctCO2MEDIAN 62 1.028363466 y 1.78612989 > >? > onepctCO2MEDIAN 63 1.054009140 y 6.25550382 onepctCO2MEDIAN 64 > >? > 1.072440803 y 7.60792365 onepctCO2MEDIAN 65 1.094457805 y 7.68714831 > >? > onepctCO2MEDIAN 66 1.123176277 y 4.77877639 onepctCO2MEDIAN 67 > >? > 1.149430871 y 12.71105018 onepctCO2MEDIAN 68 1.170912921 y -0.71562844 > >? > onepctCO2MEDIAN 69 1.196743071 y 1.64908992 onepctCO2MEDIAN 70 > >? > 1.218625903 y 3.03630241 onepctCO2MEDIAN 71 1.241868377 y 4.29747688 > >? > onepctCO2MEDIAN 72 1.267941594 y 1.95437781 onepctCO2MEDIAN 73 > >? > 1.290708780 y 3.99869637 onepctCO2MEDIAN 74 1.313222289 y 4.51794725 > >? > onepctCO2MEDIAN 75 1.339045882 y 0.93379048 onepctCO2MEDIAN 76 > >? > 1.362803459 y 3.30507700 onepctCO2MEDIAN 77 1.384450197 y 3.54229702 > >? > onepctCO2MEDIAN 78 1.409720302 y 5.99736597 onepctCO2MEDIAN 79 > >? > 1.435851157 y 0.50818686 onepctCO2MEDIAN 80 1.455592215 y 7.96616301 > >? > onepctCO2MEDIAN 81 1.479495347 y 9.94604963 onepctCO2MEDIAN 82 > >? > 1.506051958 y 3.79083717 onepctCO2MEDIAN 83 1.525728464 y 2.57358469 > >? > onepctCO2MEDIAN 84 1.549362063 y 10.14049742 onepctCO2MEDIAN 85 > >? > 1.573440671 y 13.74083036 onepctCO2MEDIAN 86 1.600278735 y 0.93357712 > >? > onepctCO2MEDIAN 87 1.623879492 y 9.75887417 onepctCO2MEDIAN 88 > >? > 1.650029302 y 1.27693947 onepctCO2MEDIAN 89 1.672362328 y 13.49709060 > >? > onepctCO2MEDIAN 90 1.700221121 y 10.20875018 onepctCO2MEDIAN 91 > >? > 1.724793375 y 1.68112753 onepctCO2MEDIAN 92 1.751070559 y 6.11789915 > >? > onepctCO2MEDIAN 93 1.778022110 y -0.15676262 onepctCO2MEDIAN 94 > >? > 1.803022087 y 3.82374792 onepctCO2MEDIAN 95 1.830668867 y 4.43314679 > >? > onepctCO2MEDIAN 96 1.855736911 y 5.97907067 onepctCO2MEDIAN 97 > >? > 1.882615030 y 11.31043325 onepctCO2MEDIAN 98 1.909218490 y 8.21426074 > >? > onepctCO2MEDIAN 99 1.938130021 y 15.32096736 onepctCO2MEDIAN 100 > >? > 1.963727593 y 5.81782169 onepctCO2MEDIAN 101 1.993271947 y 9.60049074 > >? > onepctCO2MEDIAN 102 2.022548139 y 3.40636456 onepctCO2MEDIAN 103 > >? > 2.050679922 y 4.73750104 onepctCO2MEDIAN 104 2.078064442 y 3.01330195 > >? > onepctCO2MEDIAN 105 2.104113460 y 5.56595225 onepctCO2MEDIAN 106 > >? > 2.133597612 y 12.03463325 onepctCO2MEDIAN 107 2.164026260 y > -0.40283200 > >? > onepctCO2MEDIAN 108 2.194852829 y 10.59967795 onepctCO2MEDIAN 109 > >? > 2.224257946 y 5.44795837 onepctCO2MEDIAN 110 2.252194643 y 4.70523736 > >? > onepctCO2MEDIAN 111 2.277335048 y 14.09620189 onepctCO2MEDIAN 112 > >? > 2.304058313 y 5.71490162 onepctCO2MEDIAN 113 2.330930233 y 3.77800721 > >? > onepctCO2MEDIAN 114 2.357022762 y 4.41206201 onepctCO2MEDIAN 115 > >? > 2.386489272 y 4.18660848 onepctCO2MEDIAN 116 2.417503953 y 6.90788020 > >? > onepctCO2MEDIAN 117 2.448524356 y 2.78257393 onepctCO2MEDIAN 118 > >? > 2.478698969 y 7.61717857 onepctCO2MEDIAN 119 2.510175705 y 10.24106026 > >? > onepctCO2MEDIAN 120 2.539697886 y 8.18207107 onepctCO2MEDIAN 121 > >? > 2.567915559 y 4.82754944 onepctCO2MEDIAN 122 2.597463250 y 19.16248829 > >? > onepctCO2MEDIAN 123 2.627518773 y 16.06771094 onepctCO2MEDIAN 124 > >? > 2.658759236 y 12.58970807 onepctCO2MEDIAN 125 2.692401528 y 9.29079880 > >? > onepctCO2MEDIAN 126 2.721903205 y 7.42625020 onepctCO2MEDIAN 127 > >? > 2.753021359 y 9.39025180 onepctCO2MEDIAN 128 2.786313415 y 12.61935503 > >? > onepctCO2MEDIAN 129 2.819564104 y 11.11210397 onepctCO2MEDIAN 130 > >? > 2.850823164 y 15.79070997 onepctCO2MEDIAN 131 2.880394101 y > 10.74252868 > >? > onepctCO2MEDIAN 132 2.911391258 y 7.79714300 onepctCO2MEDIAN 133 > >? > 2.942965150 y 8.80608578 onepctCO2MEDIAN 134 2.974468350 y 17.56062663 > >? > onepctCO2MEDIAN 135 3.008983612 y 17.30886049 onepctCO2MEDIAN 136 > >? > 3.040015221 y 13.45005435 onepctCO2MEDIAN 137 3.072668672 y > 14.63778842 > >? > onepctCO2MEDIAN 138 3.105982423 y 8.07985518 onepctCO2MEDIAN 139 > >? > 0.467429527 y -1.55704023 RCP4.5MEDIAN 140 0.478266196 y -3.19367515 > >? > RCP4.5MEDIAN 141 0.489205229 y -2.44452679 RCP4.5MEDIAN 142 > 0.500039143 > >? > y 0.87504367 RCP4.5MEDIAN 143 0.511021115 y -0.39185002 > RCP4.5MEDIAN 144 > >? > 0.519874968 y -4.18935168 RCP4.5MEDIAN 145 0.528508358 y -3.64179524 > >? > RCP4.5MEDIAN 146 0.537377594 y -2.58167128 RCP4.5MEDIAN 147 > 0.546194211 > >? > y 2.20583694 RCP4.5MEDIAN 148 0.554720591 y -8.57764597 > RCP4.5MEDIAN 149 > >? > 0.563289814 y 2.88442536 RCP4.5MEDIAN 150 0.572032790 y -3.90829882 > >? > RCP4.5MEDIAN 151 0.580939066 y -3.39269048 RCP4.5MEDIAN 152 > 0.590921065 > >? > y -4.60849867 RCP4.5MEDIAN 153 0.601575326 y -1.62572657 RCP4.5MEDIAN > >? > 154 0.612425555 y 1.14198465 RCP4.5MEDIAN 155 0.623773319 y > -3.38454122 > >? > RCP4.5MEDIAN 156 0.635363359 y 2.43414265 RCP4.5MEDIAN 157 > 0.646722666 y > >? > 3.30007615 RCP4.5MEDIAN 158 0.658285673 y -0.79555442 RCP4.5MEDIAN 159 > >? > 0.670250852 y -2.05220500 RCP4.5MEDIAN 160 0.681702690 y -5.56808946 > >? > RCP4.5MEDIAN 161 0.693531145 y 2.24168605 RCP4.5MEDIAN 162 > 0.706016061 y > >? > -4.83673351 RCP4.5MEDIAN 163 0.718231249 y 0.40086819 RCP4.5MEDIAN 164 > >? > 0.730190911 y -1.98026992 RCP4.5MEDIAN 165 0.741269845 y 0.39963115 > >? > RCP4.5MEDIAN 166 0.751000321 y -0.83241777 RCP4.5MEDIAN 167 > 0.760886972 > >? > y -1.66101404 RCP4.5MEDIAN 168 0.771137164 y -1.05452982 RCP4.5MEDIAN > >? > 169 0.781856383 y -1.18338156 RCP4.5MEDIAN 170 0.792607542 y > 0.22722653 > >? > RCP4.5MEDIAN 171 0.803724128 y -1.90642564 RCP4.5MEDIAN 172 > 0.815066246 > >? > y 0.75010550 RCP4.5MEDIAN 173 0.826027437 y -1.31108646 > RCP4.5MEDIAN 174 > >? > 0.836766732 y 1.05961515 RCP4.5MEDIAN 175 0.847553312 y -2.06588010 > >? > RCP4.5MEDIAN 176 0.858331452 y 8.53403315 RCP4.5MEDIAN 177 > 0.869154422 y > >? > 0.09979751 RCP4.5MEDIAN 178 0.879572539 y -2.50854353 RCP4.5MEDIAN 179 > >? > 0.889426601 y 5.29550783 RCP4.5MEDIAN 180 0.899009805 y 2.02909481 > >? > RCP4.5MEDIAN 181 0.908289566 y 2.66922982 RCP4.5MEDIAN 182 > 0.917284978 y > >? > -4.17757196 RCP4.5MEDIAN 183 0.926128960 y 3.40202916 RCP4.5MEDIAN 184 > >? > 0.934752874 y -1.92292218 RCP4.5MEDIAN 185 0.943010943 y 6.36969150 > >? > RCP4.5MEDIAN 186 0.950999217 y 1.86490308 RCP4.5MEDIAN 187 > 0.958795701 y > >? > 8.32126161 RCP4.5MEDIAN 188 0.966310396 y 10.15048356 RCP4.5MEDIAN 189 > >? > 0.973635493 y 6.68925964 RCP4.5MEDIAN 190 0.980834088 y -1.01615369 > >? > RCP4.5MEDIAN 191 0.987694790 y 0.20892853 RCP4.5MEDIAN 192 > 0.994548581 y > >? > -1.52787222 RCP4.5MEDIAN 193 1.001274595 y -0.72374597 > RCP4.5MEDIAN 194 > >? > 1.007810612 y 2.26062309 RCP4.5MEDIAN 195 1.014270389 y -2.40270340 > >? > RCP4.5MEDIAN 196 1.022719711 y -1.94548262 RCP4.5MEDIAN 197 > 1.032070810 > >? > y -1.13053235 RCP4.5MEDIAN 198 1.041118812 y 0.56107969 > RCP4.5MEDIAN 199 > >? > 1.050189571 y 3.27941835 RCP4.5MEDIAN 200 1.059380475 y 3.01333588 > >? > RCP4.5MEDIAN 201 1.067877585 y 4.87457336 RCP4.5MEDIAN 202 > 1.076078766 y > >? > 1.02457895 RCP4.5MEDIAN 203 1.084707357 y 4.49174869 RCP4.5MEDIAN 204 > >? > 1.093223180 y 8.24629303 RCP4.5MEDIAN 205 1.101414382 y -0.03364132 > >? > RCP4.5MEDIAN 206 1.108886304 y 9.12509848 RCP4.5MEDIAN 207 > 1.115482896 y > >? > 1.74254621 RCP4.5MEDIAN 208 1.121856558 y 2.27004536 RCP4.5MEDIAN 209 > >? > 1.127809421 y -0.65627179 RCP4.5MEDIAN 210 1.133265961 y 12.02566969 > >? > RCP4.5MEDIAN 211 1.138549712 y -1.04260843 RCP4.5MEDIAN 212 > 1.143910237 > >? > y -6.47611327 RCP4.5MEDIAN 213 1.149437787 y 8.88410567 > RCP4.5MEDIAN 214 > >? > 1.154488347 y -4.24916247 RCP4.5MEDIAN 215 1.159872903 y 7.90741918 > >? > RCP4.5MEDIAN 216 1.165477487 y -3.91386711 RCP4.5MEDIAN 217 > 1.171103424 > >? > y 1.02370701 RCP4.5MEDIAN 218 1.177498256 y -3.71206616 > RCP4.5MEDIAN 219 > >? > 1.184003888 y -1.05694182 RCP4.5MEDIAN 220 1.190395856 y 1.10501459 > >? > RCP4.5MEDIAN 221 1.197284280 y 2.67668639 RCP4.5MEDIAN 222 > 1.204590551 y > >? > 2.21693031 RCP4.5MEDIAN 223 1.210807614 y 2.90252830 RCP4.5MEDIAN 224 > >? > 1.216470664 y 2.75093766 RCP4.5MEDIAN 225 1.221914148 y -0.73815245 > >? > RCP4.5MEDIAN 226 1.227580480 y 3.58554626 RCP4.5MEDIAN 227 > 1.233317788 y > >? > 10.89961658 RCP4.5MEDIAN 228 1.238093406 y 3.23374387 RCP4.5MEDIAN 229 > >? > 0.466622908 y -1.92366466 RCP8.5MEDIAN 230 0.474211509 y 4.09292949 > >? > RCP8.5MEDIAN 231 0.480383051 y -0.84736312 RCP8.5MEDIAN 232 > 0.486304903 > >? > y -0.80597889 RCP8.5MEDIAN 233 0.492151615 y -0.50244413 RCP8.5MEDIAN > >? > 234 0.499312643 y 3.07785701 RCP8.5MEDIAN 235 0.508859905 y > -6.15175322 > >? > RCP8.5MEDIAN 236 0.518758845 y -0.51590144 RCP8.5MEDIAN 237 > 0.528675758 > >? > y 3.33135956 RCP8.5MEDIAN 238 0.538928423 y 2.62280891 > RCP8.5MEDIAN 239 > >? > 0.549621221 y -6.90096009 RCP8.5MEDIAN 240 0.560062840 y -3.45706029 > >? > RCP8.5MEDIAN 241 0.570860791 y 1.36192518 RCP8.5MEDIAN 242 > 0.581923368 y > >? > 0.34822359 RCP8.5MEDIAN 243 0.592628298 y 3.06882935 RCP8.5MEDIAN 244 > >? > 0.604230648 y -3.56142825 RCP8.5MEDIAN 245 0.615975167 y 10.35932554 > >? > RCP8.5MEDIAN 246 0.627448279 y 10.21751629 RCP8.5MEDIAN 247 > 0.639401050 > >? > y 3.31040335 RCP8.5MEDIAN 248 0.651949591 y -0.53558775 > RCP8.5MEDIAN 249 > >? > 0.664634427 y 2.66081860 RCP8.5MEDIAN 250 0.677343552 y 3.21379656 > >? > RCP8.5MEDIAN Maybe something like this? > >? > > >? > lusher<-ggplot(NewestdataULTRA) + > >? > geom_jitter(aes(x,value,onepctCO2MEDIAN=L1), colour="green") + > >? > geom_smooth(aes(x, value, onepctCO2MEDIAN=L1), method=lm) + > >? > geom_jitter(aes(x, value, RCP8.5MEDIAN=L1), colour="red")**//___^ > >? > **//___^ > >? > I receive this warning, however: > >? > > >? > Warning:Ignoring unknown aesthetics: onepctCO2MEDIAN Warning:Ignoring > >? > unknown aesthetics: onepctCO2MEDIAN > >? > > >? > **//___^ > >? > Perhaps I am not assigning the columns properly? Essentially, I just > >? > want create two scatter plots and two regression lines for these two > >? > objects. > >? > > >? > Once again, any assistance would be greatly appreciated! > >? > > >? > -----Original Message----- > >? > From: Rui Barradas <ruipbarradas at sapo.pt > <mailto:ruipbarradas at sapo.pt> <mailto:ruipbarradas at sapo.pt > <mailto:ruipbarradas at sapo.pt>>> > >? > To: rain1290 <rain1290 at aim.com <mailto:rain1290 at aim.com> > <mailto:rain1290 at aim.com <mailto:rain1290 at aim.com>>>; r-help > > <r-help at R-project.org <mailto:r-help at R-project.org> > <mailto:r-help at R-project.org <mailto:r-help at R-project.org>>>; > >? > r-sig-geo <r-sig-geo at r-project.org > <mailto:r-sig-geo at r-project.org> <mailto:r-sig-geo at r-project.org > <mailto:r-sig-geo at r-project.org>>> > >? > Sent: Wed, Jun 5, 2019 10:52 am > >? > Subject: Re: [R] Plotting more than one regression line in ggplot > >? > > >? > Hello, > >? > > >? > This is pretty basic ggplot. > >? > > >? > > >? > lm1 <- ggplot(onepctCO2MEDIAN, aes(x, y)) + > >? >? ? geom_point(colour = 'blue') + > >? >? ? geom_smooth(method = 'lm') > >? > > >? > lm1 > >? > > >? > > >? > If you want to combine several datasets, you will have to have a > >? > variable telling which dataset is which. In the example below, this is > >? > column 'id'. > >? > > >? > > >? > onepctCO2MEDIAN2 <- onepctCO2MEDIAN > >? > onepctCO2MEDIAN2$y <- jitter(onepctCO2MEDIAN2$y) + 2 > >? > onepctCO2MEDIAN$id <- 1 > >? > onepctCO2MEDIAN2$id <- 2 > >? > df2 <- rbind(onepctCO2MEDIAN, onepctCO2MEDIAN2) > >? > > >? > ggplot(df2, aes(x, y, group = id, colour = factor(id))) + > >? >? ? geom_point() + > >? >? ? geom_smooth(method = 'lm') > >? > > >? > > >? > Hope this helps, > >? > > >? > Rui Barradas > >? > > >? > ?s 15:21 de 05/06/19, rain1290--- via R-help escreveu: > >? >? > I am trying to plot, using ggplot, a series of scatter plots with > >? > regression lines for several datasets. I started with the following > >? > dataset, "onepectCO2MEDIAN". The data for this dataset is as follows: > >? >? >? ??? onepctCO2MEDIAN > >? >? >? ??????????????????? x????????? y > >? >? >? ??? layer.1?? 0.000000000? 0.0000000 > >? >? >? ??? layer.2?? 0.006794447? 4.9002490 > >? >? >? ??? layer.3?? 0.014288058? 0.1608000 > >? >? >? ??? layer.4?? 0.022087920? 6.6349133 > >? >? >? ??? layer.5?? 0.030797357 -1.2429506 > >? >? >? ??? layer.6?? 0.038451072? 1.5643374 > >? >? >? ??? layer.7?? 0.048087904 -2.2659035 > >? >? >? ??? layer.8?? 0.058677729? 2.2070045 > >? >? >? ??? layer.9?? 0.069261406 -2.3677001 > >? >? >? ??? layer.10? 0.080524530 -1.0913506 > >? >? >? ??? layer.11? 0.092760246? 0.4099940 > >? >? >? ??? layer.12? 0.103789609 -0.1259727 > >? >? >? ??? layer.13? 0.116953168 -2.4138253 > >? >? >? ??? layer.14? 0.129253298? 7.0890257 > >? >? >? ??? layer.15? 0.141710050 -0.7593539 > >? >? >? ??? layer.16? 0.156002052? 0.0454416 > >? >? >? ??? layer.17? 0.170648172 -1.5349683 > >? >? >? ??? layer.18? 0.185318425? 6.5524201 > >? >? >? ??? layer.19? 0.199463055 -0.8312563 > >? >? >? ??? layer.20? 0.213513337 -2.5099183 > >? >? >? ??? layer.21? 0.228839271? 0.1365968 > >? >? >? ??? layer.22? 0.246981293 -1.3719845 > >? >? >? ??? layer.23? 0.263012767 -0.8712988 > >? >? >? ??? layer.24? 0.278505564? 0.6632584 > >? >? >? ??? layer.25? 0.293658361? 0.7938036 > >? >? >? ??? layer.26? 0.310747266? 3.4880637 > >? >? >? ??? layer.27? 0.325990349 -4.4612208 > >? >? >? ??? layer.28? 0.342517540? 0.0871734 > >? >? >? ??? layer.29? 0.362751633 -1.4171578 > >? >? >? ??? layer.30? 0.380199537 -0.9956508 > >? >? >? ??? layer.31? 0.394992948? 0.3215526 > >? >? >? ??? layer.32? 0.414373398? 3.1403866 > >? >? >? ??? layer.33? 0.430690214 -0.7376099 > >? >? >? ??? layer.34? 0.449738145 -2.4860541 > >? >? >? ??? layer.35? 0.470167458 -3.4235858 > >? >? >? ??? layer.36? 0.489019871? 0.4824748 > >? >? >? ??? layer.37? 0.507242471 -0.9785386 > >? >? >? ??? layer.38? 0.524314284? 8.5359684 > >? >? >? ??? layer.39? 0.543750525? 5.4844742 > >? >? >? ??? layer.40? 0.564234197? 3.2149367 > >? >? >? ??? layer.41? 0.583679616? 3.9168916 > >? >? >? ??? layer.42? 0.601459444? 4.4907020 > >? >? >? ??? layer.43? 0.619924664? 6.5410410 > >? >? >? ??? layer.44? 0.639932007? 4.8068650 > >? >? >? ??? layer.45? 0.661347181? 8.1510170 > >? >? >? ??? layer.46? 0.684117317? 0.2697413 > >? >? >? ??? layer.47? 0.704829752 -0.1807501 > >? >? >? ??? layer.48? 0.725045770? 9.7181249 > >? >? >? ??? layer.49? 0.745165825? 1.5406466 > >? >? >? ??? layer.50? 0.765016139 -1.6476041 > >? >? >? ??? layer.51? 0.783461511? 4.8024603 > >? >? >? ??? layer.52? 0.806382924? 4.0421516 > >? >? >? ??? layer.53? 0.829241335? 9.3756512 > >? >? >? ??? layer.54? 0.849924415? 5.3305050 > >? >? >? ??? layer.55? 0.871352434? 7.5445803 > >? >? >? ??? layer.56? 0.893632233? 6.4679547 > >? >? >? ??? layer.57? 0.916052133? 2.8096065 > >? >? >? ??? layer.58? 0.938579470? 5.3921661 > >? >? >? ??? layer.59? 0.959907651? 7.2043689 > >? >? >? ??? layer.60? 0.981643587? 3.3350806 > >? >? >? ??? layer.61? 1.004116774? 8.8690707 > >? >? >? ??? layer.62? 1.028363466? 1.7861299 > >? >? >? ??? layer.63? 1.054009140? 6.2555038 > >? >? >? ??? layer.64? 1.072440803? 7.6079236 > >? >? >? ??? layer.65? 1.094457805? 7.6871483 > >? >? >? ??? layer.66? 1.123176277? 4.7787764 > >? >? >? ??? layer.67? 1.149430871 12.7110502 > >? >? >? ??? layer.68? 1.170912921 -0.7156284 > >? >? >? ??? layer.69? 1.196743071? 1.6490899 > >? >? >? ??? layer.70? 1.218625903? 3.0363024 > >? >? >? ??? layer.71? 1.241868377? 4.2974769 > >? >? >? ??? layer.72? 1.267941594? 1.9543778 > >? >? >? ??? layer.73? 1.290708780? 3.9986964 > >? >? >? ??? layer.74? 1.313222289? 4.5179472 > >? >? >? ??? layer.75? 1.339045882? 0.9337905 > >? >? >? ??? layer.76? 1.362803459? 3.3050770 > >? >? >? ??? layer.77? 1.384450197? 3.5422970 > >? >? >? ??? layer.78? 1.409720302? 5.9973660 > >? >? >? ??? layer.79? 1.435851157? 0.5081869 > >? >? >? ??? layer.80? 1.455592215? 7.9661630 > >? >? >? ??? layer.81? 1.479495347? 9.9460496 > >? >? >? ??? layer.82? 1.506051958? 3.7908372 > >? >? >? ??? layer.83? 1.525728464? 2.5735847 > >? >? >? ??? layer.84? 1.549362063 10.1404974 > >? >? >? ??? layer.85? 1.573440671 13.7408304 > >? >? >? ??? layer.86? 1.600278735? 0.9335771 > >? >? >? ??? layer.87? 1.623879492? 9.7588742 > >? >? >? ??? layer.88? 1.650029302? 1.2769395 > >? >? >? ??? layer.89? 1.672362328 13.4970906 > >? >? >? ??? layer.90? 1.700221121 10.2087502 > >? >? >? ??? layer.91? 1.724793375? 1.6811275 > >? >? >? ??? layer.92? 1.751070559? 6.1178992 > >? >? >? ??? layer.93? 1.778022110 -0.1567626 > >? >? >? ??? layer.94? 1.803022087? 3.8237479 > >? >? >? ??? layer.95? 1.830668867? 4.4331468 > >? >? >? ??? layer.96? 1.855736911? 5.9790707 > >? >? >? ??? layer.97? 1.882615030 11.3104333 > >? >? >? ??? layer.98? 1.909218490? 8.2142607 > >? >? >? ??? layer.99? 1.938130021 15.3209674 > >? >? >? ??? layer.100 1.963727593? 5.8178217 > >? >? >? ??? layer.101 1.993271947? 9.6004907 > >? >? >? ??? layer.102 2.022548139? 3.4063646 > >? >? >? ??? layer.103 2.050679922? 4.7375010 > >? >? >? ??? layer.104 2.078064442? 3.0133019 > >? >? >? ??? layer.105 2.104113460? 5.5659522 > >? >? >? ??? layer.106 2.133597612 12.0346333 > >? >? >? ??? layer.107 2.164026260 -0.4028320 > >? >? >? ??? layer.108 2.194852829 10.5996780 > >? >? >? ??? layer.109 2.224257946? 5.4479584 > >? >? >? ??? layer.110 2.252194643? 4.7052374 > >? >? >? ??? layer.111 2.277335048 14.0962019 > >? >? >? ??? layer.112 2.304058313? 5.7149016 > >? >? >? ??? layer.113 2.330930233? 3.7780072 > >? >? >? ??? layer.114 2.357022762? 4.4120620 > >? >? >? ??? layer.115 2.386489272? 4.1866085 > >? >? >? ??? layer.116 2.417503953? 6.9078802 > >? >? >? ??? layer.117 2.448524356? 2.7825739 > >? >? >? ??? layer.118 2.478698969? 7.6171786 > >? >? >? ??? layer.119 2.510175705 10.2410603 > >? >? >? ??? layer.120 2.539697886? 8.1820711 > >? >? >? ??? layer.121 2.567915559? 4.8275494 > >? >? >? ??? layer.122 2.597463250 19.1624883 > >? >? >? ??? layer.123 2.627518773 16.0677109 > >? >? >? ??? layer.124 2.658759236 12.5897081 > >? >? >? ??? layer.125 2.692401528? 9.2907988 > >? >? >? ??? layer.126 2.721903205? 7.4262502 > >? >? >? ??? layer.127 2.753021359? 9.3902518 > >? >? >? ??? layer.128 2.786313415 12.6193550 > >? >? >? ??? layer.129 2.819564104 11.1121040 > >? >? >? ??? layer.130 2.850823164 15.7907100 > >? >? >? ??? layer.131 2.880394101 10.7425287 > >? >? >? ??? layer.132 2.911391258? 7.7971430 > >? >? >? ??? layer.133 2.942965150? 8.8060858 > >? >? >? ??? layer.134 2.974468350 17.5606266 > >? >? >? ??? layer.135 3.008983612 17.3088605 > >? >? >? ??? layer.136 3.040015221 13.4500543 > >? >? >? ??? layer.137 3.072668672 14.6377884 > >? >? >? ??? layer.138 3.105982423? 8.0798552dput(onepctCO2MEDIAN) > >? > dput(onepctCO2MEDIAN) > >? >? >? ??? structure(list(x = c(0, 0.00679444684647024, > 0.014288058038801, > >? >? >? ??? 0.0220879195258021, > >? > 0.0307973567396402,0.0384510718286037,0.0480879042297602, > >? >? >? ??? 0.0586777292191982, 0.0692614056169987, > >? > 0.080524530261755,0.0927602462470531, > >? >? >? ??? 0.103789608925581, 0.116953168064356, 0.129253298044205, > >? > 0.141710050404072, > >? >? >? ??? 0.156002052128315, 0.170648172497749, 0.185318425297737, > >? > 0.199463054537773, > >? >? >? ??? 0.21351333707571, 0.22883927077055, 0.246981292963028, > >? > 0.263012766838074, > >? >? >? ??? 0.278505563735962, 0.29365836083889, 0.310747265815735, > >? > 0.325990349054337, > >? >? >? ??? 0.342517539858818, 0.362751632928848, 0.380199536681175, > >? > 0.39499294757843, > >? >? >? ??? 0.414373397827148, 0.430690214037895, 0.449738144874573, > >? > 0.470167458057404, > >? >? >? ??? 0.489019870758057, 0.507242470979691, 0.524314284324646, > >? > 0.543750524520874, > >? >? >? ??? 0.56423419713974, 0.583679616451263, 0.601459443569183, > >? > 0.619924664497375, > >? >? >? ??? 0.639932006597519, 0.661347180604935, 0.684117317199707, > >? > 0.704829752445221, > >? >? >? ??? 0.725045770406723, 0.745165824890137, 0.765016138553619, > >? > 0.783461511135101, > >? >? >? ??? 0.806382924318314, 0.829241335391998, 0.84992441534996, > >? > 0.871352434158325, > >? >? >? ??? 0.893632233142853, 0.916052132844925, 0.938579469919205, > >? > 0.959907650947571, > >? >? >? ??? 0.981643587350845, 1.00411677360535, 1.02836346626282, > >? > 1.05400913953781, > >? >? >? ??? 1.07244080305099, 1.09445780515671, 1.12317627668381, > >? > 1.14943087100983, > >? >? >? ??? 1.17091292142868, 1.19674307107925, 1.21862590312958, > >? > 1.24186837673187, > >? >? >? ??? 1.26794159412384, 1.2907087802887, 1.31322228908539, > >? > 1.33904588222504, > >? >? >? ??? 1.36280345916748, 1.38445019721985, 1.40972030162811, > >? > 1.43585115671158, > >? >? >? ??? 1.45559221506119, 1.47949534654617, 1.50605195760727, > >? > 1.52572846412659, > >? >? >? ??? 1.5493620634079, 1.5734406709671, 1.60027873516083, > >? > 1.62387949228287, > >? >? >? ??? 1.65002930164337, 1.67236232757568, 1.70022112131119, > >? > 1.72479337453842, > >? >? >? ??? 1.75107055902481, 1.77802211046219, 1.80302208662033, > >? > 1.83066886663437, > >? >? >? ??? 1.85573691129684, 1.88261502981186, 1.90921849012375, > >? > 1.93813002109528, > >? >? >? ??? 1.96372759342194, 1.99327194690704, 2.02254813909531, > >? > 2.05067992210388, > >? >? >? ??? 2.07806444168091, 2.1041134595871, 2.13359761238098, > >? > 2.16402626037598, > >? >? >? ??? 2.19485282897949, 2.2242579460144, 2.25219464302063, > >? > 2.27733504772186, > >? >? >? ??? 2.30405831336975, 2.33093023300171, 2.35702276229858, > >? > 2.38648927211761, > >? >? >? ??? 2.41750395298004, 2.44852435588837, 2.47869896888733, > >? > 2.51017570495605, > >? >? >? ??? 2.53969788551331, 2.567915558815, 2.59746325016022, > >? > 2.62751877307892, > >? >? >? ??? 2.65875923633575, 2.69240152835846, 2.72190320491791, > >? > 2.75302135944366, > >? >? >? ??? 2.78631341457367, 2.8195641040802, 2.85082316398621, > >? > 2.88039410114288, > >? >? >? ??? 2.91139125823975, 2.94296514987946, 2.97446835041046, > >? > 3.00898361206055, > >? >? >? ??? 3.04001522064209, 3.07266867160797, 3.10598242282867), y = > c(0, > >? >? >? ??? 4.90024901723162, 0.160799993152722, 6.63491326258641, > >? > -1.24295055804536, > >? >? >? ??? 1.56433744259162, -2.26590352245208, 2.20700446463354, > >? > -2.36770012911069, > >? >? >? ??? -1.09135061899174, 0.409993989292701, -0.125972681525582, > >? > -2.41382533818026, > >? >? >? ??? 7.08902570153028, -0.759353880417294, 0.0454415959640926, > >? > -1.53496826259972, > >? >? >? ??? 6.55242014096194, -0.831256280861552, -2.50991825629084, > >? > 0.136596820654013, > >? >? >? ??? -1.37198445498419, -0.871298832596736, 0.663258363762466, > >? > 0.793803634291308, > >? >? >? ??? 3.48806373666998, -4.46122081238949, 0.0871733966938564, > >? > -1.41715777257774, > >? >? >? ??? -0.995650815648318, 0.32155262317503, 3.14038657369241, > >? > -0.737609879885404, > >? >? >? ??? -2.48605406511292, -3.423585843908, 0.482474753780281, > >? > -0.978538630093809, > >? >? >? ??? 8.53596837794201, 5.48447420320695, 3.21493665820644, > >? > 3.91689160157513, > >? >? >? ??? 4.49070195980797, 6.54104103157039, 4.80686500146557, > >? > 8.15101701282067, > >? >? >? ??? 0.26974132191657, -0.180750068063062, 9.71812491230244, > >? > 1.54064657400204, > >? >? >? ??? -1.64760408795688, 4.80246028991894, 4.04215159914344, > >? > 9.37565121768513, > >? >? >? ??? 5.33050496938428, 7.54458026088508, 6.46795470819342, > >? > 2.80960651433971, > >? >? >? ??? 5.39216613235986, 7.20436888038562, 3.3350806460997, > >? > 8.86907069895943, > >? >? >? ??? 1.78612988613659, 6.25550382050395, 7.60792364896564, > >? > 7.68714830528144, > >? >? >? ??? 4.77877638957615, 12.7110501777314, -0.715628443181046, > >? > 1.64908991824022, > >? >? >? ??? 3.03630240714679, 4.29747688442346, 1.95437780501881, > >? > 3.99869636910933, > >? >? >? ??? 4.51794724689848, 0.933790484492299, 3.30507700050003, > >? > 3.5422970157433, > >? >? >? ??? 5.99736597322524, 0.508186860060022, 7.96616300581067, > >? > 9.94604963036295, > >? >? >? ??? 3.79083717222623, 2.57358468532258, 10.1404974171776, > >? > 13.7408303595752, > >? >? >? ??? 0.933577123801399, 9.75887417074129, 1.27693947132921, > >? > 13.4970905965787, > >? >? >? ??? 10.2087501765735, 1.68112753028756, 6.1178991508927, > >? > -0.156762622680077, > >? >? >? ??? 3.82374791691426, 4.43314678736265, 5.97907067167507, > >? > 11.3104332518482, > >? >? >? ??? 8.21426074201525, 15.320967360602, 5.81782169471483, > >? > 9.6004907412354, > >? >? >? ??? 3.40636455909704, 4.73750103921864, 3.0133019468806, > >? > 5.56595224859066, > >? >? >? ??? 12.0346332527215, -0.40283199827104, 10.5996779538754, > >? > 5.44795836991128, > >? >? >? ??? 4.70523736412729, 14.096201892183, 5.71490161813391, > >? > 3.77800720810782, > >? >? >? ??? 4.41206200639436, 4.18660847858423, 6.90788020044911, > >? > 2.78257393345915, > >? >? >? ??? 7.61717857379431, 10.2410602647684, 8.18207106836167, > >? > 4.82754943871433, > >? >? >? ??? 19.1624882857155, 16.0677109398509, 12.589708067017, > >? > 9.29079879799404, > >? >? >? ??? 7.42625019725314, 9.39025179806185, 12.6193550331438, > >? > 11.1121039747257, > >? >? >? ??? 15.7907099734986, 10.7425286789233, 7.79714300307344, > >? > 8.80608578166101, > >? >? >? ??? 17.5606266346039, 17.3088604929222, 13.4500543478523, > >? > 14.6377884248645, > >? >? >? ??? 8.07985518296064)), class = "data.frame", row.names > > c("layer.1", > >? >? >? ??? "layer.2", "layer.3", "layer.4", "layer.5", "layer.6", > "layer.7", > >? >? >? ??? "layer.8", "layer.9", "layer.10", "layer.11", "layer.12", > >? > "layer.13", > >? >? >? ??? "layer.14", "layer.15", "layer.16", "layer.17", "layer.18", > >? > "layer.19", > >? >? >? ??? "layer.20", "layer.21", "layer.22", "layer.23", "layer.24", > >? > "layer.25", > >? >? >? ??? "layer.26", "layer.27", "layer.28", "layer.29", "layer.30", > >? > "layer.31", > >? >? >? ??? "layer.32", "layer.33", "layer.34", "layer.35", "layer.36", > >? > "layer.37", > >? >? >? ??? "layer.38", "layer.39", "layer.40", "layer.41", "layer.42", > >? > "layer.43", > >? >? >? ??? "layer.44", "layer.45", "layer.46", "layer.47", "layer.48", > >? > "layer.49", > >? >? >? ??? "layer.50", "layer.51", "layer.52", "layer.53", "layer.54", > >? > "layer.55", > >? >? >? ??? "layer.56", "layer.57", "layer.58", "layer.59", "layer.60", > >? > "layer.61", > >? >? >? ??? "layer.62", "layer.63", "layer.64", "layer.65", "layer.66", > >? > "layer.67", > >? >? >? ??? "layer.68", "layer.69", "layer.70", "layer.71", "layer.72", > >? > "layer.73", > >? >? >? ??? "layer.74", "layer.75", "layer.76", "layer.77", "layer.78", > >? > "layer.79", > >? >? >? ??? "layer.80", "layer.81", "layer.82", "layer.83", "layer.84", > >? > "layer.85", > >? >? >? ??? "layer.86", "layer.87", "layer.88", "layer.89", "layer.90", > >? > "layer.91", > >? >? >? ??? "layer.92", "layer.93", "layer.94", "layer.95", "layer.96", > >? > "layer.97", > >? >? >? ??? "layer.98", "layer.99", "layer.100", "layer.101", "layer.102", > >? >? >? ??? "layer.103", "layer.104", "layer.105", "layer.106", > "layer.107", > >? >? >? ??? "layer.108", "layer.109", "layer.110", "layer.111", > "layer.112", > >? >? >? ??? "layer.113", "layer.114", "layer.115", "layer.116", > "layer.117", > >? >? >? ??? "layer.118", "layer.119", "layer.120", "layer.121", > "layer.122", > >? >? >? ??? "layer.123", "layer.124", "layer.125", "layer.126", > "layer.127", > >? >? >? ??? "layer.128", "layer.129", "layer.130", "layer.131", > "layer.132", > >? >? >? ??? "layer.133", "layer.134", "layer.135", "layer.136", > "layer.137", > >? >? >? ??? "layer.138")) > >? >? > I started with the following to generate the first regression line > >? > and scatter plot:??? lm<-ggplot(onepctCO2MEDIAN) + > >? >? >? ??? geom_jitter(aes(RCP1pctCO2cumulativeMedian[1:138], > departurea), > >? >? >? ??? colour="blue") + > > geom_smooth(aes(RCP1pctCO2cumulativeMedian[1:138], > >? >? >? ??? departurea), method=lm) > >? >? > But I receive this error:? ??Warning message: > >? >? >? ??? Computation failed in `stat_smooth()`: > >? >? >? ??? 'what' must be a function or character string > >? >? > A blue scatter plot is successfully generated, but the problem is > >? > that the regression line does not appear, presumably related to the > >? > above warning. > >? >? > Is there a reason for this? I would appreciate any assistance! > >? >? > ??? [[alternative HTML version deleted]] > >? > > >? >? > > >? >? > ______________________________________________ > >? >? > R-help at r-project.org <mailto:R-help at r-project.org> > <mailto:R-help at r-project.org <mailto:R-help at r-project.org>> mailing list -- > > To UNSUBSCRIBE and more, see > >? >? > https://stat.ethz.ch/mailman/listinfo/r-help > >? >? > PLEASE do read the posting guide > >? > http://www.R-project.org/posting-guide.html > >? >? > and provide commented, minimal, self-contained, reproducible code. > >? > > >? >? >
r@i@1290 m@iii@g oii @im@com
2019-Jun-06 16:49 UTC
[R] Plotting more than one regression line in ggplot
Hi Rui, NewestdataUltra looks like this (Note that "HistoricalMEDIAN" is hidden, but it follows "RCP8.5MEDIAN" listing the same way): x variable value L1 1 0.000000000 y 0.00000000 onepctCO2MEDIAN 2 0.006794447 y 4.90024902 onepctCO2MEDIAN 3 0.014288058 y 0.16079999 onepctCO2MEDIAN 4 0.022087920 y 6.63491326 onepctCO2MEDIAN 5 0.030797357 y -1.24295056 onepctCO2MEDIAN 6 0.038451072 y 1.56433744 onepctCO2MEDIAN 7 0.048087904 y -2.26590352 onepctCO2MEDIAN 8 0.058677729 y 2.20700446 onepctCO2MEDIAN 9 0.069261406 y -2.36770013 onepctCO2MEDIAN 10 0.080524530 y -1.09135062 onepctCO2MEDIAN 11 0.092760246 y 0.40999399 onepctCO2MEDIAN 12 0.103789609 y -0.12597268 onepctCO2MEDIAN 13 0.116953168 y -2.41382534 onepctCO2MEDIAN 14 0.129253298 y 7.08902570 onepctCO2MEDIAN 15 0.141710050 y -0.75935388 onepctCO2MEDIAN 16 0.156002052 y 0.04544160 onepctCO2MEDIAN 17 0.170648172 y -1.53496826 onepctCO2MEDIAN 18 0.185318425 y 6.55242014 onepctCO2MEDIAN 19 0.199463055 y -0.83125628 onepctCO2MEDIAN 20 0.213513337 y -2.50991826 onepctCO2MEDIAN 21 0.228839271 y 0.13659682 onepctCO2MEDIAN 22 0.246981293 y -1.37198445 onepctCO2MEDIAN 23 0.263012767 y -0.87129883 onepctCO2MEDIAN 24 0.278505564 y 0.66325836 onepctCO2MEDIAN 25 0.293658361 y 0.79380363 onepctCO2MEDIAN 26 0.310747266 y 3.48806374 onepctCO2MEDIAN 27 0.325990349 y -4.46122081 onepctCO2MEDIAN 28 0.342517540 y 0.08717340 onepctCO2MEDIAN 29 0.362751633 y -1.41715777 onepctCO2MEDIAN 30 0.380199537 y -0.99565082 onepctCO2MEDIAN 31 0.394992948 y 0.32155262 onepctCO2MEDIAN 32 0.414373398 y 3.14038657 onepctCO2MEDIAN 33 0.430690214 y -0.73760988 onepctCO2MEDIAN 34 0.449738145 y -2.48605407 onepctCO2MEDIAN 35 0.470167458 y -3.42358584 onepctCO2MEDIAN 36 0.489019871 y 0.48247475 onepctCO2MEDIAN 37 0.507242471 y -0.97853863 onepctCO2MEDIAN 38 0.524314284 y 8.53596838 onepctCO2MEDIAN 39 0.543750525 y 5.48447420 onepctCO2MEDIAN 40 0.564234197 y 3.21493666 onepctCO2MEDIAN 41 0.583679616 y 3.91689160 onepctCO2MEDIAN 42 0.601459444 y 4.49070196 onepctCO2MEDIAN 43 0.619924664 y 6.54104103 onepctCO2MEDIAN 44 0.639932007 y 4.80686500 onepctCO2MEDIAN 45 0.661347181 y 8.15101701 onepctCO2MEDIAN 46 0.684117317 y 0.26974132 onepctCO2MEDIAN 47 0.704829752 y -0.18075007 onepctCO2MEDIAN 48 0.725045770 y 9.71812491 onepctCO2MEDIAN 49 0.745165825 y 1.54064657 onepctCO2MEDIAN 50 0.765016139 y -1.64760409 onepctCO2MEDIAN 51 0.783461511 y 4.80246029 onepctCO2MEDIAN 52 0.806382924 y 4.04215160 onepctCO2MEDIAN 53 0.829241335 y 9.37565122 onepctCO2MEDIAN 54 0.849924415 y 5.33050497 onepctCO2MEDIAN 55 0.871352434 y 7.54458026 onepctCO2MEDIAN 56 0.893632233 y 6.46795471 onepctCO2MEDIAN 57 0.916052133 y 2.80960651 onepctCO2MEDIAN 58 0.938579470 y 5.39216613 onepctCO2MEDIAN 59 0.959907651 y 7.20436888 onepctCO2MEDIAN 60 0.981643587 y 3.33508065 onepctCO2MEDIAN 61 1.004116774 y 8.86907070 onepctCO2MEDIAN 62 1.028363466 y 1.78612989 onepctCO2MEDIAN 63 1.054009140 y 6.25550382 onepctCO2MEDIAN 64 1.072440803 y 7.60792365 onepctCO2MEDIAN 65 1.094457805 y 7.68714831 onepctCO2MEDIAN 66 1.123176277 y 4.77877639 onepctCO2MEDIAN 67 1.149430871 y 12.71105018 onepctCO2MEDIAN 68 1.170912921 y -0.71562844 onepctCO2MEDIAN 69 1.196743071 y 1.64908992 onepctCO2MEDIAN 70 1.218625903 y 3.03630241 onepctCO2MEDIAN 71 1.241868377 y 4.29747688 onepctCO2MEDIAN 72 1.267941594 y 1.95437781 onepctCO2MEDIAN 73 1.290708780 y 3.99869637 onepctCO2MEDIAN 74 1.313222289 y 4.51794725 onepctCO2MEDIAN 75 1.339045882 y 0.93379048 onepctCO2MEDIAN 76 1.362803459 y 3.30507700 onepctCO2MEDIAN 77 1.384450197 y 3.54229702 onepctCO2MEDIAN 78 1.409720302 y 5.99736597 onepctCO2MEDIAN 79 1.435851157 y 0.50818686 onepctCO2MEDIAN 80 1.455592215 y 7.96616301 onepctCO2MEDIAN 81 1.479495347 y 9.94604963 onepctCO2MEDIAN 82 1.506051958 y 3.79083717 onepctCO2MEDIAN 83 1.525728464 y 2.57358469 onepctCO2MEDIAN 84 1.549362063 y 10.14049742 onepctCO2MEDIAN 85 1.573440671 y 13.74083036 onepctCO2MEDIAN 86 1.600278735 y 0.93357712 onepctCO2MEDIAN 87 1.623879492 y 9.75887417 onepctCO2MEDIAN 88 1.650029302 y 1.27693947 onepctCO2MEDIAN 89 1.672362328 y 13.49709060 onepctCO2MEDIAN 90 1.700221121 y 10.20875018 onepctCO2MEDIAN 91 1.724793375 y 1.68112753 onepctCO2MEDIAN 92 1.751070559 y 6.11789915 onepctCO2MEDIAN 93 1.778022110 y -0.15676262 onepctCO2MEDIAN 94 1.803022087 y 3.82374792 onepctCO2MEDIAN 95 1.830668867 y 4.43314679 onepctCO2MEDIAN 96 1.855736911 y 5.97907067 onepctCO2MEDIAN 97 1.882615030 y 11.31043325 onepctCO2MEDIAN 98 1.909218490 y 8.21426074 onepctCO2MEDIAN 99 1.938130021 y 15.32096736 onepctCO2MEDIAN 100 1.963727593 y 5.81782169 onepctCO2MEDIAN 101 1.993271947 y 9.60049074 onepctCO2MEDIAN 102 2.022548139 y 3.40636456 onepctCO2MEDIAN 103 2.050679922 y 4.73750104 onepctCO2MEDIAN 104 2.078064442 y 3.01330195 onepctCO2MEDIAN 105 2.104113460 y 5.56595225 onepctCO2MEDIAN 106 2.133597612 y 12.03463325 onepctCO2MEDIAN 107 2.164026260 y -0.40283200 onepctCO2MEDIAN 108 2.194852829 y 10.59967795 onepctCO2MEDIAN 109 2.224257946 y 5.44795837 onepctCO2MEDIAN 110 2.252194643 y 4.70523736 onepctCO2MEDIAN 111 2.277335048 y 14.09620189 onepctCO2MEDIAN 112 2.304058313 y 5.71490162 onepctCO2MEDIAN 113 2.330930233 y 3.77800721 onepctCO2MEDIAN 114 2.357022762 y 4.41206201 onepctCO2MEDIAN 115 2.386489272 y 4.18660848 onepctCO2MEDIAN 116 2.417503953 y 6.90788020 onepctCO2MEDIAN 117 2.448524356 y 2.78257393 onepctCO2MEDIAN 118 2.478698969 y 7.61717857 onepctCO2MEDIAN 119 2.510175705 y 10.24106026 onepctCO2MEDIAN 120 2.539697886 y 8.18207107 onepctCO2MEDIAN 121 2.567915559 y 4.82754944 onepctCO2MEDIAN 122 2.597463250 y 19.16248829 onepctCO2MEDIAN 123 2.627518773 y 16.06771094 onepctCO2MEDIAN 124 2.658759236 y 12.58970807 onepctCO2MEDIAN 125 2.692401528 y 9.29079880 onepctCO2MEDIAN 126 2.721903205 y 7.42625020 onepctCO2MEDIAN 127 2.753021359 y 9.39025180 onepctCO2MEDIAN 128 2.786313415 y 12.61935503 onepctCO2MEDIAN 129 2.819564104 y 11.11210397 onepctCO2MEDIAN 130 2.850823164 y 15.79070997 onepctCO2MEDIAN 131 2.880394101 y 10.74252868 onepctCO2MEDIAN 132 2.911391258 y 7.79714300 onepctCO2MEDIAN 133 2.942965150 y 8.80608578 onepctCO2MEDIAN 134 2.974468350 y 17.56062663 onepctCO2MEDIAN 135 3.008983612 y 17.30886049 onepctCO2MEDIAN 136 3.040015221 y 13.45005435 onepctCO2MEDIAN 137 3.072668672 y 14.63778842 onepctCO2MEDIAN 138 3.105982423 y 8.07985518 onepctCO2MEDIAN 139 0.467429527 y -1.55704023 RCP4.5MEDIAN 140 0.478266196 y -3.19367515 RCP4.5MEDIAN 141 0.489205229 y -2.44452679 RCP4.5MEDIAN 142 0.500039143 y 0.87504367 RCP4.5MEDIAN 143 0.511021115 y -0.39185002 RCP4.5MEDIAN 144 0.519874968 y -4.18935168 RCP4.5MEDIAN 145 0.528508358 y -3.64179524 RCP4.5MEDIAN 146 0.537377594 y -2.58167128 RCP4.5MEDIAN 147 0.546194211 y 2.20583694 RCP4.5MEDIAN 148 0.554720591 y -8.57764597 RCP4.5MEDIAN 149 0.563289814 y 2.88442536 RCP4.5MEDIAN 150 0.572032790 y -3.90829882 RCP4.5MEDIAN 151 0.580939066 y -3.39269048 RCP4.5MEDIAN 152 0.590921065 y -4.60849867 RCP4.5MEDIAN 153 0.601575326 y -1.62572657 RCP4.5MEDIAN 154 0.612425555 y 1.14198465 RCP4.5MEDIAN 155 0.623773319 y -3.38454122 RCP4.5MEDIAN 156 0.635363359 y 2.43414265 RCP4.5MEDIAN 157 0.646722666 y 3.30007615 RCP4.5MEDIAN 158 0.658285673 y -0.79555442 RCP4.5MEDIAN 159 0.670250852 y -2.05220500 RCP4.5MEDIAN 160 0.681702690 y -5.56808946 RCP4.5MEDIAN 161 0.693531145 y 2.24168605 RCP4.5MEDIAN 162 0.706016061 y -4.83673351 RCP4.5MEDIAN 163 0.718231249 y 0.40086819 RCP4.5MEDIAN 164 0.730190911 y -1.98026992 RCP4.5MEDIAN 165 0.741269845 y 0.39963115 RCP4.5MEDIAN 166 0.751000321 y -0.83241777 RCP4.5MEDIAN 167 0.760886972 y -1.66101404 RCP4.5MEDIAN 168 0.771137164 y -1.05452982 RCP4.5MEDIAN 169 0.781856383 y -1.18338156 RCP4.5MEDIAN 170 0.792607542 y 0.22722653 RCP4.5MEDIAN 171 0.803724128 y -1.90642564 RCP4.5MEDIAN 172 0.815066246 y 0.75010550 RCP4.5MEDIAN 173 0.826027437 y -1.31108646 RCP4.5MEDIAN 174 0.836766732 y 1.05961515 RCP4.5MEDIAN 175 0.847553312 y -2.06588010 RCP4.5MEDIAN 176 0.858331452 y 8.53403315 RCP4.5MEDIAN 177 0.869154422 y 0.09979751 RCP4.5MEDIAN 178 0.879572539 y -2.50854353 RCP4.5MEDIAN 179 0.889426601 y 5.29550783 RCP4.5MEDIAN 180 0.899009805 y 2.02909481 RCP4.5MEDIAN 181 0.908289566 y 2.66922982 RCP4.5MEDIAN 182 0.917284978 y -4.17757196 RCP4.5MEDIAN 183 0.926128960 y 3.40202916 RCP4.5MEDIAN 184 0.934752874 y -1.92292218 RCP4.5MEDIAN 185 0.943010943 y 6.36969150 RCP4.5MEDIAN 186 0.950999217 y 1.86490308 RCP4.5MEDIAN 187 0.958795701 y 8.32126161 RCP4.5MEDIAN 188 0.966310396 y 10.15048356 RCP4.5MEDIAN 189 0.973635493 y 6.68925964 RCP4.5MEDIAN 190 0.980834088 y -1.01615369 RCP4.5MEDIAN 191 0.987694790 y 0.20892853 RCP4.5MEDIAN 192 0.994548581 y -1.52787222 RCP4.5MEDIAN 193 1.001274595 y -0.72374597 RCP4.5MEDIAN 194 1.007810612 y 2.26062309 RCP4.5MEDIAN 195 1.014270389 y -2.40270340 RCP4.5MEDIAN 196 1.022719711 y -1.94548262 RCP4.5MEDIAN 197 1.032070810 y -1.13053235 RCP4.5MEDIAN 198 1.041118812 y 0.56107969 RCP4.5MEDIAN 199 1.050189571 y 3.27941835 RCP4.5MEDIAN 200 1.059380475 y 3.01333588 RCP4.5MEDIAN 201 1.067877585 y 4.87457336 RCP4.5MEDIAN 202 1.076078766 y 1.02457895 RCP4.5MEDIAN 203 1.084707357 y 4.49174869 RCP4.5MEDIAN 204 1.093223180 y 8.24629303 RCP4.5MEDIAN 205 1.101414382 y -0.03364132 RCP4.5MEDIAN 206 1.108886304 y 9.12509848 RCP4.5MEDIAN 207 1.115482896 y 1.74254621 RCP4.5MEDIAN 208 1.121856558 y 2.27004536 RCP4.5MEDIAN 209 1.127809421 y -0.65627179 RCP4.5MEDIAN 210 1.133265961 y 12.02566969 RCP4.5MEDIAN 211 1.138549712 y -1.04260843 RCP4.5MEDIAN 212 1.143910237 y -6.47611327 RCP4.5MEDIAN 213 1.149437787 y 8.88410567 RCP4.5MEDIAN 214 1.154488347 y -4.24916247 RCP4.5MEDIAN 215 1.159872903 y 7.90741918 RCP4.5MEDIAN 216 1.165477487 y -3.91386711 RCP4.5MEDIAN 217 1.171103424 y 1.02370701 RCP4.5MEDIAN 218 1.177498256 y -3.71206616 RCP4.5MEDIAN 219 1.184003888 y -1.05694182 RCP4.5MEDIAN 220 1.190395856 y 1.10501459 RCP4.5MEDIAN 221 1.197284280 y 2.67668639 RCP4.5MEDIAN 222 1.204590551 y 2.21693031 RCP4.5MEDIAN 223 1.210807614 y 2.90252830 RCP4.5MEDIAN 224 1.216470664 y 2.75093766 RCP4.5MEDIAN 225 1.221914148 y -0.73815245 RCP4.5MEDIAN 226 1.227580480 y 3.58554626 RCP4.5MEDIAN 227 1.233317788 y 10.89961658 RCP4.5MEDIAN 228 1.238093406 y 3.23374387 RCP4.5MEDIAN 229 0.466622908 y -1.92366466 RCP8.5MEDIAN 230 0.474211509 y 4.09292949 RCP8.5MEDIAN 231 0.480383051 y -0.84736312 RCP8.5MEDIAN 232 0.486304903 y -0.80597889 RCP8.5MEDIAN 233 0.492151615 y -0.50244413 RCP8.5MEDIAN 234 0.499312643 y 3.07785701 RCP8.5MEDIAN 235 0.508859905 y -6.15175322 RCP8.5MEDIAN 236 0.518758845 y -0.51590144 RCP8.5MEDIAN 237 0.528675758 y 3.33135956 RCP8.5MEDIAN 238 0.538928423 y 2.62280891 RCP8.5MEDIAN 239 0.549621221 y -6.90096009 RCP8.5MEDIAN 240 0.560062840 y -3.45706029 RCP8.5MEDIAN 241 0.570860791 y 1.36192518 RCP8.5MEDIAN 242 0.581923368 y 0.34822359 RCP8.5MEDIAN 243 0.592628298 y 3.06882935 RCP8.5MEDIAN 244 0.604230648 y -3.56142825 RCP8.5MEDIAN 245 0.615975167 y 10.35932554 RCP8.5MEDIAN 246 0.627448279 y 10.21751629 RCP8.5MEDIAN 247 0.639401050 y 3.31040335 RCP8.5MEDIAN 248 0.651949591 y -0.53558775 RCP8.5MEDIAN 249 0.664634427 y 2.66081860 RCP8.5MEDIAN 250 0.677343552 y 3.21379656 RCP8.5MEDIAN [ reached 'max' / getOption("max.print") -- omitted 212 rows ] If I wanted scatter plots and regression lines of onepctCO2MEDIAN, RCP4.5MEDIAN and RCP8.5MEDIAN, would I do something like this? :ggplot(subset(NewestdataUltra, L1 != 'onepctCO2MEDIAN'), aes(x, value, colour = L1)) + geom_point() + scale_color_manual(values =c("green", "blue" "red", "black")) + geom_smooth(method = lm, se=FALSE) Thanks, -----Original Message----- From: Rui Barradas <ruipbarradas at sapo.pt> To: rain1290 <rain1290 at aim.com>; r-help <r-help at R-project.org> Sent: Thu, Jun 6, 2019 11:53 am Subject: Re: [R] Plotting more than one regression line in ggplot Hello, It's impossible to say without seeing the data. What is the return value of df_tmp <- subset(NewestdataUltra, L1 != 'onepctCO2MEDIAN') unique(df_tmp$L1) The number of colors must be the same as length(unique(df_tmp$L1)) Hope this helps, Rui Barradas ?s 16:49 de 06/06/19, rain1290 at aim.com escreveu:> Hi Rui, > > Yes, you are right. It should be this, but I tried with only 3 colors, > as you suggested: > > ggplot(subset(NewestdataUltra, L1 != 'onepctCO2MEDIAN'), aes(x, value, > colour = L1)) + geom_point() + scale_color_manual(values =c("green", > "blue" "red")) + geom_smooth(method = lm, se=FALSE) > > **//___^ > **//___^I still end up with the same error, however, when I specify only > 3 colors. Why could this be? > > > -----Original Message----- > From: Rui Barradas <ruipbarradas at sapo.pt> > To: rain1290 <rain1290 at aim.com>; r-help <r-help at R-project.org> > Sent: Thu, Jun 6, 2019 11:18 am > Subject: Re: [R] Plotting more than one regression line in ggplot > > Hello, > > 1) In the text you say your dataset is named NewestdataUltra but in the > ggplot instruction it's Newestdata. One of these is wrong. > > 2) Is it onepctCO2MEDIAN or RCPonepctCO2MEDIAN? > > 3) You are filtering out the value in point ) above. So you only plot 3 > regression lines, you don't need 4 colors. > > > Hope this helps, > > Rui Barradas > > ?s 15:35 de 06/06/19, rain1290 at aim.com <mailto:rain1290 at aim.com> escreveu: >? > Hi Rui (and everyone), >? > >? > >? > Thank you for this! Yes, this did work fine, as I can see my scatter >? > plots and regression lines on the same plot, along with the appropriate >? > coloring scheme! :) >? > >? > Just one last question concerning this - I melted other dataframes into >? > my new "NewestdataUltra". I now have 4 objects listed in there in this >? > order (starting from the top of the list): "onepctCO2MEDIAN", >? > "RCP4.5MEDIAN", RCP8.5MEDIAN", and "HistoricalMEDIAN". I tried plotting >? > colored scattered plots and regression lines for these in this manner: >? > >? > ggplot(subset(Newestdata, L1 != 'RCPonepctCO2MEDIAN'), aes(x, value, >? > colour = L1)) + geom_point() + scale_color_manual(values =c("green", >? > "blue" "red", "black")) + geom_smooth(method = lm, se=FALSE) >? > >? > However, I received this error: >? > >? > Error: unexpected string constant in "ggplot(subset(NewestdataUltra, L1 >? > != 'RCPonepctCO2MEDIAN'), aes(x, value, colour = L1)) + geom_point() + >? > scale_color_manual(values =c("green", "blue" "red"" >? > >? > **//___^ >? > >? > Why would this error appear?? I think that I assigned the colors >? > correctly to each of the four objects in question, so why would this > occur? >? > >? > Thank you, once again! >? > >? > -----Original Message----- >? > From: Rui Barradas <ruipbarradas at sapo.pt <mailto:ruipbarradas at sapo.pt>> >? > To: rain1290 <rain1290 at aim.com <mailto:rain1290 at aim.com>>; r-help > <r-help at R-project.org <mailto:r-help at R-project.org>> >? > Sent: Thu, Jun 6, 2019 6:52 am >? > Subject: Re: [R] Plotting more than one regression line in ggplot >? > >? > Hello, >? > >? > You are confusing some of the values of L1 with L1 itself. >? > If you just want two of those values in your plot, "onepctCO2MEDIAN" and >? > "RCP8.5MEDIAN", you need to subset the data filtering out the rows with >? > L1 == "RCP4.5MEDIAN". >? > >? > And please forget geom_jitter, it is completely inappropriate for the >? > type of scatter plot you are trying to graph. You jitter when there is >? > overplotting, not as a general purpose technique. >? > >? > Here is one way to do it. >? > >? > >? > ggplot(subset(NewestdataUltra, L1 != 'RCP4.5MEDIAN'), >? >? ? ? ? ? aes(x, value, colour = L1)) + >? >? ? geom_point() + >? >? ? scale_color_manual(values = c("green", "red")) + >? >? ? geom_smooth(method = lm) >? > >? > >? > Hope this helps, >? > >? > Rui Barradas >? > >? > ?s 22:37 de 05/06/19, rain1290 at aim.com <mailto:rain1290 at aim.com> > <mailto:rain1290 at aim.com <mailto:rain1290 at aim.com>> escreveu: >? >? > Hi Rui (and everyone), >? >? > >? >? > Thank you so much for your response! Much appreciated! >? >? > >? >? > What if I wanted I create several regression lines and scatter > plots in >? >? > the same ggplot using a "melted" dataset? I would like to create a >? >? > scatter plot and regression line for both the objects of >? >? > "onepctCO2MEDIAN" and "RCP8.5MEDIANThis melted dataset looks like > this: >? >? > >? >? > >? >? >? >NewestdataUltra >? >? > >? >? > x variable value L1 1 0.000000000 y 0.00000000 onepctCO2MEDIAN 2 >? >? > 0.006794447 y 4.90024902 onepctCO2MEDIAN 3 0.014288058 y 0.16079999 >? >? > onepctCO2MEDIAN 4 0.022087920 y 6.63491326 onepctCO2MEDIAN 5 > 0.030797357 >? >? > y -1.24295056 onepctCO2MEDIAN 6 0.038451072 y 1.56433744 > onepctCO2MEDIAN >? >? > 7 0.048087904 y -2.26590352 onepctCO2MEDIAN 8 0.058677729 y 2.20700446 >? >? > onepctCO2MEDIAN 9 0.069261406 y -2.36770013 onepctCO2MEDIAN 10 >? >? > 0.080524530 y -1.09135062 onepctCO2MEDIAN 11 0.092760246 y 0.40999399 >? >? > onepctCO2MEDIAN 12 0.103789609 y -0.12597268 onepctCO2MEDIAN 13 >? >? > 0.116953168 y -2.41382534 onepctCO2MEDIAN 14 0.129253298 y 7.08902570 >? >? > onepctCO2MEDIAN 15 0.141710050 y -0.75935388 onepctCO2MEDIAN 16 >? >? > 0.156002052 y 0.04544160 onepctCO2MEDIAN 17 0.170648172 y -1.53496826 >? >? > onepctCO2MEDIAN 18 0.185318425 y 6.55242014 onepctCO2MEDIAN 19 >? >? > 0.199463055 y -0.83125628 onepctCO2MEDIAN 20 0.213513337 y -2.50991826 >? >? > onepctCO2MEDIAN 21 0.228839271 y 0.13659682 onepctCO2MEDIAN 22 >? >? > 0.246981293 y -1.37198445 onepctCO2MEDIAN 23 0.263012767 y -0.87129883 >? >? > onepctCO2MEDIAN 24 0.278505564 y 0.66325836 onepctCO2MEDIAN 25 >? >? > 0.293658361 y 0.79380363 onepctCO2MEDIAN 26 0.310747266 y 3.48806374 >? >? > onepctCO2MEDIAN 27 0.325990349 y -4.46122081 onepctCO2MEDIAN 28 >? >? > 0.342517540 y 0.08717340 onepctCO2MEDIAN 29 0.362751633 y -1.41715777 >? >? > onepctCO2MEDIAN 30 0.380199537 y -0.99565082 onepctCO2MEDIAN 31 >? >? > 0.394992948 y 0.32155262 onepctCO2MEDIAN 32 0.414373398 y 3.14038657 >? >? > onepctCO2MEDIAN 33 0.430690214 y -0.73760988 onepctCO2MEDIAN 34 >? >? > 0.449738145 y -2.48605407 onepctCO2MEDIAN 35 0.470167458 y -3.42358584 >? >? > onepctCO2MEDIAN 36 0.489019871 y 0.48247475 onepctCO2MEDIAN 37 >? >? > 0.507242471 y -0.97853863 onepctCO2MEDIAN 38 0.524314284 y 8.53596838 >? >? > onepctCO2MEDIAN 39 0.543750525 y 5.48447420 onepctCO2MEDIAN 40 >? >? > 0.564234197 y 3.21493666 onepctCO2MEDIAN 41 0.583679616 y 3.91689160 >? >? > onepctCO2MEDIAN 42 0.601459444 y 4.49070196 onepctCO2MEDIAN 43 >? >? > 0.619924664 y 6.54104103 onepctCO2MEDIAN 44 0.639932007 y 4.80686500 >? >? > onepctCO2MEDIAN 45 0.661347181 y 8.15101701 onepctCO2MEDIAN 46 >? >? > 0.684117317 y 0.26974132 onepctCO2MEDIAN 47 0.704829752 y -0.18075007 >? >? > onepctCO2MEDIAN 48 0.725045770 y 9.71812491 onepctCO2MEDIAN 49 >? >? > 0.745165825 y 1.54064657 onepctCO2MEDIAN 50 0.765016139 y -1.64760409 >? >? > onepctCO2MEDIAN 51 0.783461511 y 4.80246029 onepctCO2MEDIAN 52 >? >? > 0.806382924 y 4.04215160 onepctCO2MEDIAN 53 0.829241335 y 9.37565122 >? >? > onepctCO2MEDIAN 54 0.849924415 y 5.33050497 onepctCO2MEDIAN 55 >? >? > 0.871352434 y 7.54458026 onepctCO2MEDIAN 56 0.893632233 y 6.46795471 >? >? > onepctCO2MEDIAN 57 0.916052133 y 2.80960651 onepctCO2MEDIAN 58 >? >? > 0.938579470 y 5.39216613 onepctCO2MEDIAN 59 0.959907651 y 7.20436888 >? >? > onepctCO2MEDIAN 60 0.981643587 y 3.33508065 onepctCO2MEDIAN 61 >? >? > 1.004116774 y 8.86907070 onepctCO2MEDIAN 62 1.028363466 y 1.78612989 >? >? > onepctCO2MEDIAN 63 1.054009140 y 6.25550382 onepctCO2MEDIAN 64 >? >? > 1.072440803 y 7.60792365 onepctCO2MEDIAN 65 1.094457805 y 7.68714831 >? >? > onepctCO2MEDIAN 66 1.123176277 y 4.77877639 onepctCO2MEDIAN 67 >? >? > 1.149430871 y 12.71105018 onepctCO2MEDIAN 68 1.170912921 y -0.71562844 >? >? > onepctCO2MEDIAN 69 1.196743071 y 1.64908992 onepctCO2MEDIAN 70 >? >? > 1.218625903 y 3.03630241 onepctCO2MEDIAN 71 1.241868377 y 4.29747688 >? >? > onepctCO2MEDIAN 72 1.267941594 y 1.95437781 onepctCO2MEDIAN 73 >? >? > 1.290708780 y 3.99869637 onepctCO2MEDIAN 74 1.313222289 y 4.51794725 >? >? > onepctCO2MEDIAN 75 1.339045882 y 0.93379048 onepctCO2MEDIAN 76 >? >? > 1.362803459 y 3.30507700 onepctCO2MEDIAN 77 1.384450197 y 3.54229702 >? >? > onepctCO2MEDIAN 78 1.409720302 y 5.99736597 onepctCO2MEDIAN 79 >? >? > 1.435851157 y 0.50818686 onepctCO2MEDIAN 80 1.455592215 y 7.96616301 >? >? > onepctCO2MEDIAN 81 1.479495347 y 9.94604963 onepctCO2MEDIAN 82 >? >? > 1.506051958 y 3.79083717 onepctCO2MEDIAN 83 1.525728464 y 2.57358469 >? >? > onepctCO2MEDIAN 84 1.549362063 y 10.14049742 onepctCO2MEDIAN 85 >? >? > 1.573440671 y 13.74083036 onepctCO2MEDIAN 86 1.600278735 y 0.93357712 >? >? > onepctCO2MEDIAN 87 1.623879492 y 9.75887417 onepctCO2MEDIAN 88 >? >? > 1.650029302 y 1.27693947 onepctCO2MEDIAN 89 1.672362328 y 13.49709060 >? >? > onepctCO2MEDIAN 90 1.700221121 y 10.20875018 onepctCO2MEDIAN 91 >? >? > 1.724793375 y 1.68112753 onepctCO2MEDIAN 92 1.751070559 y 6.11789915 >? >? > onepctCO2MEDIAN 93 1.778022110 y -0.15676262 onepctCO2MEDIAN 94 >? >? > 1.803022087 y 3.82374792 onepctCO2MEDIAN 95 1.830668867 y 4.43314679 >? >? > onepctCO2MEDIAN 96 1.855736911 y 5.97907067 onepctCO2MEDIAN 97 >? >? > 1.882615030 y 11.31043325 onepctCO2MEDIAN 98 1.909218490 y 8.21426074 >? >? > onepctCO2MEDIAN 99 1.938130021 y 15.32096736 onepctCO2MEDIAN 100 >? >? > 1.963727593 y 5.81782169 onepctCO2MEDIAN 101 1.993271947 y 9.60049074 >? >? > onepctCO2MEDIAN 102 2.022548139 y 3.40636456 onepctCO2MEDIAN 103 >? >? > 2.050679922 y 4.73750104 onepctCO2MEDIAN 104 2.078064442 y 3.01330195 >? >? > onepctCO2MEDIAN 105 2.104113460 y 5.56595225 onepctCO2MEDIAN 106 >? >? > 2.133597612 y 12.03463325 onepctCO2MEDIAN 107 2.164026260 y > -0.40283200 >? >? > onepctCO2MEDIAN 108 2.194852829 y 10.59967795 onepctCO2MEDIAN 109 >? >? > 2.224257946 y 5.44795837 onepctCO2MEDIAN 110 2.252194643 y 4.70523736 >? >? > onepctCO2MEDIAN 111 2.277335048 y 14.09620189 onepctCO2MEDIAN 112 >? >? > 2.304058313 y 5.71490162 onepctCO2MEDIAN 113 2.330930233 y 3.77800721 >? >? > onepctCO2MEDIAN 114 2.357022762 y 4.41206201 onepctCO2MEDIAN 115 >? >? > 2.386489272 y 4.18660848 onepctCO2MEDIAN 116 2.417503953 y 6.90788020 >? >? > onepctCO2MEDIAN 117 2.448524356 y 2.78257393 onepctCO2MEDIAN 118 >? >? > 2.478698969 y 7.61717857 onepctCO2MEDIAN 119 2.510175705 y 10.24106026 >? >? > onepctCO2MEDIAN 120 2.539697886 y 8.18207107 onepctCO2MEDIAN 121 >? >? > 2.567915559 y 4.82754944 onepctCO2MEDIAN 122 2.597463250 y 19.16248829 >? >? > onepctCO2MEDIAN 123 2.627518773 y 16.06771094 onepctCO2MEDIAN 124 >? >? > 2.658759236 y 12.58970807 onepctCO2MEDIAN 125 2.692401528 y 9.29079880 >? >? > onepctCO2MEDIAN 126 2.721903205 y 7.42625020 onepctCO2MEDIAN 127 >? >? > 2.753021359 y 9.39025180 onepctCO2MEDIAN 128 2.786313415 y 12.61935503 >? >? > onepctCO2MEDIAN 129 2.819564104 y 11.11210397 onepctCO2MEDIAN 130 >? >? > 2.850823164 y 15.79070997 onepctCO2MEDIAN 131 2.880394101 y > 10.74252868 >? >? > onepctCO2MEDIAN 132 2.911391258 y 7.79714300 onepctCO2MEDIAN 133 >? >? > 2.942965150 y 8.80608578 onepctCO2MEDIAN 134 2.974468350 y 17.56062663 >? >? > onepctCO2MEDIAN 135 3.008983612 y 17.30886049 onepctCO2MEDIAN 136 >? >? > 3.040015221 y 13.45005435 onepctCO2MEDIAN 137 3.072668672 y > 14.63778842 >? >? > onepctCO2MEDIAN 138 3.105982423 y 8.07985518 onepctCO2MEDIAN 139 >? >? > 0.467429527 y -1.55704023 RCP4.5MEDIAN 140 0.478266196 y -3.19367515 >? >? > RCP4.5MEDIAN 141 0.489205229 y -2.44452679 RCP4.5MEDIAN 142 > 0.500039143 >? >? > y 0.87504367 RCP4.5MEDIAN 143 0.511021115 y -0.39185002 > RCP4.5MEDIAN 144 >? >? > 0.519874968 y -4.18935168 RCP4.5MEDIAN 145 0.528508358 y -3.64179524 >? >? > RCP4.5MEDIAN 146 0.537377594 y -2.58167128 RCP4.5MEDIAN 147 > 0.546194211 >? >? > y 2.20583694 RCP4.5MEDIAN 148 0.554720591 y -8.57764597 > RCP4.5MEDIAN 149 >? >? > 0.563289814 y 2.88442536 RCP4.5MEDIAN 150 0.572032790 y -3.90829882 >? >? > RCP4.5MEDIAN 151 0.580939066 y -3.39269048 RCP4.5MEDIAN 152 > 0.590921065 >? >? > y -4.60849867 RCP4.5MEDIAN 153 0.601575326 y -1.62572657 RCP4.5MEDIAN >? >? > 154 0.612425555 y 1.14198465 RCP4.5MEDIAN 155 0.623773319 y > -3.38454122 >? >? > RCP4.5MEDIAN 156 0.635363359 y 2.43414265 RCP4.5MEDIAN 157 > 0.646722666 y >? >? > 3.30007615 RCP4.5MEDIAN 158 0.658285673 y -0.79555442 RCP4.5MEDIAN 159 >? >? > 0.670250852 y -2.05220500 RCP4.5MEDIAN 160 0.681702690 y -5.56808946 >? >? > RCP4.5MEDIAN 161 0.693531145 y 2.24168605 RCP4.5MEDIAN 162 > 0.706016061 y >? >? > -4.83673351 RCP4.5MEDIAN 163 0.718231249 y 0.40086819 RCP4.5MEDIAN 164 >? >? > 0.730190911 y -1.98026992 RCP4.5MEDIAN 165 0.741269845 y 0.39963115 >? >? > RCP4.5MEDIAN 166 0.751000321 y -0.83241777 RCP4.5MEDIAN 167 > 0.760886972 >? >? > y -1.66101404 RCP4.5MEDIAN 168 0.771137164 y -1.05452982 RCP4.5MEDIAN >? >? > 169 0.781856383 y -1.18338156 RCP4.5MEDIAN 170 0.792607542 y > 0.22722653 >? >? > RCP4.5MEDIAN 171 0.803724128 y -1.90642564 RCP4.5MEDIAN 172 > 0.815066246 >? >? > y 0.75010550 RCP4.5MEDIAN 173 0.826027437 y -1.31108646 > RCP4.5MEDIAN 174 >? >? > 0.836766732 y 1.05961515 RCP4.5MEDIAN 175 0.847553312 y -2.06588010 >? >? > RCP4.5MEDIAN 176 0.858331452 y 8.53403315 RCP4.5MEDIAN 177 > 0.869154422 y >? >? > 0.09979751 RCP4.5MEDIAN 178 0.879572539 y -2.50854353 RCP4.5MEDIAN 179 >? >? > 0.889426601 y 5.29550783 RCP4.5MEDIAN 180 0.899009805 y 2.02909481 >? >? > RCP4.5MEDIAN 181 0.908289566 y 2.66922982 RCP4.5MEDIAN 182 > 0.917284978 y >? >? > -4.17757196 RCP4.5MEDIAN 183 0.926128960 y 3.40202916 RCP4.5MEDIAN 184 >? >? > 0.934752874 y -1.92292218 RCP4.5MEDIAN 185 0.943010943 y 6.36969150 >? >? > RCP4.5MEDIAN 186 0.950999217 y 1.86490308 RCP4.5MEDIAN 187 > 0.958795701 y >? >? > 8.32126161 RCP4.5MEDIAN 188 0.966310396 y 10.15048356 RCP4.5MEDIAN 189 >? >? > 0.973635493 y 6.68925964 RCP4.5MEDIAN 190 0.980834088 y -1.01615369 >? >? > RCP4.5MEDIAN 191 0.987694790 y 0.20892853 RCP4.5MEDIAN 192 > 0.994548581 y >? >? > -1.52787222 RCP4.5MEDIAN 193 1.001274595 y -0.72374597 > RCP4.5MEDIAN 194 >? >? > 1.007810612 y 2.26062309 RCP4.5MEDIAN 195 1.014270389 y -2.40270340 >? >? > RCP4.5MEDIAN 196 1.022719711 y -1.94548262 RCP4.5MEDIAN 197 > 1.032070810 >? >? > y -1.13053235 RCP4.5MEDIAN 198 1.041118812 y 0.56107969 > RCP4.5MEDIAN 199 >? >? > 1.050189571 y 3.27941835 RCP4.5MEDIAN 200 1.059380475 y 3.01333588 >? >? > RCP4.5MEDIAN 201 1.067877585 y 4.87457336 RCP4.5MEDIAN 202 > 1.076078766 y >? >? > 1.02457895 RCP4.5MEDIAN 203 1.084707357 y 4.49174869 RCP4.5MEDIAN 204 >? >? > 1.093223180 y 8.24629303 RCP4.5MEDIAN 205 1.101414382 y -0.03364132 >? >? > RCP4.5MEDIAN 206 1.108886304 y 9.12509848 RCP4.5MEDIAN 207 > 1.115482896 y >? >? > 1.74254621 RCP4.5MEDIAN 208 1.121856558 y 2.27004536 RCP4.5MEDIAN 209 >? >? > 1.127809421 y -0.65627179 RCP4.5MEDIAN 210 1.133265961 y 12.02566969 >? >? > RCP4.5MEDIAN 211 1.138549712 y -1.04260843 RCP4.5MEDIAN 212 > 1.143910237 >? >? > y -6.47611327 RCP4.5MEDIAN 213 1.149437787 y 8.88410567 > RCP4.5MEDIAN 214 >? >? > 1.154488347 y -4.24916247 RCP4.5MEDIAN 215 1.159872903 y 7.90741918 >? >? > RCP4.5MEDIAN 216 1.165477487 y -3.91386711 RCP4.5MEDIAN 217 > 1.171103424 >? >? > y 1.02370701 RCP4.5MEDIAN 218 1.177498256 y -3.71206616 > RCP4.5MEDIAN 219 >? >? > 1.184003888 y -1.05694182 RCP4.5MEDIAN 220 1.190395856 y 1.10501459 >? >? > RCP4.5MEDIAN 221 1.197284280 y 2.67668639 RCP4.5MEDIAN 222 > 1.204590551 y >? >? > 2.21693031 RCP4.5MEDIAN 223 1.210807614 y 2.90252830 RCP4.5MEDIAN 224 >? >? > 1.216470664 y 2.75093766 RCP4.5MEDIAN 225 1.221914148 y -0.73815245 >? >? > RCP4.5MEDIAN 226 1.227580480 y 3.58554626 RCP4.5MEDIAN 227 > 1.233317788 y >? >? > 10.89961658 RCP4.5MEDIAN 228 1.238093406 y 3.23374387 RCP4.5MEDIAN 229 >? >? > 0.466622908 y -1.92366466 RCP8.5MEDIAN 230 0.474211509 y 4.09292949 >? >? > RCP8.5MEDIAN 231 0.480383051 y -0.84736312 RCP8.5MEDIAN 232 > 0.486304903 >? >? > y -0.80597889 RCP8.5MEDIAN 233 0.492151615 y -0.50244413 RCP8.5MEDIAN >? >? > 234 0.499312643 y 3.07785701 RCP8.5MEDIAN 235 0.508859905 y > -6.15175322 >? >? > RCP8.5MEDIAN 236 0.518758845 y -0.51590144 RCP8.5MEDIAN 237 > 0.528675758 >? >? > y 3.33135956 RCP8.5MEDIAN 238 0.538928423 y 2.62280891 > RCP8.5MEDIAN 239 >? >? > 0.549621221 y -6.90096009 RCP8.5MEDIAN 240 0.560062840 y -3.45706029 >? >? > RCP8.5MEDIAN 241 0.570860791 y 1.36192518 RCP8.5MEDIAN 242 > 0.581923368 y >? >? > 0.34822359 RCP8.5MEDIAN 243 0.592628298 y 3.06882935 RCP8.5MEDIAN 244 >? >? > 0.604230648 y -3.56142825 RCP8.5MEDIAN 245 0.615975167 y 10.35932554 >? >? > RCP8.5MEDIAN 246 0.627448279 y 10.21751629 RCP8.5MEDIAN 247 > 0.639401050 >? >? > y 3.31040335 RCP8.5MEDIAN 248 0.651949591 y -0.53558775 > RCP8.5MEDIAN 249 >? >? > 0.664634427 y 2.66081860 RCP8.5MEDIAN 250 0.677343552 y 3.21379656 >? >? > RCP8.5MEDIAN Maybe something like this? >? >? > >? >? > lusher<-ggplot(NewestdataULTRA) + >? >? > geom_jitter(aes(x,value,onepctCO2MEDIAN=L1), colour="green") + >? >? > geom_smooth(aes(x, value, onepctCO2MEDIAN=L1), method=lm) + >? >? > geom_jitter(aes(x, value, RCP8.5MEDIAN=L1), colour="red")**//___^ >? >? > **//___^ >? >? > I receive this warning, however: >? >? > >? >? > Warning:Ignoring unknown aesthetics: onepctCO2MEDIAN Warning:Ignoring >? >? > unknown aesthetics: onepctCO2MEDIAN >? >? > >? >? > **//___^ >? >? > Perhaps I am not assigning the columns properly? Essentially, I just >? >? > want create two scatter plots and two regression lines for these two >? >? > objects. >? >? > >? >? > Once again, any assistance would be greatly appreciated! >? >? > >? >? > -----Original Message----- >? >? > From: Rui Barradas <ruipbarradas at sapo.pt > <mailto:ruipbarradas at sapo.pt> <mailto:ruipbarradas at sapo.pt > <mailto:ruipbarradas at sapo.pt>>> >? >? > To: rain1290 <rain1290 at aim.com <mailto:rain1290 at aim.com> > <mailto:rain1290 at aim.com <mailto:rain1290 at aim.com>>>; r-help >? > <r-help at R-project.org <mailto:r-help at R-project.org> > <mailto:r-help at R-project.org <mailto:r-help at R-project.org>>>; >? >? > r-sig-geo <r-sig-geo at r-project.org > <mailto:r-sig-geo at r-project.org> <mailto:r-sig-geo at r-project.org > <mailto:r-sig-geo at r-project.org>>> >? >? > Sent: Wed, Jun 5, 2019 10:52 am >? >? > Subject: Re: [R] Plotting more than one regression line in ggplot >? >? > >? >? > Hello, >? >? > >? >? > This is pretty basic ggplot. >? >? > >? >? > >? >? > lm1 <- ggplot(onepctCO2MEDIAN, aes(x, y)) + >? >? >? ? geom_point(colour = 'blue') + >? >? >? ? geom_smooth(method = 'lm') >? >? > >? >? > lm1 >? >? > >? >? > >? >? > If you want to combine several datasets, you will have to have a >? >? > variable telling which dataset is which. In the example below, this is >? >? > column 'id'. >? >? > >? >? > >? >? > onepctCO2MEDIAN2 <- onepctCO2MEDIAN >? >? > onepctCO2MEDIAN2$y <- jitter(onepctCO2MEDIAN2$y) + 2 >? >? > onepctCO2MEDIAN$id <- 1 >? >? > onepctCO2MEDIAN2$id <- 2 >? >? > df2 <- rbind(onepctCO2MEDIAN, onepctCO2MEDIAN2) >? >? > >? >? > ggplot(df2, aes(x, y, group = id, colour = factor(id))) + >? >? >? ? geom_point() + >? >? >? ? geom_smooth(method = 'lm') >? >? > >? >? > >? >? > Hope this helps, >? >? > >? >? > Rui Barradas >? >? > >? >? > ?s 15:21 de 05/06/19, rain1290--- via R-help escreveu: >? >? >? > I am trying to plot, using ggplot, a series of scatter plots with >? >? > regression lines for several datasets. I started with the following >? >? > dataset, "onepectCO2MEDIAN". The data for this dataset is as follows: >? >? >? >? ??? onepctCO2MEDIAN >? >? >? >? ??????????????????? x????????? y >? >? >? >? ??? layer.1?? 0.000000000? 0.0000000 >? >? >? >? ??? layer.2?? 0.006794447? 4.9002490 >? >? >? >? ??? layer.3?? 0.014288058? 0.1608000 >? >? >? >? ??? layer.4?? 0.022087920? 6.6349133 >? >? >? >? ??? layer.5?? 0.030797357 -1.2429506 >? >? >? >? ??? layer.6?? 0.038451072? 1.5643374 >? >? >? >? ??? layer.7?? 0.048087904 -2.2659035 >? >? >? >? ??? layer.8?? 0.058677729? 2.2070045 >? >? >? >? ??? layer.9?? 0.069261406 -2.3677001 >? >? >? >? ??? layer.10? 0.080524530 -1.0913506 >? >? >? >? ??? layer.11? 0.092760246? 0.4099940 >? >? >? >? ??? layer.12? 0.103789609 -0.1259727 >? >? >? >? ??? layer.13? 0.116953168 -2.4138253 >? >? >? >? ??? layer.14? 0.129253298? 7.0890257 >? >? >? >? ??? layer.15? 0.141710050 -0.7593539 >? >? >? >? ??? layer.16? 0.156002052? 0.0454416 >? >? >? >? ??? layer.17? 0.170648172 -1.5349683 >? >? >? >? ??? layer.18? 0.185318425? 6.5524201 >? >? >? >? ??? layer.19? 0.199463055 -0.8312563 >? >? >? >? ??? layer.20? 0.213513337 -2.5099183 >? >? >? >? ??? layer.21? 0.228839271? 0.1365968 >? >? >? >? ??? layer.22? 0.246981293 -1.3719845 >? >? >? >? ??? layer.23? 0.263012767 -0.8712988 >? >? >? >? ??? layer.24? 0.278505564? 0.6632584 >? >? >? >? ??? layer.25? 0.293658361? 0.7938036 >? >? >? >? ??? layer.26? 0.310747266? 3.4880637 >? >? >? >? ??? layer.27? 0.325990349 -4.4612208 >? >? >? >? ??? layer.28? 0.342517540? 0.0871734 >? >? >? >? ??? layer.29? 0.362751633 -1.4171578 >? >? >? >? ??? layer.30? 0.380199537 -0.9956508 >? >? >? >? ??? layer.31? 0.394992948? 0.3215526 >? >? >? >? ??? layer.32? 0.414373398? 3.1403866 >? >? >? >? ??? layer.33? 0.430690214 -0.7376099 >? >? >? >? ??? layer.34? 0.449738145 -2.4860541 >? >? >? >? ??? layer.35? 0.470167458 -3.4235858 >? >? >? >? ??? layer.36? 0.489019871? 0.4824748 >? >? >? >? ??? layer.37? 0.507242471 -0.9785386 >? >? >? >? ??? layer.38? 0.524314284? 8.5359684 >? >? >? >? ??? layer.39? 0.543750525? 5.4844742 >? >? >? >? ??? layer.40? 0.564234197? 3.2149367 >? >? >? >? ??? layer.41? 0.583679616? 3.9168916 >? >? >? >? ??? layer.42? 0.601459444? 4.4907020 >? >? >? >? ??? layer.43? 0.619924664? 6.5410410 >? >? >? >? ??? layer.44? 0.639932007? 4.8068650 >? >? >? >? ??? layer.45? 0.661347181? 8.1510170 >? >? >? >? ??? layer.46? 0.684117317? 0.2697413 >? >? >? >? ??? layer.47? 0.704829752 -0.1807501 >? >? >? >? ??? layer.48? 0.725045770? 9.7181249 >? >? >? >? ??? layer.49? 0.745165825? 1.5406466 >? >? >? >? ??? layer.50? 0.765016139 -1.6476041 >? >? >? >? ??? layer.51? 0.783461511? 4.8024603 >? >? >? >? ??? layer.52? 0.806382924? 4.0421516 >? >? >? >? ??? layer.53? 0.829241335? 9.3756512 >? >? >? >? ??? layer.54? 0.849924415? 5.3305050 >? >? >? >? ??? layer.55? 0.871352434? 7.5445803 >? >? >? >? ??? layer.56? 0.893632233? 6.4679547 >? >? >? >? ??? layer.57? 0.916052133? 2.8096065 >? >? >? >? ??? layer.58? 0.938579470? 5.3921661 >? >? >? >? ??? layer.59? 0.959907651? 7.2043689 >? >? >? >? ??? layer.60? 0.981643587? 3.3350806 >? >? >? >? ??? layer.61? 1.004116774? 8.8690707 >? >? >? >? ??? layer.62? 1.028363466? 1.7861299 >? >? >? >? ??? layer.63? 1.054009140? 6.2555038 >? >? >? >? ??? layer.64? 1.072440803? 7.6079236 >? >? >? >? ??? layer.65? 1.094457805? 7.6871483 >? >? >? >? ??? layer.66? 1.123176277? 4.7787764 >? >? >? >? ??? layer.67? 1.149430871 12.7110502 >? >? >? >? ??? layer.68? 1.170912921 -0.7156284 >? >? >? >? ??? layer.69? 1.196743071? 1.6490899 >? >? >? >? ??? layer.70? 1.218625903? 3.0363024 >? >? >? >? ??? layer.71? 1.241868377? 4.2974769 >? >? >? >? ??? layer.72? 1.267941594? 1.9543778 >? >? >? >? ??? layer.73? 1.290708780? 3.9986964 >? >? >? >? ??? layer.74? 1.313222289? 4.5179472 >? >? >? >? ??? layer.75? 1.339045882? 0.9337905 >? >? >? >? ??? layer.76? 1.362803459? 3.3050770 >? >? >? >? ??? layer.77? 1.384450197? 3.5422970 >? >? >? >? ??? layer.78? 1.409720302? 5.9973660 >? >? >? >? ??? layer.79? 1.435851157? 0.5081869 >? >? >? >? ??? layer.80? 1.455592215? 7.9661630 >? >? >? >? ??? layer.81? 1.479495347? 9.9460496 >? >? >? >? ??? layer.82? 1.506051958? 3.7908372 >? >? >? >? ??? layer.83? 1.525728464? 2.5735847 >? >? >? >? ??? layer.84? 1.549362063 10.1404974 >? >? >? >? ??? layer.85? 1.573440671 13.7408304 >? >? >? >? ??? layer.86? 1.600278735? 0.9335771 >? >? >? >? ??? layer.87? 1.623879492? 9.7588742 >? >? >? >? ??? layer.88? 1.650029302? 1.2769395 >? >? >? >? ??? layer.89? 1.672362328 13.4970906 >? >? >? >? ??? layer.90? 1.700221121 10.2087502 >? >? >? >? ??? layer.91? 1.724793375? 1.6811275 >? >? >? >? ??? layer.92? 1.751070559? 6.1178992 >? >? >? >? ??? layer.93? 1.778022110 -0.1567626 >? >? >? >? ??? layer.94? 1.803022087? 3.8237479 >? >? >? >? ??? layer.95? 1.830668867? 4.4331468 >? >? >? >? ??? layer.96? 1.855736911? 5.9790707 >? >? >? >? ??? layer.97? 1.882615030 11.3104333 >? >? >? >? ??? layer.98? 1.909218490? 8.2142607 >? >? >? >? ??? layer.99? 1.938130021 15.3209674 >? >? >? >? ??? layer.100 1.963727593? 5.8178217 >? >? >? >? ??? layer.101 1.993271947? 9.6004907 >? >? >? >? ??? layer.102 2.022548139? 3.4063646 >? >? >? >? ??? layer.103 2.050679922? 4.7375010 >? >? >? >? ??? layer.104 2.078064442? 3.0133019 >? >? >? >? ??? layer.105 2.104113460? 5.5659522 >? >? >? >? ??? layer.106 2.133597612 12.0346333 >? >? >? >? ??? layer.107 2.164026260 -0.4028320 >? >? >? >? ??? layer.108 2.194852829 10.5996780 >? >? >? >? ??? layer.109 2.224257946? 5.4479584 >? >? >? >? ??? layer.110 2.252194643? 4.7052374 >? >? >? >? ??? layer.111 2.277335048 14.0962019 >? >? >? >? ??? layer.112 2.304058313? 5.7149016 >? >? >? >? ??? layer.113 2.330930233? 3.7780072 >? >? >? >? ??? layer.114 2.357022762? 4.4120620 >? >? >? >? ??? layer.115 2.386489272? 4.1866085 >? >? >? >? ??? layer.116 2.417503953? 6.9078802 >? >? >? >? ??? layer.117 2.448524356? 2.7825739 >? >? >? >? ??? layer.118 2.478698969? 7.6171786 >? >? >? >? ??? layer.119 2.510175705 10.2410603 >? >? >? >? ??? layer.120 2.539697886? 8.1820711 >? >? >? >? ??? layer.121 2.567915559? 4.8275494 >? >? >? >? ??? layer.122 2.597463250 19.1624883 >? >? >? >? ??? layer.123 2.627518773 16.0677109 >? >? >? >? ??? layer.124 2.658759236 12.5897081 >? >? >? >? ??? layer.125 2.692401528? 9.2907988 >? >? >? >? ??? layer.126 2.721903205? 7.4262502 >? >? >? >? ??? layer.127 2.753021359? 9.3902518 >? >? >? >? ??? layer.128 2.786313415 12.6193550 >? >? >? >? ??? layer.129 2.819564104 11.1121040 >? >? >? >? ??? layer.130 2.850823164 15.7907100 >? >? >? >? ??? layer.131 2.880394101 10.7425287 >? >? >? >? ??? layer.132 2.911391258? 7.7971430 >? >? >? >? ??? layer.133 2.942965150? 8.8060858 >? >? >? >? ??? layer.134 2.974468350 17.5606266 >? >? >? >? ??? layer.135 3.008983612 17.3088605 >? >? >? >? ??? layer.136 3.040015221 13.4500543 >? >? >? >? ??? layer.137 3.072668672 14.6377884 >? >? >? >? ??? layer.138 3.105982423? 8.0798552dput(onepctCO2MEDIAN) >? >? > dput(onepctCO2MEDIAN) >? >? >? >? ??? structure(list(x = c(0, 0.00679444684647024, > 0.014288058038801, >? >? >? >? ??? 0.0220879195258021, >? >? > 0.0307973567396402,0.0384510718286037,0.0480879042297602, >? >? >? >? ??? 0.0586777292191982, 0.0692614056169987, >? >? > 0.080524530261755,0.0927602462470531, >? >? >? >? ??? 0.103789608925581, 0.116953168064356, 0.129253298044205, >? >? > 0.141710050404072, >? >? >? >? ??? 0.156002052128315, 0.170648172497749, 0.185318425297737, >? >? > 0.199463054537773, >? >? >? >? ??? 0.21351333707571, 0.22883927077055, 0.246981292963028, >? >? > 0.263012766838074, >? >? >? >? ??? 0.278505563735962, 0.29365836083889, 0.310747265815735, >? >? > 0.325990349054337, >? >? >? >? ??? 0.342517539858818, 0.362751632928848, 0.380199536681175, >? >? > 0.39499294757843, >? >? >? >? ??? 0.414373397827148, 0.430690214037895, 0.449738144874573, >? >? > 0.470167458057404, >? >? >? >? ??? 0.489019870758057, 0.507242470979691, 0.524314284324646, >? >? > 0.543750524520874, >? >? >? >? ??? 0.56423419713974, 0.583679616451263, 0.601459443569183, >? >? > 0.619924664497375, >? >? >? >? ??? 0.639932006597519, 0.661347180604935, 0.684117317199707, >? >? > 0.704829752445221, >? >? >? >? ??? 0.725045770406723, 0.745165824890137, 0.765016138553619, >? >? > 0.783461511135101, >? >? >? >? ??? 0.806382924318314, 0.829241335391998, 0.84992441534996, >? >? > 0.871352434158325, >? >? >? >? ??? 0.893632233142853, 0.916052132844925, 0.938579469919205, >? >? > 0.959907650947571, >? >? >? >? ??? 0.981643587350845, 1.00411677360535, 1.02836346626282, >? >? > 1.05400913953781, >? >? >? >? ??? 1.07244080305099, 1.09445780515671, 1.12317627668381, >? >? > 1.14943087100983, >? >? >? >? ??? 1.17091292142868, 1.19674307107925, 1.21862590312958, >? >? > 1.24186837673187, >? >? >? >? ??? 1.26794159412384, 1.2907087802887, 1.31322228908539, >? >? > 1.33904588222504, >? >? >? >? ??? 1.36280345916748, 1.38445019721985, 1.40972030162811, >? >? > 1.43585115671158, >? >? >? >? ??? 1.45559221506119, 1.47949534654617, 1.50605195760727, >? >? > 1.52572846412659, >? >? >? >? ??? 1.5493620634079, 1.5734406709671, 1.60027873516083, >? >? > 1.62387949228287, >? >? >? >? ??? 1.65002930164337, 1.67236232757568, 1.70022112131119, >? >? > 1.72479337453842, >? >? >? >? ??? 1.75107055902481, 1.77802211046219, 1.80302208662033, >? >? > 1.83066886663437, >? >? >? >? ??? 1.85573691129684, 1.88261502981186, 1.90921849012375, >? >? > 1.93813002109528, >? >? >? >? ??? 1.96372759342194, 1.99327194690704, 2.02254813909531, >? >? > 2.05067992210388, >? >? >? >? ??? 2.07806444168091, 2.1041134595871, 2.13359761238098, >? >? > 2.16402626037598, >? >? >? >? ??? 2.19485282897949, 2.2242579460144, 2.25219464302063, >? >? > 2.27733504772186, >? >? >? >? ??? 2.30405831336975, 2.33093023300171, 2.35702276229858, >? >? > 2.38648927211761, >? >? >? >? ??? 2.41750395298004, 2.44852435588837, 2.47869896888733, >? >? > 2.51017570495605, >? >? >? >? ??? 2.53969788551331, 2.567915558815, 2.59746325016022, >? >? > 2.62751877307892, >? >? >? >? ??? 2.65875923633575, 2.69240152835846, 2.72190320491791, >? >? > 2.75302135944366, >? >? >? >? ??? 2.78631341457367, 2.8195641040802, 2.85082316398621, >? >? > 2.88039410114288, >? >? >? >? ??? 2.91139125823975, 2.94296514987946, 2.97446835041046, >? >? > 3.00898361206055, >? >? >? >? ??? 3.04001522064209, 3.07266867160797, 3.10598242282867), y = > c(0, >? >? >? >? ??? 4.90024901723162, 0.160799993152722, 6.63491326258641, >? >? > -1.24295055804536, >? >? >? >? ??? 1.56433744259162, -2.26590352245208, 2.20700446463354, >? >? > -2.36770012911069, >? >? >? >? ??? -1.09135061899174, 0.409993989292701, -0.125972681525582, >? >? > -2.41382533818026, >? >? >? >? ??? 7.08902570153028, -0.759353880417294, 0.0454415959640926, >? >? > -1.53496826259972, >? >? >? >? ??? 6.55242014096194, -0.831256280861552, -2.50991825629084, >? >? > 0.136596820654013, >? >? >? >? ??? -1.37198445498419, -0.871298832596736, 0.663258363762466, >? >? > 0.793803634291308, >? >? >? >? ??? 3.48806373666998, -4.46122081238949, 0.0871733966938564, >? >? > -1.41715777257774, >? >? >? >? ??? -0.995650815648318, 0.32155262317503, 3.14038657369241, >? >? > -0.737609879885404, >? >? >? >? ??? -2.48605406511292, -3.423585843908, 0.482474753780281, >? >? > -0.978538630093809, >? >? >? >? ??? 8.53596837794201, 5.48447420320695, 3.21493665820644, >? >? > 3.91689160157513, >? >? >? >? ??? 4.49070195980797, 6.54104103157039, 4.80686500146557, >? >? > 8.15101701282067, >? >? >? >? ??? 0.26974132191657, -0.180750068063062, 9.71812491230244, >? >? > 1.54064657400204, >? >? >? >? ??? -1.64760408795688, 4.80246028991894, 4.04215159914344, >? >? > 9.37565121768513, >? >? >? >? ??? 5.33050496938428, 7.54458026088508, 6.46795470819342, >? >? > 2.80960651433971, >? >? >? >? ??? 5.39216613235986, 7.20436888038562, 3.3350806460997, >? >? > 8.86907069895943, >? >? >? >? ??? 1.78612988613659, 6.25550382050395, 7.60792364896564, >? >? > 7.68714830528144, >? >? >? >? ??? 4.77877638957615, 12.7110501777314, -0.715628443181046, >? >? > 1.64908991824022, >? >? >? >? ??? 3.03630240714679, 4.29747688442346, 1.95437780501881, >? >? > 3.99869636910933, >? >? >? >? ??? 4.51794724689848, 0.933790484492299, 3.30507700050003, >? >? > 3.5422970157433, >? >? >? >? ??? 5.99736597322524, 0.508186860060022, 7.96616300581067, >? >? > 9.94604963036295, >? >? >? >? ??? 3.79083717222623, 2.57358468532258, 10.1404974171776, >? >? > 13.7408303595752, >? >? >? >? ??? 0.933577123801399, 9.75887417074129, 1.27693947132921, >? >? > 13.4970905965787, >? >? >? >? ??? 10.2087501765735, 1.68112753028756, 6.1178991508927, >? >? > -0.156762622680077, >? >? >? >? ??? 3.82374791691426, 4.43314678736265, 5.97907067167507, >? >? > 11.3104332518482, >? >? >? >? ??? 8.21426074201525, 15.320967360602, 5.81782169471483, >? >? > 9.6004907412354, >? >? >? >? ??? 3.40636455909704, 4.73750103921864, 3.0133019468806, >? >? > 5.56595224859066, >? >? >? >? ??? 12.0346332527215, -0.40283199827104, 10.5996779538754, >? >? > 5.44795836991128, >? >? >? >? ??? 4.70523736412729, 14.096201892183, 5.71490161813391, >? >? > 3.77800720810782, >? >? >? >? ??? 4.41206200639436, 4.18660847858423, 6.90788020044911, >? >? > 2.78257393345915, >? >? >? >? ??? 7.61717857379431, 10.2410602647684, 8.18207106836167, >? >? > 4.82754943871433, >? >? >? >? ??? 19.1624882857155, 16.0677109398509, 12.589708067017, >? >? > 9.29079879799404, >? >? >? >? ??? 7.42625019725314, 9.39025179806185, 12.6193550331438, >? >? > 11.1121039747257, >? >? >? >? ??? 15.7907099734986, 10.7425286789233, 7.79714300307344, >? >? > 8.80608578166101, >? >? >? >? ??? 17.5606266346039, 17.3088604929222, 13.4500543478523, >? >? > 14.6377884248645, >? >? >? >? ??? 8.07985518296064)), class = "data.frame", row.names >? > c("layer.1", >? >? >? >? ??? "layer.2", "layer.3", "layer.4", "layer.5", "layer.6", > "layer.7", >? >? >? >? ??? "layer.8", "layer.9", "layer.10", "layer.11", "layer.12", >? >? > "layer.13", >? >? >? >? ??? "layer.14", "layer.15", "layer.16", "layer.17", "layer.18", >? >? > "layer.19", >? >? >? >? ??? "layer.20", "layer.21", "layer.22", "layer.23", "layer.24", >? >? > "layer.25", >? >? >? >? ??? "layer.26", "layer.27", "layer.28", "layer.29", "layer.30", >? >? > "layer.31", >? >? >? >? ??? "layer.32", "layer.33", "layer.34", "layer.35", "layer.36", >? >? > "layer.37", >? >? >? >? ??? "layer.38", "layer.39", "layer.40", "layer.41", "layer.42", >? >? > "layer.43", >? >? >? >? ??? "layer.44", "layer.45", "layer.46", "layer.47", "layer.48", >? >? > "layer.49", >? >? >? >? ??? "layer.50", "layer.51", "layer.52", "layer.53", "layer.54", >? >? > "layer.55", >? >? >? >? ??? "layer.56", "layer.57", "layer.58", "layer.59", "layer.60", >? >? > "layer.61", >? >? >? >? ??? "layer.62", "layer.63", "layer.64", "layer.65", "layer.66", >? >? > "layer.67", >? >? >? >? ??? "layer.68", "layer.69", "layer.70", "layer.71", "layer.72", >? >? > "layer.73", >? >? >? >? ??? "layer.74", "layer.75", "layer.76", "layer.77", "layer.78", >? >? > "layer.79", >? >? >? >? ??? "layer.80", "layer.81", "layer.82", "layer.83", "layer.84", >? >? > "layer.85", >? >? >? >? ??? "layer.86", "layer.87", "layer.88", "layer.89", "layer.90", >? >? > "layer.91", >? >? >? >? ??? "layer.92", "layer.93", "layer.94", "layer.95", "layer.96", >? >? > "layer.97", >? >? >? >? ??? "layer.98", "layer.99", "layer.100", "layer.101", "layer.102", >? >? >? >? ??? "layer.103", "layer.104", "layer.105", "layer.106", > "layer.107", >? >? >? >? ??? "layer.108", "layer.109", "layer.110", "layer.111", > "layer.112", >? >? >? >? ??? "layer.113", "layer.114", "layer.115", "layer.116", > "layer.117", >? >? >? >? ??? "layer.118", "layer.119", "layer.120", "layer.121", > "layer.122", >? >? >? >? ??? "layer.123", "layer.124", "layer.125", "layer.126", > "layer.127", >? >? >? >? ??? "layer.128", "layer.129", "layer.130", "layer.131", > "layer.132", >? >? >? >? ??? "layer.133", "layer.134", "layer.135", "layer.136", > "layer.137", >? >? >? >? ??? "layer.138")) >? >? >? > I started with the following to generate the first regression line >? >? > and scatter plot:??? lm<-ggplot(onepctCO2MEDIAN) + >? >? >? >? ??? geom_jitter(aes(RCP1pctCO2cumulativeMedian[1:138], > departurea), >? >? >? >? ??? colour="blue") + >? > geom_smooth(aes(RCP1pctCO2cumulativeMedian[1:138], >? >? >? >? ??? departurea), method=lm) >? >? >? > But I receive this error:? ??Warning message: >? >? >? >? ??? Computation failed in `stat_smooth()`: >? >? >? >? ??? 'what' must be a function or character string >? >? >? > A blue scatter plot is successfully generated, but the problem is >? >? > that the regression line does not appear, presumably related to the >? >? > above warning. >? >? >? > Is there a reason for this? I would appreciate any assistance! >? >? >? > ??? [[alternative HTML version deleted]] >? >? > >? >? >? > >? >? >? > ______________________________________________ >? >? >? > R-help at r-project.org <mailto:R-help at r-project.org> > <mailto:R-help at r-project.org <mailto:R-help at r-project.org>> mailing list -- >? > To UNSUBSCRIBE and more, see >? >? >? > https://stat.ethz.ch/mailman/listinfo/r-help >? >? >? > PLEASE do read the posting guide >? >? > http://www.R-project.org/posting-guide.html >? >? >? > and provide commented, minimal, self-contained, reproducible code. >? >? > >? >? >? >[[alternative HTML version deleted]]