[R] Drawing a vertical line
Gregory Coats
gregco@t@ @end|ng |rom me@com
Mon Jun 27 04:29:09 CEST 2022
Super! Thanks! Greg
> On Jun 26, 2022, at 7:41 PM, Jeff Newmiller <jdnewmil using dcn.davis.ca.us> wrote:
>
> Because the integer 2020 is not a date.
>
> abline(v=as.Date("2020-01-01"), col="green")
>
> On June 26, 2022 4:31:42 PM PDT, Gregory Coats via R-help <r-help using r-project.org> wrote:
>> I understand how to use grid to draw chocolate colored dashed horizontal lines.
>> I understand how to use abline to draw a solid red horizontal line.
>> I do not understand why using abline, R refuses to draw a solid vertical green line.
>> grid (nx = NA, ny = NULL, lty=4, lwd=1, col="chocolate")
>> abline(h=1750, col="red")
>> abline(v=2020, col="green”)
>> Greg Coats
>> dta <- read.table( text =
>> "Year Mon Day Cost kwhr kwhr2 Days text
>> 2016 5 16 97.89 786 kwhr 29 days
>> 2016 6 15 120.67 969 kwhr 32 days
>> 2016 7 15 132.89 1087 kwhr 30 days
>> 2016 8 15 146.51 1215 kwhr 29 days
>> 2016 9 14 149.88 1241 kwhr 32 days
>> 2016 10 13 91.12 737 kwhr 29 days
>> 2016 11 14 95.23 775 kwhr 29 days
>> 2016 12 14 142.34 1292 kwhr 33 days
>> 2017 1 17 162.85 1519 kwhr 31 days
>> 2017 2 15 150.71 1385 kwhr 32 days
>> 2017 3 16 132.75 1186 kwhr 29 days
>> 2017 4 17 112.22 951 kwhr 29 days
>> 2017 5 16 90.62 722 kwhr 32 days
>> 2017 6 15 101.26 817 kwhr 30 days
>> 2017 7 17 125.55 1004 kwhr 30 days
>> 2017 8 15 124.38 978 kwhr 31 days
>> 2017 9 14 97.22 762 kwhr 30 days
>> 2017 10 13 87.52 683 kwhr 29 days
>> 2017 11 14 99.64 791 kwhr 32 days
>> 2017 12 14 137.18 1190 kwhr 30 days
>> 2018 1 16 221.46 2086 kwhr 30 days
>> 2018 2 14 285.58 2763 kwhr 32 days
>> 2018 3 15 144.84 1266 kwhr 28 days
>> 2018 4 16 148.56 1314 kwhr 31 days
>> 2018 5 15 102.17 826 kwhr 31 days
>> 2018 6 14 113.60 914 kwhr 30 days
>> 2018 7 16 125.16 1217 kwhr 30 days
>> 2018 8 14 160.51 1295 kwhr 31 days
>> 2018 9 13 131.77 1060 kwhr 30 days
>> 2018 10 12 103.72 840 kwhr 29 days
>> 2018 11 13 97.15 776 kwhr 29 days
>> 2018 12 13 177.43 1628 kwhr 33 days
>> 2019 1 15 162.35 1623 kwhr 33 days
>> 2019 2 14 279.97 2649 kwhr 30 days
>> 2019 3 15 223.43 2046 kwhr 29 days
>> 2019 4 15 104.24 821 kwhr 29 days
>> 2019 5 15 82.61 632 kwhr 32 days
>> 2019 6 14 63.28 836 kwhr 30 days
>> 2019 7 16 127.36 1018 kwhr 32 days
>> 2019 8 14 126.32 1024 kwhr 29 days
>> 2019 9 13 111.41 880 kwhr 30 days
>> 2019 10 14 88.60 662 kwhr 29 days
>> 2019 11 13 104.08 788 kwhr 32 days
>> 2019 12 19 143.04 1157 kwhr 30 days
>> 2020 1 23 169.55 1417 kwhr 33 days
>> 2020 2 24 151.28 1242 kwhr 30 days
>> 2020 3 24 135.98 1095 kwhr 29 days
>> 2020 4 23 110.43 845 kwhr 32 days
>> 2020 5 22 100.65 774 kwhr 29 days
>> 2020 6 23 91.92 718 kwhr 30 days
>> 2020 7 23 123.30 977 kwhr 32 days
>> 2020 8 21 131.87 1048 kwhr 29 days
>> 2020 9 22 109.86 869 kwhr 30 days
>> 2020 10 20 83.86 644 kwhr 31 days
>> 2020 11 20 92.57 721 kwhr 29 days
>> 2020 12 22 143.78 1241 kwhr 32 days
>> 2021 1 22 197.93 1805 kwhr 32 days
>> 2021 2 23 211.95 1952 kwhr 30 days
>> 2021 3 24 194.58 1771 kwhr 31 days
>> 2021 4 23 118.43 974 kwhr 30 days
>> 2021 5 24 89.88 694 kwhr 29 days
>> 2021 6 23 101.75 796 kwhr 32 days
>> 2021 7 23 103.03 795 kwhr 30 days
>> 2021 8 23 99.95 756 kwhr 29 days
>> 2021 9 20 102.70 788 kwhr 32 days
>> 2021 10 20 74.57 558 kwhr 29 days
>> 2021 11 22 110.08 881 kwhr 29 days
>> 2021 12 22 181.03 1597 kwhr 29 days
>> 2022 1 13 160.41 1513 kwhr 30 days
>> 2022 2 14 253.07 2352 kwhr 30 days
>> 2022 3 15 136.15 1202 kwhr 31 days
>> 2022 4 13 98.33 829 kwhr 29 days
>> 2022 5 13 78.96 658 kwhr 30 days
>> 2022 6 14 76.76 633 kwhr 32 days
>> ", header=TRUE )
>> dta$Dtm <- with( dta, as.Date( ISOdate(Year, Mon, Day ) ) )
>> with (dta, plot( Dtm, kwhr, type="l", xlab="Years", ylab="kwhr" ))
>> grid (nx = NA, ny = NULL, lty=4, lwd=1, col="chocolate")
>> abline(h=1750, col="red")
>> abline(v=2020, col="green")
>>
>> [[alternative HTML version deleted]]
>> ______________________________________________
>> R-help using 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.
>
> --
> Sent from my phone. Please excuse my brevity.
More information about the R-help
mailing list