0

I keep getting lines on the axis of my plots when using ggplot for data that I imported. Below is the code I used and a picture of the outputed graph.

install.packages("ggplot2")

library(ggplot2)

#base data that will be used for analysis
pH_and_chloro <-read.csv("C:\\Users\\pc\\Downloads\\pH and Chlorophyll Data.csv")

ggplot(pH_and_chloro, aes(Date, Water.Works.Park.pH))+
  geom_jitter( size=1, color="orange", width=0.3) 

Here is the graph enter image description here

I tried finding similar issues and graphing without using ggplot (just using R's in-built graph features) but in the future I need to be comfortable with ggplot.

EDIT 1: When typing

    str(pH_and_chloro[[c("Date", "Water.Works.Park.pH")]]) 

I get the error: "Error in .subset2(x, i, exact = exact) : subscript out of bounds."

When graphing using in-built datasets in R, the graphs turn out to be normal.

EDIT 2: Here is the dput(pH_and_chloro) output (I had to exclude some of the data because I passed the 30,000 character limit:

structure(list(Date = c("Date", "4/1/2022", "4/2/2022", "4/3/2022", 
"4/4/2022", "4/5/2022", "4/6/2022", "4/7/2022", "4/8/2022", "4/9/2022", 
"4/10/2022", "4/11/2022", "4/12/2022", "4/13/2022", "4/14/2022", 
"4/15/2022", "4/16/2022", "4/17/2022", "4/18/2022", "4/19/2022", 
"4/20/2022", "4/21/2022", "4/22/2022", "4/23/2022", "4/24/2022", 
"4/25/2022", "4/26/2022", "4/27/2022", "4/28/2022", "4/29/2022", 
"4/30/2022", "5/1/2022", "5/2/2022", "5/3/2022", "5/4/2022", 
"5/5/2022", "5/6/2022", "5/7/2022", "5/8/2022", "5/9/2022", "5/10/2022", 
"5/11/2022", "5/12/2022", "5/13/2022", "5/14/2022", "5/15/2022", 
"5/16/2022", "5/17/2022", "5/18/2022", "5/19/2022", "5/20/2022", 
"5/21/2022", "5/22/2022", "5/23/2022", "5/24/2022", "5/25/2022", 
"5/26/2022", "5/27/2022", "5/28/2022", "5/29/2022", "5/30/2022", 
"5/31/2022", "6/1/2022", "6/2/2022", "6/3/2022", "6/4/2022", 
"6/5/2022", "6/6/2022", "6/7/2022", "6/8/2022", "6/9/2022", "6/10/2022", 
"6/11/2022", "6/12/2022", "6/13/2022", "6/14/2022", "6/15/2022", 
"6/16/2022", "6/17/2022", "6/18/2022", "6/19/2022", "6/20/2022", 
"6/21/2022", "6/22/2022", "6/23/2022", "6/24/2022", "6/25/2022", 
"6/26/2022", "6/27/2022", "6/28/2022", "6/29/2022", "6/30/2022", 
"7/1/2022", "7/2/2022", "7/3/2022", "7/4/2022", "7/5/2022", "7/6/2022", 
"7/7/2022", "7/8/2022", "7/9/2022", "7/10/2022", "7/11/2022", 
"7/12/2022", "7/13/2022", "7/14/2022", "7/15/2022", "7/16/2022", 
"7/17/2022", "7/18/2022", "7/19/2022", "7/20/2022", "7/21/2022", 
"7/22/2022", "7/23/2022", "7/24/2022", "7/25/2022", "7/26/2022", 
"7/27/2022", "7/28/2022", "7/29/2022", "7/30/2022", "7/31/2022", 
"8/1/2022", "8/2/2022", "8/3/2022", "8/4/2022", "8/5/2022", "8/6/2022", 
"8/7/2022", "8/8/2022", "8/9/2022", "8/10/2022", "8/11/2022", 
"8/12/2022", "8/13/2022", "8/14/2022", "8/15/2022", "8/16/2022", 
"8/17/2022", "8/18/2022", "8/19/2022", "8/20/2022", "8/21/2022", 
"8/22/2022", "8/23/2022", "8/24/2022", "8/25/2022", "8/26/2022", 
"8/27/2022", "8/28/2022", "8/29/2022", "8/30/2022", "8/31/2022", 
"9/1/2022", "9/2/2022", "9/3/2022", "9/4/2022", "9/5/2022", "9/6/2022", 
"9/7/2022", "9/8/2022", "9/9/2022", "9/10/2022", "9/11/2022", 
"9/12/2022", "9/13/2022", "9/14/2022", "9/15/2022", "9/16/2022", 
"9/17/2022", "9/18/2022", "9/19/2022", "9/20/2022", "9/21/2022", 
"9/22/2022", "9/23/2022", "9/24/2022", "9/25/2022", "9/26/2022", 
"9/27/2022", "9/28/2022", "9/29/2022", "9/30/2022", "10/1/2022", 
"10/2/2022", "10/3/2022", "10/4/2022", "10/5/2022", "10/6/2022", 
"10/7/2022", "10/8/2022", "10/9/2022", "10/10/2022", "10/11/2022", 
"10/12/2022", "10/13/2022", "10/14/2022", "10/15/2022", "10/16/2022", 
"10/17/2022", "10/18/2022", "10/19/2022", "10/20/2022", "10/21/2022", 
"10/22/2022", "10/23/2022", "10/24/2022", "10/25/2022", "10/26/2022", 
"10/27/2022", "10/28/2022", "10/29/2022", "10/30/2022", "10/31/2022", 
"11/1/2022", "11/2/2022", "11/3/2022", "11/4/2022", "11/5/2022", 
"11/6/2022", "11/7/2022", "11/8/2022", "11/9/2022", "11/10/2022", 
"11/11/2022", "11/12/2022", "11/13/2022", "11/14/2022", "11/15/2022", 
"11/16/2022", "11/17/2022", "11/18/2022", "11/19/2022", "11/20/2022", 
"11/21/2022", "11/22/2022", "11/23/2022", "11/24/2022", "11/25/2022", 
"11/26/2022", "11/27/2022", "11/28/2022", "11/29/2022", "11/30/2022", 
"12/1/2022", "12/2/2022", "12/3/2022", "12/4/2022", "12/5/2022", 
"12/6/2022", "12/7/2022", "12/8/2022", "12/9/2022", "12/10/2022", 
"12/11/2022", "12/12/2022", "12/13/2022", "12/14/2022", "12/15/2022", 
"12/16/2022", "12/17/2022", "12/18/2022", "12/19/2022", "12/20/2022", 
"12/21/2022", "12/22/2022", "12/23/2022", "12/24/2022", "12/25/2022", 
"12/26/2022", "12/27/2022", "12/28/2022", "12/29/2022", "12/30/2022", 
"12/31/2022", "1/1/2023", "1/2/2023", "1/3/2023", "1/4/2023", 
"1/5/2023", "1/6/2023", "1/7/2023", "1/8/2023", "1/9/2023", "1/10/2023", 
"1/11/2023", "1/12/2023", "1/13/2023", "1/14/2023", "1/15/2023", 
"1/16/2023", "1/17/2023", "1/18/2023", "1/19/2023", "1/20/2023", 
"1/21/2023", "1/22/2023", "1/23/2023", "1/24/2023", "1/25/2023", 
"1/26/2023", "1/27/2023", "1/28/2023", "1/29/2023", "1/30/2023", 
"1/31/2023", "2/1/2023", "2/2/2023", "2/3/2023", "2/4/2023", 
"2/5/2023", "2/6/2023", "2/7/2023", "2/8/2023", "2/9/2023", "2/10/2023", 
"2/11/2023", "2/12/2023", "2/13/2023", "2/14/2023", "2/15/2023", 
"2/16/2023", "2/17/2023", "2/18/2023", "2/19/2023", "2/20/2023", 
"2/21/2023", "2/22/2023", "2/23/2023", "2/24/2023", "2/25/2023", 
"2/26/2023", "2/27/2023", "2/28/2023", "3/1/2023", "3/2/2023", 
"3/3/2023", "3/4/2023", "3/5/2023", "3/6/2023", "3/7/2023", "3/8/2023", 
"3/9/2023", "3/10/2023", "3/11/2023", "3/12/2023", "3/13/2023", 
"3/14/2023", "3/15/2023", "3/16/2023", "3/17/2023", "3/18/2023", 
"3/19/2023", "3/20/2023", "3/21/2023", "3/22/2023", "3/23/2023", 
"3/24/2023", "3/25/2023", "3/26/2023", "3/27/2023", "3/28/2023", 
"3/29/2023", "3/30/2023", "3/31/2023", "4/1/2023", "4/2/2023", 
"4/3/2023", "4/4/2023", "4/5/2023", "4/6/2023", "4/7/2023", "4/8/2023", 
"4/9/2023", "4/10/2023", "4/11/2023", "4/12/2023", "4/13/2023", 
"4/14/2023", "4/15/2023", "4/16/2023", "4/17/2023", "4/18/2023", 
"4/19/2023", "4/20/2023", "4/21/2023", "4/22/2023", "4/23/2023", 
"4/24/2023", "4/25/2023", "4/26/2023", "4/27/2023", "4/28/2023", 
"4/29/2023", "4/30/2023", "5/1/2023", "5/2/2023", "5/3/2023", 
"5/4/2023", "5/5/2023", "5/6/2023", "5/7/2023", "5/8/2023", "5/9/2023", 
"5/10/2023", "5/11/2023", "5/12/2023", "5/13/2023", "5/14/2023", 
"5/15/2023", "5/16/2023", "5/17/2023", "5/18/2023", "5/19/2023", 
"5/20/2023", "5/21/2023", "5/22/2023", "5/23/2023", "5/24/2023", 
"5/25/2023", "5/26/2023", "5/27/2023", "5/28/2023", "5/29/2023", 
"5/30/2023", "5/31/2023", "6/1/2023", "6/2/2023", "6/3/2023", 
"6/4/2023", "6/5/2023", "6/6/2023", "6/7/2023", "6/8/2023", "6/9/2023", 
"6/10/2023", "6/11/2023", "6/12/2023", "6/13/2023", "6/14/2023", 
"6/15/2023", "6/16/2023", "6/17/2023", "6/18/2023", "6/19/2023", 
"6/20/2023", "6/21/2023", "6/22/2023", "6/23/2023", "6/24/2023", 
"6/25/2023", "6/26/2023", "6/27/2023", "6/28/2023", "6/29/2023", 
"6/30/2023", "7/1/2023", "7/2/2023", "7/3/2023", "7/4/2023", 
"7/5/2023", "7/6/2023", "7/7/2023", "7/8/2023", "7/9/2023", "7/10/2023", 
"7/11/2023", "7/12/2023"), Water.Works.Park.pH = c("pH", "7.871567944", "7.869097222", 
"7.823819444", "7.842152778", "7.866979167", "7.874738676", "7.880034843", 
"7.873645833", "7.875121951", "7.873715278", "7.8809375", "7.911041667", 
"7.893854167", "7.919270833", "7.9253125", "7.896423611", "7.882682927", 
"7.863715278", "7.911458333", "7.882569444", "7.888784722", "7.902743056", 
"7.897881944", "7.937038328", "8.020729167", "8.020890411", "", 
"", "", "", "", "", "", "", "", "7.984427481", "7.992777778", 
"8.014930556", "7.993229167", "8.042534722", "8.067700348", "8.1034375", 
"8.136944444", "8.193888889", "8.227526132", "8.215138889", "8.190451389", 
"8.158125", "8.155798611", "8.134270833", "8.150694444", "8.15825784", 
"8.129513889", "8.154722222", "7.983554007", "7.871215278", "7.820487805", 
"8.239407666", "8.215868056", "8.236076389", "8.268784722", "8.276840278", 
"8.2546875", "8.218125", "8.23912892", "8.261215278", "8.273076923", 
"8.271493056", "8.243888889", "8.236111111", "8.242787456", "8.269791667", 
"8.279407666", "8.302083333", "8.298680556", "8.317395833", "8.392847222", 
"8.405", "8.359236111", "8.341111111", "8.283645833", "8.295972222", 
"8.368854167", "8.434166667", "8.463090278", "8.429305556", "8.470833333", 
"8.458333333", "8.459163763", "8.439340278", "8.416933798", "8.419861111", 
"8.525173611", "8.476076389", "8.496145833", "8.547222222", "8.565347222", 
"8.553923611", "8.495277778", "8.529652778", "8.522891986", "8.618611111", 
"8.714166667", "8.690296296", "8.655017422", "8.547638889", "8.571533101", 
"8.626215278", "8.666236934", "8.626111111", "8.668675958", "8.69875", 
"8.653263889", "8.629097222", "8.614340278", "8.619513889", "8.606445993", 
"8.595590278", "8.610868056", "8.618055556", "8.683135889", "8.626284722", 
"8.574861111", "8.617013889", "8.685798611", "8.663993056", "8.548993056", 
"8.517048611", "8.583611111", "8.645590278", "8.654930556", "8.62375", 
"8.593263889", "8.573298611", "8.552996516", "8.614041812", "8.601736111", 
"8.551533101", "8.629270833", "8.634250871", "8.607777778", "8.597491289", 
"8.642578397", "8.603993056", "8.550243056", "8.525156794", "8.525243056", 
"8.554791667", "8.608368056", "8.587665505", "8.561319444", "8.560347222", 
"8.519756944", "8.457881944", "8.398013937", "8.426423611", "8.481770833", 
"8.558125", "8.500451389", "8.256840278", "7.936875", "7.526875", 
"7.396076389", "7.351006944", "7.352291667", "7.313972125", "7.344831461", 
"8.1646875", "8.068923611", "8.061979167", "8.031458333", "7.975208333", 
"7.921770833", "7.936689895", "7.942020906", "7.897777778", "8.003958333", 
"7.990486111", "7.957361111", "7.930798611", "7.9728125", "8.0590625", 
"8.023472222", "8.002473868", "7.989479167", "7.970729167", "8.054024896", 
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", 
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", 
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", 
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", 
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", 
"", "", "", "", "", "", "7.976860465", "8.01323741", "8.018411552", 
"7.99921147", "8.009678571", "8.019566787", "8.024208633", "8.012831541", 
"8.003071429", "7.998741007", "7.988817204", "7.994128114", "8.02917603", 
"8.032302158", "8.030282258", "8.003568773", "7.984587814", "7.978888889", 
"7.994590747", "8.019", "8.018093525", "8.051362007", "8.02881295", 
"8.022285714", "8.023985765", "8.022939068", "8.025734767", "8.033225806", 
"7.833405018", "7.520821429", "7.331", "7.361690647", "7.234208633", 
"7.172597865", "7.245662651", "", "", "", "", "", "", "", "", 
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", 
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", 
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", 
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", 
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", 
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", 
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", 
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", 
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", 
"", "", "", "", "", "", "", ""), Water.Work.Parks.Chlorophyll = c("Chlorophyll", 
"1.266202091", "1.717708333", "0.994097222", "0.878472222", "1.014583333", 
"1.135888502", "1.064583333", "0.835069444", "0.788194444", "0.756944444", 
"0.747569444", "0.743402778", "0.795833333", "0.802083333", "0.824652778", 
"0.836111111", "0.833449477", "0.823263889", "0.812847222", "0.905555556", 
"0.943055556", "0.8", "0.770486111", "0.750522648", "0.773958333", 
"0.781506849", "", "", "", "", "", "", "", "", "", "0.890076336", 
"0.890972222", "0.915972222", "0.948958333", "0.929513889", "0.951567944", 
"1.223263889", "1.608680556", "2.261111111", "2.757491289", "2.523958333", 
"2.147222222", "1.790625", "1.632638889", "1.499305556", "1.581944444", 
"1.653819444", "1.689930556", "2.111458333", "1.550522648", "1.005902778", 
"1.867595819", "2.387804878", "2.315277778", "2.742708333", "2.886805556", 
"2.747916667", "2.629166667", "2.761111111", "3.07630662", "2.684722222", 
"2.28951049", "2.105555556", "1.672222222", "1.273611111", "1.150522648", 
"1.073611111", "1.106968641", "1.061111111", "0.988194444", "0.969444444", 
"1.061111111", "1.114930556", "1.120138889", "1.068055556", "1.074652778", 
"1.187152778", "1.251041667", "1.148263889", "1.141319444", "1.136805556", 
"1.164583333", "1.142361111", "1.129268293", "1.211805556", "1.035888502", 
"1.033333333", "1.048263889", "1.105555556", "1.069444444", "1.069444444", 
"1.048958333", "1.094444444", "1.148958333", "1.15", "1.198606272", 
"1.164930556", "1.131597222", "1.12962963", "1.093728223", "1.052777778", 
"1.035416667", "1.044097222", "1.087804878", "1.129166667", "1.166202091", 
"1.204513889", "1.16875", "1.147569444", "1.211111111", "1.321875", 
"1.355400697", "1.2625", "1.215625", "1.282986111", "1.309407666", 
"1.249652778", "1.192708333", "1.167708333", "1.151388889", "1.126041667", 
"1.148263889", "1.167708333", "1.193055556", "1.179166667", "1.189583333", 
"1.204166667", "1.175347222", "1.204513889", "1.220905923", "1.218402778", 
"1.220833333", "1.229616725", "1.210416667", "1.170034843", "1.1375", 
"1.150174216", "1.163541667", "1.181944444", "1.248263889", "1.305574913", 
"1.376736111", "1.339236111", "1.324652778", "1.318466899", "1.278819444", 
"1.253819444", "1.23125", "1.233680556", "1.218118467", "1.196527778", 
"1.21875", "1.210763889", "1.236458333", "1.134375", "1.046180556", 
"1.201736111", "1.201736111", "1.208680556", "1.215972222", "1.197222222", 
"1.147191011", "1.111805556", "1.175694444", "1.169444444", "1.153472222", 
"1.151041667", "1.156597222", "1.158885017", "1.16445993", "1.168402778", 
"1.168055556", "1.165625", "1.165625", "1.159375", "1.161805556", 
"1.157291667", "1.152430556", "1.141463415", "1.149652778", "1.159027778", 
"1.156431535", "", "", "", "", "", "", "", "", "", "", "", "", 
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", 
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", 
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", 
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", 
"", "", "", "", "", "", "", "", "", "", "0.848837209", "0.80971223", 
"0.794604317", "0.786379928", "0.803571429", "0.806498195", "0.831654676", 
"0.883154122", "0.863928571", "0.871942446", "0.859856631", "0.834875445", 
"0.820224719", "0.80323741", "0.915725806", "0.944237918", "1.115770609", 
"1.102508961", "1", "0.918214286", "0.931541219", "0.961290323", 
"1.055035971", "1.0125", "0.956227758", "0.897491039", "0.85125448", 
"0.858781362", "0.922580645", "1.054285714", "1.198928571", "1.185971223", 
"1.177697842", "1.183629893", "1.175301205", "", "", "", "", 
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", 
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", 
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", 
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", 
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", 
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", 
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", 
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", 
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", 
"", "", "", "", "", "", "", "", "", "", "", "")), class = "data.frame", row.names = c(NA,-469L))

     
Albert Einstein
  • 7,472
  • 8
  • 36
  • 71
Gsizzle
  • 1
  • 1
  • 2
    These sort of figures are often caused by the data being character or factor class. Can you edit your question with the results of `str(pH_and_chloro[[c("Date", "Water.Works.Park.pH")]` please – user20650 Jul 19 '23 at 15:02
  • also it is good practice to add a reproducible example to your question; it makes it easier for you to get help. See https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example – user20650 Jul 19 '23 at 15:03
  • Please can you share a sample of your data using `dput()` so that we are able to run your code - it makes it much easier to help! – nrennie Jul 19 '23 at 16:17
  • As user20650 suspected/suggested you need to convert date and pH from `character` to the correct modes, using e. g. `as.Date`, `as.double`. See `?read.csv` about specifying the mode already at the import stage. – I_O Jul 19 '23 at 16:47

0 Answers0