当数据为Na时,R Studio GGPLOT线路断开不会出现
我有一个数据集,我想在其中随着时间的推移在不同位置进行物质的测量值。这与简单的线图一起工作。但是,我的数据中有一些瞬间,当没有执行这些时刻,我希望线路破裂。我添加了一些NA值的日期。但是,它不会出现休息。
代码是这样的:
chloride <- subset(df, Parameter == "chloride - nf - mg/l")
ggplot(data = chloride2, aes(x = Datum, y = as.numeric(as.factor(Waarden)))) +
geom_line(aes(color = Locatie), lwd = 1) +
labs(x = "Datum", y = "Chloride (mg/l)") +
scale_color_manual(values = c("navy", "darkslategray4", "orange", "yellowgreen", "cornflowerblue", "firebrick")) +
theme_bw() +
theme(text = element_text(size = 16), legend.position = "top") +
scale_y_continuous(limits = c(0, 220)) +
geom_hline(yintercept = 200, linetype = "dashed") +
scale_x_date(date_breaks = ("1 year"), labels = date_format("%m/%Y"))
我已经尝试了另一种物质,其中包括一个位置,
extinction <- subset(df, Parameter == "Extinctie")
every.year <- data.frame(Datum = seq(min(extinction$Datum), max(extinction$Datum), by = "1 year"))
extinction2 <- merge(extinction, every.year, all = TRUE)
ggplot(data = extinction2, aes(x = Datum, y = Waarden)) +
geom_line(color = "steelblue", lwd = 1) +
labs(y = "Extinctie-waarden", x = "Datum") +
theme_bw() +
theme(text = element_text(size = 16)) +
scale_y_continuous(limit = c(0, 15)) +
scale_x_date(date_breaks = ("3 month"), labels = date_format("%m/%Y"))
该位置尝试了此代码。
似乎由于不同的位置而没有出现休息
Datum Parameter Waarden Locatie
1 2016-02-08 chloride - nf - mg/l 89.0 Waterskivijver Wollebrand
2 2016-04-26 chloride - nf - mg/l 93.0 Waterskivijver Wollebrand
3 2016-05-24 chloride - nf - mg/l 81.0 Waterskivijver Wollebrand
4 2016-06-16 chloride - nf - mg/l 74.0 Waterskivijver Wollebrand
5 2016-06-16 chloride - nf - mg/l 62.0 Wollebrand_Inlaat zwemplas
6 2016-06-16 chloride - nf - mg/l 70.0 hoofdwatergang_Lange Broekweg nr 78 (?)_tuin
7 2016-06-16 chloride - nf - mg/l 63.0 veilingroute_bovenstroom stuw
8 2016-06-16 chloride - nf - mg/l 59.0 Strijp_inlaat FLORA
9 2016-06-21 chloride - nf - mg/l 51.0 Waterskivijver Wollebrand
10 2016-06-28 chloride - nf - mg/l 45.0 Waterskivijver Wollebrand
11 2016-06-28 chloride - nf - mg/l 33.0 Wollebrand_Inlaat zwemplas
12 2016-06-28 chloride - nf - mg/l 36.0 Strijp_inlaat FLORA
13 2016-06-28 chloride - nf - mg/l 47.0 hoofdwatergang_Lange Broekweg nr 78 (?)_tuin
14 2016-06-28 chloride - nf - mg/l 82.0 veilingroute_bovenstroom stuw
15 2016-07-08 chloride - nf - mg/l 46.0 Wollebrand_Inlaat zwemplas
16 2016-07-08 chloride - nf - mg/l 54.0 Waterskivijver Wollebrand
17 2016-07-08 chloride - nf - mg/l 46.0 veilingroute_bovenstroom stuw
18 2016-07-08 chloride - nf - mg/l 42.0 Strijp_inlaat FLORA
19 2016-07-11 chloride - nf - mg/l 63.0 hoofdwatergang_Lange Broekweg nr 78 (?)_tuin
20 2016-07-19 chloride - nf - mg/l 68.0 Waterskivijver Wollebrand
21 2016-07-19 chloride - nf - mg/l 65.0 Wollebrand_Inlaat zwemplas
22 2016-07-19 chloride - nf - mg/l 72.0 hoofdwatergang_Lange Broekweg nr 78 (?)_tuin
23 2016-07-19 chloride - nf - mg/l 53.0 veilingroute_bovenstroom stuw
24 2016-07-19 chloride - nf - mg/l 45.0 Strijp_inlaat FLORA
25 2016-08-01 chloride - nf - mg/l 54.0 Wollebrand_Inlaat zwemplas
26 2016-08-01 chloride - nf - mg/l 65.0 Waterskivijver Wollebrand
27 2016-08-01 chloride - nf - mg/l 62.0 hoofdwatergang_Lange Broekweg nr 78 (?)_tuin
28 2016-08-01 chloride - nf - mg/l 45.0 veilingroute_bovenstroom stuw
29 2016-08-01 chloride - nf - mg/l 48.0 Strijp_inlaat FLORA
30 2016-08-16 chloride - nf - mg/l 61.0 Waterskivijver Wollebrand
31 2016-08-16 chloride - nf - mg/l 61.0 Waterskivijver Wollebrand
32 2016-08-16 chloride - nf - mg/l 58.0 Wollebrand_Inlaat zwemplas
33 2016-08-16 chloride - nf - mg/l 62.0 hoofdwatergang_Lange Broekweg nr 78 (?)_tuin
34 2016-08-16 chloride - nf - mg/l 57.0 veilingroute_bovenstroom stuw
35 2016-08-16 chloride - nf - mg/l 56.0 Strijp_inlaat FLORA
36 2016-08-30 chloride - nf - mg/l 48.0 Waterskivijver Wollebrand
37 2016-09-02 chloride - nf - mg/l 58.0 Strijp_inlaat FLORA
38 2016-09-02 chloride - nf - mg/l 51.0 Waterskivijver Wollebrand
39 2016-09-02 chloride - nf - mg/l 54.0 Wollebrand_Inlaat zwemplas
40 2016-09-02 chloride - nf - mg/l 56.0 hoofdwatergang_Lange Broekweg nr 78 (?)_tuin
41 2016-09-02 chloride - nf - mg/l 60.0 veilingroute_bovenstroom stuw
42 2016-09-13 chloride - nf - mg/l 64.0 Waterskivijver Wollebrand
43 2016-09-15 chloride - nf - mg/l 68.0 Waterskivijver Wollebrand
44 2016-09-15 chloride - nf - mg/l 76.0 hoofdwatergang_Lange Broekweg nr 78 (?)_tuin
45 2016-09-15 chloride - nf - mg/l 72.0 Wollebrand_Inlaat zwemplas
46 2016-09-15 chloride - nf - mg/l 75.0 veilingroute_bovenstroom stuw
47 2016-09-15 chloride - nf - mg/l 72.0 Strijp_inlaat FLORA
48 2016-09-30 chloride - nf - mg/l 75.0 Waterskivijver Wollebrand
49 2016-09-30 chloride - nf - mg/l 74.0 hoofdwatergang_Lange Broekweg nr 78 (?)_tuin
50 2016-09-30 chloride - nf - mg/l 63.0 Wollebrand_Inlaat zwemplas
51 2016-09-30 chloride - nf - mg/l 68.0 veilingroute_bovenstroom stuw
52 2016-09-30 chloride - nf - mg/l 71.0 Strijp_inlaat FLORA
53 2016-10-10 chloride - nf - mg/l 75.0 Waterskivijver Wollebrand
54 2016-10-10 chloride - nf - mg/l 74.0 Wollebrand_Inlaat zwemplas
55 2016-10-10 chloride - nf - mg/l 76.0 hoofdwatergang_Lange Broekweg nr 78 (?)_tuin
56 2016-10-10 chloride - nf - mg/l 76.0 veilingroute_bovenstroom stuw
57 2016-10-10 chloride - nf - mg/l 74.0 Strijp_inlaat FLORA
58 2016-10-25 chloride - nf - mg/l 70.0 Waterskivijver Wollebrand
59 2016-10-25 chloride - nf - mg/l 66.0 Wollebrand_Inlaat zwemplas
60 2016-10-25 chloride - nf - mg/l 64.0 hoofdwatergang_Lange Broekweg nr 78 (?)_tuin
61 2016-10-25 chloride - nf - mg/l 65.0 veilingroute_bovenstroom stuw
62 2016-10-25 chloride - nf - mg/l 67.0 Strijp_inlaat FLORA
63 2016-11-07 chloride - nf - mg/l 60.0 Waterskivijver Wollebrand
64 2016-11-14 chloride - nf - mg/l 62.0 Waterskivijver Wollebrand
65 2016-11-14 chloride - nf - mg/l 52.0 Wollebrand_Inlaat zwemplas
66 2016-11-14 chloride - nf - mg/l 60.0 hoofdwatergang_Lange Broekweg nr 78 (?)_tuin
67 2016-11-14 chloride - nf - mg/l 63.0 veilingroute_bovenstroom stuw
68 2016-11-14 chloride - nf - mg/l 52.0 Strijp_inlaat FLORA
69 2016-12-20 chloride - nf - mg/l 76.0 Waterskivijver Wollebrand
70 2016-12-20 chloride - nf - mg/l 84.0 Wollebrand_Inlaat zwemplas
71 2016-12-20 chloride - nf - mg/l 83.0 hoofdwatergang_Lange Broekweg nr 78 (?)_tuin
72 2016-12-20 chloride - nf - mg/l 93.0 veilingroute_bovenstroom stuw
73 2016-12-20 chloride - nf - mg/l 97.0 Strijp_inlaat FLORA
74 2017-01-13 chloride - nf - mg/l 103.0 Waterskivijver Wollebrand
75 2017-01-13 chloride - nf - mg/l 49.2 Wollebrand_Inlaat zwemplas
76 2017-01-13 chloride - nf - mg/l 68.2 hoofdwatergang_Lange Broekweg nr 78 (?)_tuin
77 2017-01-13 chloride - nf - mg/l 60.8 veilingroute_bovenstroom stuw
78 2017-01-13 chloride - nf - mg/l 61.7 Strijp_inlaat FLORA
79 2017-02-08 <NA> NA <NA>
80 2017-02-13 chloride - nf - mg/l 73.4 Strijp_inlaat FLORA
81 2017-02-13 chloride - nf - mg/l 99.5 Waterskivijver Wollebrand
82 2017-02-13 chloride - nf - mg/l 133.0 Wollebrand_Inlaat zwemplas
83 2017-02-13 chloride - nf - mg/l 110.0 hoofdwatergang_Lange Broekweg nr 78 (?)_tuin
84 2017-02-13 chloride - nf - mg/l 99.1 veilingroute_bovenstroom stuw
85 2017-03-07 chloride - nf - mg/l 95.7 Waterskivijver Wollebrand
86 2017-03-09 chloride - nf - mg/l 55.3 Wollebrand_Inlaat zwemplas
87 2017-03-09 chloride - nf - mg/l 74.5 hoofdwatergang_Lange Broekweg nr 78 (?)_tuin
88 2017-03-09 chloride - nf - mg/l 71.7 veilingroute_bovenstroom stuw
89 2017-03-09 chloride - nf - mg/l 64.3 Strijp_inlaat FLORA
90 2017-04-04 chloride - nf - mg/l 99.1 Wollebrand_Inlaat zwemplas
91 2017-04-04 chloride - nf - mg/l 111.0 hoofdwatergang_Lange Broekweg nr 78 (?)_tuin
92 2017-04-04 chloride - nf - mg/l 101.0 veilingroute_bovenstroom stuw
93 2017-04-04 chloride - nf - mg/l 91.2 Strijp_inlaat FLORA
94 2017-04-25 chloride - nf - mg/l 107.0 Waterskivijver Wollebrand
95 2017-05-02 chloride - nf - mg/l 111.0 Wollebrand_Inlaat zwemplas
96 2017-05-02 chloride - nf - mg/l 123.0 hoofdwatergang_Lange Broekweg nr 78 (?)_tuin
97 2017-05-02 chloride - nf - mg/l 143.0 veilingroute_bovenstroom stuw
98 2017-05-02 chloride - nf - mg/l 132.0 Strijp_inlaat FLORA
99 2017-05-02 chloride - nf - mg/l 113.0 Waterskivijver Wollebrand steiger-vlot
100 2017-05-23 chloride - nf - mg/l 147.0 Waterskivijver Wollebrand
101 2017-06-06 chloride - nf - mg/l 100.0 Wollebrand_Inlaat zwemplas
102 2017-06-06 chloride - nf - mg/l 147.0 hoofdwatergang_Lange Broekweg nr 78 (?)_tuin
103 2017-06-06 chloride - nf - mg/l 99.0 veilingroute_bovenstroom stuw
104 2017-06-06 chloride - nf - mg/l 88.2 Strijp_inlaat FLORA
105 2017-06-06 chloride - nf - mg/l 144.0 Waterskivijver Wollebrand steiger-vlot
106 2017-06-20 chloride - nf - mg/l 127.0 Waterskivijver Wollebrand
107 2017-07-05 chloride - nf - mg/l 105.0 Wollebrand_Inlaat zwemplas
108 2017-07-05 chloride - nf - mg/l 103.0 hoofdwatergang_Lange Broekweg nr 78 (?)_tuin
109 2017-07-05 chloride - nf - mg/l 106.0 veilingroute_bovenstroom stuw
110 2017-07-05 chloride - nf - mg/l 84.3 Strijp_inlaat FLORA
111 2017-07-05 chloride - nf - mg/l 118.0 Waterskivijver Wollebrand steiger-vlot
112 2017-07-18 chloride - nf - mg/l 92.9 Waterskivijver Wollebrand
113 2017-08-03 chloride - nf - mg/l 72.1 Wollebrand_Inlaat zwemplas
114 2017-08-03 chloride - nf - mg/l 65.4 hoofdwatergang_Lange Broekweg nr 78 (?)_tuin
115 2017-08-03 chloride - nf - mg/l 63.3 veilingroute_bovenstroom stuw
116 2017-08-03 chloride - nf - mg/l 72.7 Strijp_inlaat FLORA
117 2017-08-03 chloride - nf - mg/l 84.2 Waterskivijver Wollebrand steiger-vlot
118 2017-08-15 chloride - nf - mg/l 85.4 Waterskivijver Wollebrand
119 2017-09-05 chloride - nf - mg/l 70.9 veilingroute_bovenstroom stuw
120 2017-09-05 chloride - nf - mg/l 68.6 Waterskivijver Wollebrand steiger-vlot
121 2017-09-05 chloride - nf - mg/l 63.1 Wollebrand_Inlaat zwemplas
122 2017-09-05 chloride - nf - mg/l 66.8 hoofdwatergang_Lange Broekweg nr 78 (?)_tuin
123 2017-09-05 chloride - nf - mg/l 55.5 Strijp_inlaat FLORA
124 2017-09-12 chloride - nf - mg/l 52.5 Waterskivijver Wollebrand
125 2017-10-05 chloride - nf - mg/l 39.2 Wollebrand_Inlaat zwemplas
126 2017-10-05 chloride - nf - mg/l 33.3 veilingroute_bovenstroom stuw
127 2017-10-05 chloride - nf - mg/l 37.5 Strijp_inlaat FLORA
128 2017-10-05 chloride - nf - mg/l 66.5 Waterskivijver Wollebrand steiger-vlot
129 2017-10-31 chloride - nf - mg/l 81.3 hoofdwatergang_Lange Broekweg nr 78 (?)_tuin
130 2017-11-09 chloride - nf - mg/l 70.5 Wollebrand_Inlaat zwemplas
131 2017-11-09 chloride - nf - mg/l 82.6 hoofdwatergang_Lange Broekweg nr 78 (?)_tuin
132 2017-11-09 chloride - nf - mg/l 72.0 veilingroute_bovenstroom stuw
133 2017-11-09 chloride - nf - mg/l 66.3 Strijp_inlaat FLORA
134 2017-11-09 chloride - nf - mg/l 85.8 Waterskivijver Wollebrand steiger-vlot
135 2017-11-16 chloride - nf - mg/l 85.9 Waterskivijver Wollebrand steiger-vlot
136 2017-12-06 chloride - nf - mg/l 75.9 Wollebrand_Inlaat zwemplas
137 2017-12-06 chloride - nf - mg/l 68.7 veilingroute_bovenstroom stuw
138 2017-12-06 chloride - nf - mg/l 58.5 Strijp_inlaat FLORA
139 2017-12-06 chloride - nf - mg/l 86.9 Waterskivijver Wollebrand steiger-vlot
140 2018-02-08 <NA> NA <NA>
141 2019-01-08 chloride - nf - mg/l 131.0 Waterskivijver Wollebrand
142 2019-02-08 <NA> NA <NA>
143 2019-02-18 chloride - nf - mg/l 141.0 Waterskivijver Wollebrand
144 2019-02-26 chloride - nf - mg/l 142.0 Waterskivijver Wollebrand
145 2019-04-26 chloride - nf - mg/l 86.6 Wollebrand_Inlaat zwemplas
146 2019-04-30 chloride - nf - mg/l 115.0 Waterskivijver Wollebrand
147 2019-05-14 chloride - nf - mg/l 121.0 Waterskivijver Wollebrand
148 2019-05-23 chloride - nf - mg/l 115.0 Wollebrand_Inlaat zwemplas
149 2019-05-28 chloride - nf - mg/l 117.0 Waterskivijver Wollebrand
150 2019-05-28 chloride - nf - mg/l 113.0 Waterskivijver Wollebrand
151 2019-06-12 chloride - nf - mg/l 96.7 Waterskivijver Wollebrand
152 2019-06-25 chloride - nf - mg/l 91.3 Waterskivijver Wollebrand
153 2019-06-25 chloride - nf - mg/l 88.2 Wollebrand_Inlaat zwemplas
154 2019-07-09 chloride - nf - mg/l 101.0 Waterskivijver Wollebrand
155 2019-07-11 chloride - nf - mg/l 89.3 Wollebrand_Inlaat zwemplas
156 2019-07-23 chloride - nf - mg/l 92.1 Waterskivijver Wollebrand
157 2019-08-06 chloride - nf - mg/l 85.6 Waterskivijver Wollebrand
158 2019-08-20 chloride - nf - mg/l 75.2 Waterskivijver Wollebrand
159 2019-08-20 chloride - nf - mg/l 76.4 Waterskivijver Wollebrand
160 2019-08-26 chloride - nf - mg/l 91.6 Wollebrand_Inlaat zwemplas
161 2019-09-03 chloride - nf - mg/l 89.9 Waterskivijver Wollebrand
162 2019-09-17 chloride - nf - mg/l 84.9 Waterskivijver Wollebrand
163 2019-09-24 chloride - nf - mg/l 92.7 Waterskivijver Wollebrand
164 2019-09-26 chloride - nf - mg/l 68.9 Wollebrand_Inlaat zwemplas
165 2019-10-30 chloride - nf - mg/l 109.0 Wollebrand_Inlaat zwemplas
166 2019-11-07 chloride - nf - mg/l 94.5 Waterskivijver Wollebrand
167 2019-11-29 chloride - nf - mg/l 82.9 Wollebrand_Inlaat zwemplas
168 2019-12-24 chloride - nf - mg/l 100.0 Wollebrand_Inlaat zwemplas
>
[1]: https://i.sstatic.net/mjB6G.png
I have a dataset in which I want to plot the measurements of a substance at different locations over time over time. this works with a simple line plot. However, I have some moments in my data when no measurements were executed these moments I want the lines to break. I have added some dates with NA values. However it does not present break.
The code goes like this:
chloride <- subset(df, Parameter == "chloride - nf - mg/l")
ggplot(data = chloride2, aes(x = Datum, y = as.numeric(as.factor(Waarden)))) +
geom_line(aes(color = Locatie), lwd = 1) +
labs(x = "Datum", y = "Chloride (mg/l)") +
scale_color_manual(values = c("navy", "darkslategray4", "orange", "yellowgreen", "cornflowerblue", "firebrick")) +
theme_bw() +
theme(text = element_text(size = 16), legend.position = "top") +
scale_y_continuous(limits = c(0, 220)) +
geom_hline(yintercept = 200, linetype = "dashed") +
scale_x_date(date_breaks = ("1 year"), labels = date_format("%m/%Y"))
I have tried it with another substance here only one location was included tried this code
extinction <- subset(df, Parameter == "Extinctie")
every.year <- data.frame(Datum = seq(min(extinction$Datum), max(extinction$Datum), by = "1 year"))
extinction2 <- merge(extinction, every.year, all = TRUE)
ggplot(data = extinction2, aes(x = Datum, y = Waarden)) +
geom_line(color = "steelblue", lwd = 1) +
labs(y = "Extinctie-waarden", x = "Datum") +
theme_bw() +
theme(text = element_text(size = 16)) +
scale_y_continuous(limit = c(0, 15)) +
scale_x_date(date_breaks = ("3 month"), labels = date_format("%m/%Y"))
This worked.
it seems like it does not present a break because of the different locations
Datum Parameter Waarden Locatie
1 2016-02-08 chloride - nf - mg/l 89.0 Waterskivijver Wollebrand
2 2016-04-26 chloride - nf - mg/l 93.0 Waterskivijver Wollebrand
3 2016-05-24 chloride - nf - mg/l 81.0 Waterskivijver Wollebrand
4 2016-06-16 chloride - nf - mg/l 74.0 Waterskivijver Wollebrand
5 2016-06-16 chloride - nf - mg/l 62.0 Wollebrand_Inlaat zwemplas
6 2016-06-16 chloride - nf - mg/l 70.0 hoofdwatergang_Lange Broekweg nr 78 (?)_tuin
7 2016-06-16 chloride - nf - mg/l 63.0 veilingroute_bovenstroom stuw
8 2016-06-16 chloride - nf - mg/l 59.0 Strijp_inlaat FLORA
9 2016-06-21 chloride - nf - mg/l 51.0 Waterskivijver Wollebrand
10 2016-06-28 chloride - nf - mg/l 45.0 Waterskivijver Wollebrand
11 2016-06-28 chloride - nf - mg/l 33.0 Wollebrand_Inlaat zwemplas
12 2016-06-28 chloride - nf - mg/l 36.0 Strijp_inlaat FLORA
13 2016-06-28 chloride - nf - mg/l 47.0 hoofdwatergang_Lange Broekweg nr 78 (?)_tuin
14 2016-06-28 chloride - nf - mg/l 82.0 veilingroute_bovenstroom stuw
15 2016-07-08 chloride - nf - mg/l 46.0 Wollebrand_Inlaat zwemplas
16 2016-07-08 chloride - nf - mg/l 54.0 Waterskivijver Wollebrand
17 2016-07-08 chloride - nf - mg/l 46.0 veilingroute_bovenstroom stuw
18 2016-07-08 chloride - nf - mg/l 42.0 Strijp_inlaat FLORA
19 2016-07-11 chloride - nf - mg/l 63.0 hoofdwatergang_Lange Broekweg nr 78 (?)_tuin
20 2016-07-19 chloride - nf - mg/l 68.0 Waterskivijver Wollebrand
21 2016-07-19 chloride - nf - mg/l 65.0 Wollebrand_Inlaat zwemplas
22 2016-07-19 chloride - nf - mg/l 72.0 hoofdwatergang_Lange Broekweg nr 78 (?)_tuin
23 2016-07-19 chloride - nf - mg/l 53.0 veilingroute_bovenstroom stuw
24 2016-07-19 chloride - nf - mg/l 45.0 Strijp_inlaat FLORA
25 2016-08-01 chloride - nf - mg/l 54.0 Wollebrand_Inlaat zwemplas
26 2016-08-01 chloride - nf - mg/l 65.0 Waterskivijver Wollebrand
27 2016-08-01 chloride - nf - mg/l 62.0 hoofdwatergang_Lange Broekweg nr 78 (?)_tuin
28 2016-08-01 chloride - nf - mg/l 45.0 veilingroute_bovenstroom stuw
29 2016-08-01 chloride - nf - mg/l 48.0 Strijp_inlaat FLORA
30 2016-08-16 chloride - nf - mg/l 61.0 Waterskivijver Wollebrand
31 2016-08-16 chloride - nf - mg/l 61.0 Waterskivijver Wollebrand
32 2016-08-16 chloride - nf - mg/l 58.0 Wollebrand_Inlaat zwemplas
33 2016-08-16 chloride - nf - mg/l 62.0 hoofdwatergang_Lange Broekweg nr 78 (?)_tuin
34 2016-08-16 chloride - nf - mg/l 57.0 veilingroute_bovenstroom stuw
35 2016-08-16 chloride - nf - mg/l 56.0 Strijp_inlaat FLORA
36 2016-08-30 chloride - nf - mg/l 48.0 Waterskivijver Wollebrand
37 2016-09-02 chloride - nf - mg/l 58.0 Strijp_inlaat FLORA
38 2016-09-02 chloride - nf - mg/l 51.0 Waterskivijver Wollebrand
39 2016-09-02 chloride - nf - mg/l 54.0 Wollebrand_Inlaat zwemplas
40 2016-09-02 chloride - nf - mg/l 56.0 hoofdwatergang_Lange Broekweg nr 78 (?)_tuin
41 2016-09-02 chloride - nf - mg/l 60.0 veilingroute_bovenstroom stuw
42 2016-09-13 chloride - nf - mg/l 64.0 Waterskivijver Wollebrand
43 2016-09-15 chloride - nf - mg/l 68.0 Waterskivijver Wollebrand
44 2016-09-15 chloride - nf - mg/l 76.0 hoofdwatergang_Lange Broekweg nr 78 (?)_tuin
45 2016-09-15 chloride - nf - mg/l 72.0 Wollebrand_Inlaat zwemplas
46 2016-09-15 chloride - nf - mg/l 75.0 veilingroute_bovenstroom stuw
47 2016-09-15 chloride - nf - mg/l 72.0 Strijp_inlaat FLORA
48 2016-09-30 chloride - nf - mg/l 75.0 Waterskivijver Wollebrand
49 2016-09-30 chloride - nf - mg/l 74.0 hoofdwatergang_Lange Broekweg nr 78 (?)_tuin
50 2016-09-30 chloride - nf - mg/l 63.0 Wollebrand_Inlaat zwemplas
51 2016-09-30 chloride - nf - mg/l 68.0 veilingroute_bovenstroom stuw
52 2016-09-30 chloride - nf - mg/l 71.0 Strijp_inlaat FLORA
53 2016-10-10 chloride - nf - mg/l 75.0 Waterskivijver Wollebrand
54 2016-10-10 chloride - nf - mg/l 74.0 Wollebrand_Inlaat zwemplas
55 2016-10-10 chloride - nf - mg/l 76.0 hoofdwatergang_Lange Broekweg nr 78 (?)_tuin
56 2016-10-10 chloride - nf - mg/l 76.0 veilingroute_bovenstroom stuw
57 2016-10-10 chloride - nf - mg/l 74.0 Strijp_inlaat FLORA
58 2016-10-25 chloride - nf - mg/l 70.0 Waterskivijver Wollebrand
59 2016-10-25 chloride - nf - mg/l 66.0 Wollebrand_Inlaat zwemplas
60 2016-10-25 chloride - nf - mg/l 64.0 hoofdwatergang_Lange Broekweg nr 78 (?)_tuin
61 2016-10-25 chloride - nf - mg/l 65.0 veilingroute_bovenstroom stuw
62 2016-10-25 chloride - nf - mg/l 67.0 Strijp_inlaat FLORA
63 2016-11-07 chloride - nf - mg/l 60.0 Waterskivijver Wollebrand
64 2016-11-14 chloride - nf - mg/l 62.0 Waterskivijver Wollebrand
65 2016-11-14 chloride - nf - mg/l 52.0 Wollebrand_Inlaat zwemplas
66 2016-11-14 chloride - nf - mg/l 60.0 hoofdwatergang_Lange Broekweg nr 78 (?)_tuin
67 2016-11-14 chloride - nf - mg/l 63.0 veilingroute_bovenstroom stuw
68 2016-11-14 chloride - nf - mg/l 52.0 Strijp_inlaat FLORA
69 2016-12-20 chloride - nf - mg/l 76.0 Waterskivijver Wollebrand
70 2016-12-20 chloride - nf - mg/l 84.0 Wollebrand_Inlaat zwemplas
71 2016-12-20 chloride - nf - mg/l 83.0 hoofdwatergang_Lange Broekweg nr 78 (?)_tuin
72 2016-12-20 chloride - nf - mg/l 93.0 veilingroute_bovenstroom stuw
73 2016-12-20 chloride - nf - mg/l 97.0 Strijp_inlaat FLORA
74 2017-01-13 chloride - nf - mg/l 103.0 Waterskivijver Wollebrand
75 2017-01-13 chloride - nf - mg/l 49.2 Wollebrand_Inlaat zwemplas
76 2017-01-13 chloride - nf - mg/l 68.2 hoofdwatergang_Lange Broekweg nr 78 (?)_tuin
77 2017-01-13 chloride - nf - mg/l 60.8 veilingroute_bovenstroom stuw
78 2017-01-13 chloride - nf - mg/l 61.7 Strijp_inlaat FLORA
79 2017-02-08 <NA> NA <NA>
80 2017-02-13 chloride - nf - mg/l 73.4 Strijp_inlaat FLORA
81 2017-02-13 chloride - nf - mg/l 99.5 Waterskivijver Wollebrand
82 2017-02-13 chloride - nf - mg/l 133.0 Wollebrand_Inlaat zwemplas
83 2017-02-13 chloride - nf - mg/l 110.0 hoofdwatergang_Lange Broekweg nr 78 (?)_tuin
84 2017-02-13 chloride - nf - mg/l 99.1 veilingroute_bovenstroom stuw
85 2017-03-07 chloride - nf - mg/l 95.7 Waterskivijver Wollebrand
86 2017-03-09 chloride - nf - mg/l 55.3 Wollebrand_Inlaat zwemplas
87 2017-03-09 chloride - nf - mg/l 74.5 hoofdwatergang_Lange Broekweg nr 78 (?)_tuin
88 2017-03-09 chloride - nf - mg/l 71.7 veilingroute_bovenstroom stuw
89 2017-03-09 chloride - nf - mg/l 64.3 Strijp_inlaat FLORA
90 2017-04-04 chloride - nf - mg/l 99.1 Wollebrand_Inlaat zwemplas
91 2017-04-04 chloride - nf - mg/l 111.0 hoofdwatergang_Lange Broekweg nr 78 (?)_tuin
92 2017-04-04 chloride - nf - mg/l 101.0 veilingroute_bovenstroom stuw
93 2017-04-04 chloride - nf - mg/l 91.2 Strijp_inlaat FLORA
94 2017-04-25 chloride - nf - mg/l 107.0 Waterskivijver Wollebrand
95 2017-05-02 chloride - nf - mg/l 111.0 Wollebrand_Inlaat zwemplas
96 2017-05-02 chloride - nf - mg/l 123.0 hoofdwatergang_Lange Broekweg nr 78 (?)_tuin
97 2017-05-02 chloride - nf - mg/l 143.0 veilingroute_bovenstroom stuw
98 2017-05-02 chloride - nf - mg/l 132.0 Strijp_inlaat FLORA
99 2017-05-02 chloride - nf - mg/l 113.0 Waterskivijver Wollebrand steiger-vlot
100 2017-05-23 chloride - nf - mg/l 147.0 Waterskivijver Wollebrand
101 2017-06-06 chloride - nf - mg/l 100.0 Wollebrand_Inlaat zwemplas
102 2017-06-06 chloride - nf - mg/l 147.0 hoofdwatergang_Lange Broekweg nr 78 (?)_tuin
103 2017-06-06 chloride - nf - mg/l 99.0 veilingroute_bovenstroom stuw
104 2017-06-06 chloride - nf - mg/l 88.2 Strijp_inlaat FLORA
105 2017-06-06 chloride - nf - mg/l 144.0 Waterskivijver Wollebrand steiger-vlot
106 2017-06-20 chloride - nf - mg/l 127.0 Waterskivijver Wollebrand
107 2017-07-05 chloride - nf - mg/l 105.0 Wollebrand_Inlaat zwemplas
108 2017-07-05 chloride - nf - mg/l 103.0 hoofdwatergang_Lange Broekweg nr 78 (?)_tuin
109 2017-07-05 chloride - nf - mg/l 106.0 veilingroute_bovenstroom stuw
110 2017-07-05 chloride - nf - mg/l 84.3 Strijp_inlaat FLORA
111 2017-07-05 chloride - nf - mg/l 118.0 Waterskivijver Wollebrand steiger-vlot
112 2017-07-18 chloride - nf - mg/l 92.9 Waterskivijver Wollebrand
113 2017-08-03 chloride - nf - mg/l 72.1 Wollebrand_Inlaat zwemplas
114 2017-08-03 chloride - nf - mg/l 65.4 hoofdwatergang_Lange Broekweg nr 78 (?)_tuin
115 2017-08-03 chloride - nf - mg/l 63.3 veilingroute_bovenstroom stuw
116 2017-08-03 chloride - nf - mg/l 72.7 Strijp_inlaat FLORA
117 2017-08-03 chloride - nf - mg/l 84.2 Waterskivijver Wollebrand steiger-vlot
118 2017-08-15 chloride - nf - mg/l 85.4 Waterskivijver Wollebrand
119 2017-09-05 chloride - nf - mg/l 70.9 veilingroute_bovenstroom stuw
120 2017-09-05 chloride - nf - mg/l 68.6 Waterskivijver Wollebrand steiger-vlot
121 2017-09-05 chloride - nf - mg/l 63.1 Wollebrand_Inlaat zwemplas
122 2017-09-05 chloride - nf - mg/l 66.8 hoofdwatergang_Lange Broekweg nr 78 (?)_tuin
123 2017-09-05 chloride - nf - mg/l 55.5 Strijp_inlaat FLORA
124 2017-09-12 chloride - nf - mg/l 52.5 Waterskivijver Wollebrand
125 2017-10-05 chloride - nf - mg/l 39.2 Wollebrand_Inlaat zwemplas
126 2017-10-05 chloride - nf - mg/l 33.3 veilingroute_bovenstroom stuw
127 2017-10-05 chloride - nf - mg/l 37.5 Strijp_inlaat FLORA
128 2017-10-05 chloride - nf - mg/l 66.5 Waterskivijver Wollebrand steiger-vlot
129 2017-10-31 chloride - nf - mg/l 81.3 hoofdwatergang_Lange Broekweg nr 78 (?)_tuin
130 2017-11-09 chloride - nf - mg/l 70.5 Wollebrand_Inlaat zwemplas
131 2017-11-09 chloride - nf - mg/l 82.6 hoofdwatergang_Lange Broekweg nr 78 (?)_tuin
132 2017-11-09 chloride - nf - mg/l 72.0 veilingroute_bovenstroom stuw
133 2017-11-09 chloride - nf - mg/l 66.3 Strijp_inlaat FLORA
134 2017-11-09 chloride - nf - mg/l 85.8 Waterskivijver Wollebrand steiger-vlot
135 2017-11-16 chloride - nf - mg/l 85.9 Waterskivijver Wollebrand steiger-vlot
136 2017-12-06 chloride - nf - mg/l 75.9 Wollebrand_Inlaat zwemplas
137 2017-12-06 chloride - nf - mg/l 68.7 veilingroute_bovenstroom stuw
138 2017-12-06 chloride - nf - mg/l 58.5 Strijp_inlaat FLORA
139 2017-12-06 chloride - nf - mg/l 86.9 Waterskivijver Wollebrand steiger-vlot
140 2018-02-08 <NA> NA <NA>
141 2019-01-08 chloride - nf - mg/l 131.0 Waterskivijver Wollebrand
142 2019-02-08 <NA> NA <NA>
143 2019-02-18 chloride - nf - mg/l 141.0 Waterskivijver Wollebrand
144 2019-02-26 chloride - nf - mg/l 142.0 Waterskivijver Wollebrand
145 2019-04-26 chloride - nf - mg/l 86.6 Wollebrand_Inlaat zwemplas
146 2019-04-30 chloride - nf - mg/l 115.0 Waterskivijver Wollebrand
147 2019-05-14 chloride - nf - mg/l 121.0 Waterskivijver Wollebrand
148 2019-05-23 chloride - nf - mg/l 115.0 Wollebrand_Inlaat zwemplas
149 2019-05-28 chloride - nf - mg/l 117.0 Waterskivijver Wollebrand
150 2019-05-28 chloride - nf - mg/l 113.0 Waterskivijver Wollebrand
151 2019-06-12 chloride - nf - mg/l 96.7 Waterskivijver Wollebrand
152 2019-06-25 chloride - nf - mg/l 91.3 Waterskivijver Wollebrand
153 2019-06-25 chloride - nf - mg/l 88.2 Wollebrand_Inlaat zwemplas
154 2019-07-09 chloride - nf - mg/l 101.0 Waterskivijver Wollebrand
155 2019-07-11 chloride - nf - mg/l 89.3 Wollebrand_Inlaat zwemplas
156 2019-07-23 chloride - nf - mg/l 92.1 Waterskivijver Wollebrand
157 2019-08-06 chloride - nf - mg/l 85.6 Waterskivijver Wollebrand
158 2019-08-20 chloride - nf - mg/l 75.2 Waterskivijver Wollebrand
159 2019-08-20 chloride - nf - mg/l 76.4 Waterskivijver Wollebrand
160 2019-08-26 chloride - nf - mg/l 91.6 Wollebrand_Inlaat zwemplas
161 2019-09-03 chloride - nf - mg/l 89.9 Waterskivijver Wollebrand
162 2019-09-17 chloride - nf - mg/l 84.9 Waterskivijver Wollebrand
163 2019-09-24 chloride - nf - mg/l 92.7 Waterskivijver Wollebrand
164 2019-09-26 chloride - nf - mg/l 68.9 Wollebrand_Inlaat zwemplas
165 2019-10-30 chloride - nf - mg/l 109.0 Wollebrand_Inlaat zwemplas
166 2019-11-07 chloride - nf - mg/l 94.5 Waterskivijver Wollebrand
167 2019-11-29 chloride - nf - mg/l 82.9 Wollebrand_Inlaat zwemplas
168 2019-12-24 chloride - nf - mg/l 100.0 Wollebrand_Inlaat zwemplas
>
[1]: https://i.sstatic.net/mjB6G.png
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
澄清这个问题,
让我们首先创建一个有些最小的可再现示例,以便他人为您提供帮助。
对于数据框架:
导致此框架,可以很容易地将其复制来重新创建您的数据框架:
的代码:
我们可以减少有问题
首先,请注意您创建一个数据框架
,但随后绘制
氯化物2
。其次,如果我们查看
氯化物
,我们会看到其中没有NAS。那是因为我们从df
中取了一个子集,其中parameter ==“氯化物-NF -mg/l”
,而df 也有参数的NA。即使您没有过滤它们,ggplot也不会创建断裂,因为
位置
与其绘制的任何行都无法匹配。我们需要添加一个NA来为每个参数和每个位置创建一个断点。仅纠正示例数据集中的第一个问题,我们得到了此图:
parning/note :我注意到您绘制了您绘制
as.numeric(as.factor(waarden)(waarden(waarden) ))))
在y轴上,而示例中使用的传奇表示原始值。使用as.numeric(as.factor(...))
trick创建A 排名,我非常怀疑这就是您想要的!示例:解决方案
我们需要添加到
氯化物
或df
,的一行突破发生。我将手动选择可跳动的日期:
我们可以生成参数和位置以跳过这些日期:
然后,我们创建了这三个标准的所有排列的数据框架,并确保列的名称与
df :
现在我们有
df_skip
每个组合的一行,我们想绘制一个突破:最后,我们将
df_skip
添加到原始df
,然后再次运行图:但是由于这些是故意的,我们可以忽略这一点。
完成代码
Clarifying the question
Let's first create a somewhat minimal reproducible example for others to help you.
For the data frame:
Resulting in this, which can be easily copy-pasted by others to recreate your data frame:
And we can reduce the problematic code to this:
Problem
First of all, notice that you create a data frame
chloride
, but then plotchloride2
.Second, if we look at
chloride
, we'll see that there are no NAs in there. That is because we took a subset fromdf
whereParameter == "chloride - nf - mg/l"
, whereas all your NA values indf
also had NA for Parameter. Even if you didn't filter them out, ggplot wouldn't create breaks sinceLocation
wouldn't match any of the lines it's drawing. We need to add an NA to create a break for each Parameter and each Location.Correcting just the first problem on our example dataset, we get this plot:
Warning / note: I noticed you plot
as.numeric(as.factor(Waarden)))
on the y-axis, while the legend you used in the example implies raw values. Using theas.numeric(as.factor(...))
trick creates a ranking and I highly doubt that's what you want! Example:Solution
We need to add, either to
chloride
or todf
, a row for each date+parameter+location combo where we want a break to occur.I'll pick the skippable dates manually:
We can generate the parameters and locations to skip on these dates:
Then we create a data frame of all permutations of these three criteria, and make sure the columns have the same names as those in
df
:Now we have in
df_skip
a single row for each combo we want to plot a break in:Finally we add
df_skip
to the originaldf
and run the plot again:You'll get a warning about missing values, but since those are intentional we can ignore that.
Complete code