View source: R/ggpostcard_example_sunrise.R
ggpostcard_example_sunrise | R Documentation |
This example makes a postcard with a pretty ggplot that gives you when sunrise and sunset is over the course of the year.
ggpostcard_example_sunrise(
location_lat = NULL,
location_long = NULL,
location_tz = NULL,
location_name = NULL,
year = NULL,
...
)
location_lat |
the latitude of the location |
location_long |
the longitude of the location |
location_tz |
a tz time zone string of the style taken by R functions like as.POSIXct |
location_name |
string for the name to show for the location (ex: "Seattle, WA") |
To get the longitude and latitude for your location, you can click a place in Google maps. To get the time zone, you can use the Wikipedia list of time zone codes
This function uses an external API https://sunrise-sunset.org/api. While the package has some built-in caching, if you call the function with too many locations in a short period of time your IP will be temporarily blocked.
If all of the inputs are NULL, the function defaults to using Seattle, Washington.
a ggplot2 plot to pass to ggpostcard
Other ggpostcard_examples:
ggpostcard_example_contouR()
,
ggpostcard_example_rstereogram()
library(ggirl)
location_lat <- 47.6062
location_long <- -122.3321
location_tz <- "America/Los_Angeles"
location_name <- "Seattle, WA"
return_address <- address(name = "Jacqueline Nolis", address_line_1 = "111 North St",
city = "Seattle", state = "WA",
postal_code = "11111", country = "US")
contact_email <- "fakeemailforreal@gmail.com"
send_addresses <- address(name = "Fake Personname", address_line_1 = "250 North Ave",
city = "Boston", state = "MA",
postal_code = "22222", country = "US")
messages <- "Look at this cool plot I found!"
plot <- ggpostcard_example_sunrise(location_lat, location_long, location_tz, location_name)
ggpostcard(plot = plot,
contact_email = contact_email, return_address = return_address,
send_addresses = send_addresses, messages = messages)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.