@@ -380,20 +380,22 @@ solar_noon <- function(coordinates, dates, tz) {
380
380
# ' [gg_photoperiod()] is a helper function to add photoperiod information to
381
381
# ' plots generated with [gg_day()] or [gg_days()]. The function can either draw
382
382
# ' on the `dawn` and `dusk` columns of the dataset or use the `coordinates` and
383
- # ' `solarDep` arguments to calculate the photoperiods. For better visibility,
384
- # ' the
383
+ # ' `solarDep` arguments to calculate the photoperiods. The time series must be
384
+ # ' based on a column called `Datetime`.
385
385
# '
386
386
# ' If used in combination with [gg_doubleplot()], with that function in the
387
387
# ' `type = "repeat"` setting (either manually set, or because there is only one
388
388
# ' day of data per group present), photoperiods need to be added separately
389
389
# ' through [add_photoperiod()], or the second photoperiod in each panel will be
390
390
# ' off by one day. See the examples for more information.
391
- # '
391
+ # '
392
392
# ' In general, if the photoperiod setup is more complex, it makes sense to add
393
393
# ' it prior to plotting and make sure the photoperiods are correct.
394
394
# '
395
395
# ' @inheritParams photoperiod
396
- # ' @param ggplot_obj A `ggplot` object generated with [gg_day()] or [gg_days()].
396
+ # ' @param ggplot_obj A `ggplot` object generated with [gg_day()] or [gg_days()]
397
+ # ' (or [gg_doubleplot()]. The dataset used to create these **must** have a
398
+ # ' `Datetime` column.
397
399
# ' @param coordinates A two element numeric vector representing the latitude and
398
400
# ' longitude of the location. If `NULL`, the default, the function will look
399
401
# ' for the `dawn` and `dusk` columns in the dataset. If those are not present,
@@ -405,8 +407,8 @@ solar_noon <- function(coordinates, dates, tz) {
405
407
# ' construct the photoperiod shading. Can be used to change the fill color or
406
408
# ' other aesthetic properties.
407
409
# ' @param on.top Logical scalar. If `TRUE`, the photoperiods will be plotted on
408
- # ' top of the existing plot. If `FALSE`, the photoperiods will be plotted
409
- # ' underneath the existing plot. Default is `FALSE`.
410
+ # ' top of the existing plot. If `FALSE`, the photoperiods will be plotted
411
+ # ' underneath the existing plot. Default is `FALSE`.
410
412
# '
411
413
# ' @returns a modified `ggplot` object with the photoperiods added.
412
414
# ' @export
@@ -415,46 +417,46 @@ solar_noon <- function(coordinates, dates, tz) {
415
417
# ' @examples
416
418
# ' coordinates <- c(48.521637, 9.057645)
417
419
# ' #adding photoperiods to a ggplot
418
- # ' sample.data.environment |>
419
- # ' gg_days() |>
420
+ # ' sample.data.environment |>
421
+ # ' gg_days() |>
420
422
# ' gg_photoperiod(coordinates)
421
- # '
423
+ # '
422
424
# ' #adding photoperiods prior to plotting
423
- # ' sample.data.environment |>
424
- # ' add_photoperiod(coordinates, solarDep = 0) |>
425
- # ' gg_days() |>
425
+ # ' sample.data.environment |>
426
+ # ' add_photoperiod(coordinates, solarDep = 0) |>
427
+ # ' gg_days() |>
426
428
# ' gg_photoperiod()
427
- # '
429
+ # '
428
430
# ' #more examples that are not executed for computation time:
429
431
# ' \donttest{
430
432
# ' #plotting photoperiods automatically works for both gg_day() and gg_days()
431
- # ' sample.data.environment |>
432
- # ' gg_day() |>
433
+ # ' sample.data.environment |>
434
+ # ' gg_day() |>
433
435
# ' gg_photoperiod(coordinates)
434
- # '
436
+ # '
435
437
# ' #plotting for gg_doubleplot mostly works fine
436
- # ' sample.data.environment |>
437
- # ' filter_Date(length = "2 days") |>
438
- # ' gg_doubleplot() |>
438
+ # ' sample.data.environment |>
439
+ # ' filter_Date(length = "2 days") |>
440
+ # ' gg_doubleplot() |>
439
441
# ' gg_photoperiod(coordinates)
440
- # '
441
- # ' #however, in cases where only one day of data per group is available, or the
442
- # ' #type = "repeat" setting is used, the photoperiods need to be added
442
+ # '
443
+ # ' #however, in cases where only one day of data per group is available, or the
444
+ # ' #type = "repeat" setting is used, the photoperiods need to be added
443
445
# ' #separately. Otherwise the second day will be off by one day in each panel.
444
- # ' #The visual difference is subtle, and might not be visible at all, as
446
+ # ' #The visual difference is subtle, and might not be visible at all, as
445
447
# ' #photoperiod only every changes by few minutes per day.
446
- # '
448
+ # '
447
449
# ' #WRONG
448
- # ' sample.data.environment |>
449
- # ' filter_Date(length = "1 days") |>
450
- # ' gg_doubleplot() |>
450
+ # ' sample.data.environment |>
451
+ # ' filter_Date(length = "1 days") |>
452
+ # ' gg_doubleplot() |>
451
453
# ' gg_photoperiod(coordinates)
452
- # '
454
+ # '
453
455
# ' #CORRECT
454
- # ' sample.data.environment |>
455
- # ' filter_Date(length = "1 days") |>
456
+ # ' sample.data.environment |>
457
+ # ' filter_Date(length = "1 days") |>
456
458
# ' add_photoperiod(coordinates) |>
457
- # ' gg_doubleplot() |>
459
+ # ' gg_doubleplot() |>
458
460
# ' gg_photoperiod()
459
461
# ' }
460
462
@@ -586,7 +588,9 @@ gg_photoperiod <- function(ggplot_obj,
586
588
xmin = midnight.before ,
587
589
xmax = dawn ,
588
590
ymin = - Inf ,
589
- ymax = Inf
591
+ ymax = Inf ,
592
+ y = NULL ,
593
+ x = NULL
590
594
),
591
595
alpha = alpha ,
592
596
...
@@ -597,7 +601,9 @@ gg_photoperiod <- function(ggplot_obj,
597
601
xmin = dusk ,
598
602
xmax = midnight.after ,
599
603
ymin = - Inf ,
600
- ymax = Inf
604
+ ymax = Inf ,
605
+ y = NULL ,
606
+ x = NULL
601
607
),
602
608
alpha = alpha ,
603
609
...
0 commit comments