Skip to content

Commit

Permalink
added a dummy line plot
Browse files Browse the repository at this point in the history
  • Loading branch information
mikheyev committed Jul 31, 2024
1 parent d1f8507 commit 67c7eed
Show file tree
Hide file tree
Showing 5 changed files with 114 additions and 91 deletions.
75 changes: 0 additions & 75 deletions .vdoc.r

This file was deleted.

4 changes: 2 additions & 2 deletions _freeze/index/execute-results/html.json

Large diffs are not rendered by default.

54 changes: 46 additions & 8 deletions docs/index.html

Large diffs are not rendered by default.

23 changes: 22 additions & 1 deletion docs/search.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,27 @@
"href": "index.html#colony-losses-not-real-data",
"title": "Australian honeybee colony loss survey",
"section": "2024 colony losses (not real data)",
"text": "2024 colony losses (not real data)\n\nCodelibrary(sf)\nlibrary(ggplot2)\nlibrary(ggiraph)\n\n# Load the shapefile\naus_shp <- st_read(\"../STE_2021_AUST_GDA2020.shx\", quiet = T)[1:8,] # remove islands\n\n# Simplify geometries with a lower tolerance and keep empty shapes\naus_shp_simplified <- st_simplify(aus_shp, dTolerance = 8000, preserveTopology = TRUE)\n\n# Ensure geometries are valid\naus_shp_simplified <- st_make_valid(aus_shp_simplified)\n\n# Remove empty geometries\naus_shp_simplified <- aus_shp_simplified[!st_is_empty(aus_shp_simplified), ]\n# Generate random numbers between 1 and 100 for each state\nset.seed(123) # For reproducibility\naus_shp_simplified$`2024 colony losses` <- sample(1:20, nrow(aus_shp_simplified), replace = TRUE)\n\n# Create ggplot object with interactive elements\np <- ggplot(aus_shp_simplified) +\n geom_sf_interactive(aes(fill = `2024 colony losses`, tooltip = `2024 colony losses`, data_id = `2024 colony losses`)) +\n scale_fill_viridis_c() +\n theme_minimal() + theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank(), axis.text = element_blank())\n\n# Render the interactive plot\ngirafe(\n ggobj = p,\n options = list(\n opts_hover(css = \"fill:orange;\"),\n opts_hover_inv(css = \"opacity:0.5;\"),\n opts_selection(type = \"single\", only_shiny = FALSE),\n opts_tooltip(css = \"font-size: 20px;\") \n )\n)"
"text": "2024 colony losses (not real data)\nSem iaculis porttitor pellentesque libero cras porttitor tellus ac. Ligula hendrerit praesent enim felis justo eros varius consectetur molestie. Justo suspendisse habitant nunc finibus nam. Eleifend ad lacinia curabitur taciti amet nisl sodales suspendisse orci consectetur senectus. Eleifend convallis maximus vivamus est condimentum porta est litora litora nunc fringilla maecenas non dui. Duis diam inceptos pharetra habitasse elit nibh eget scelerisque eleifend volutpat ad venenatis tempor iaculis mollis.\n\nCodelibrary(sf)\nlibrary(ggplot2)\nlibrary(ggiraph)\n\n# Load the shapefile\naus_shp <- st_read(\"../STE_2021_AUST_GDA2020.shx\", quiet = T)[1:8,] # remove islands\n\n# Simplify geometries with a lower tolerance and keep empty shapes\naus_shp_simplified <- st_simplify(aus_shp, dTolerance = 8000, preserveTopology = TRUE)\n\n# Ensure geometries are valid\naus_shp_simplified <- st_make_valid(aus_shp_simplified)\n\n# Remove empty geometries\naus_shp_simplified <- aus_shp_simplified[!st_is_empty(aus_shp_simplified), ]\n# Generate random numbers between 1 and 100 for each state\nset.seed(123) # For reproducibility\naus_shp_simplified$`2024 colony losses` <- sample(1:20, nrow(aus_shp_simplified), replace = TRUE)\nyears <- 2020:2024\nstates <- c(\"New South Wales\", \"Victoria\", \"Queensland\", \"South Australia\", \"Western Australia\", \"Tasmania\", \"Northern Territory\", \"Australian Capital Territory\")\nn_states <- length(states)\ncolony_losses <- data.frame(\n state = rep(states, each = length(years)),\n year = rep(years, times = n_states),\n losses = sample(1:20, n_states * length(years), replace = TRUE)\n)\n\n\n\n# Create ggplot object with interactive elements\np <- ggplot(aus_shp_simplified) +\n geom_sf_interactive(aes(fill = `2024 colony losses`, tooltip = `2024 colony losses`, data_id = `2024 colony losses`)) +\n scale_fill_viridis_c() +\n theme_minimal() + theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank(), axis.text = element_blank())\n\n# Render the interactive plot\ngirafe(\n ggobj = p,\n options = list(\n opts_hover(css = \"fill:orange;\"),\n opts_hover_inv(css = \"opacity:0.5;\"),\n opts_selection(type = \"single\", only_shiny = FALSE),\n opts_tooltip(css = \"font-size: 20px;\") \n )\n)"
},
{
"objectID": "index.html#colny-losses-over-five-years",
"href": "index.html#colny-losses-over-five-years",
"title": "Australian honeybee colony loss survey",
"section": "Colny losses over five years",
"text": "Colny losses over five years\n\nCodep_line <- ggplot(colony_losses, aes(x = year, y = losses, color = state, group = state)) +\n geom_line_interactive(aes(tooltip = paste(state, year, losses, sep = \": \"), data_id = state)) +\n geom_point_interactive(aes(tooltip = paste(state, year, losses, sep = \": \"), data_id = state)) +\n theme_minimal() +\n theme(\n panel.grid.major = element_blank(),\n panel.grid.minor = element_blank(),\n axis.text = element_text(size = 12),\n axis.title = element_text(size = 14)\n ) +\n labs( x = \"Year\", y = \"Colony Losses\")\n\ngirafe(\n ggobj = p_line,\n options = list(\n opts_hover(css = \"stroke-width:2;\"),\n opts_hover_inv(css = \"opacity:0.5;\"),\n opts_selection(type = \"single\", only_shiny = FALSE),\n opts_tooltip(css = \"font-size: 12px;\")\n )\n)"
},
{
"objectID": "index.html#colony-losses-over-five-years",
"href": "index.html#colony-losses-over-five-years",
"title": "Australian honeybee colony loss survey",
"section": "Colony losses over five years",
"text": "Colony losses over five years\n\nCodep_line <- ggplot(colony_losses, aes(x = year, y = losses, color = state, group = state)) +\n geom_line_interactive(aes(tooltip = paste(state, year, losses, sep = \": \"), data_id = state)) +\n geom_point_interactive(aes(tooltip = paste(state, year, losses, sep = \": \"), data_id = state)) +\n theme_minimal() +\n theme(\n panel.grid.major = element_blank(),\n panel.grid.minor = element_blank(),\n axis.text = element_text(size = 12),\n axis.title = element_text(size = 14)\n ) +\n labs( x = \"Year\", y = \"Colony Losses\")\n\ngirafe(\n ggobj = p_line,\n options = list(\n opts_hover(css = \"stroke-width:2;\"),\n opts_hover_inv(css = \"opacity:0.5;\"),\n opts_selection(type = \"single\", only_shiny = FALSE),\n opts_tooltip(css = \"font-size: 12px;\")\n )\n)"
},
{
"objectID": "index.html#graphics",
"href": "index.html#graphics",
"title": "Australian honeybee colony loss survey",
"section": "Graphics",
"text": "Graphics\nSem iaculis porttitor pellentesque libero cras porttitor tellus ac. Ligula hendrerit praesent enim felis justo eros varius consectetur molestie. Justo suspendisse habitant nunc finibus nam. Eleifend ad lacinia curabitur taciti amet nisl sodales suspendisse orci consectetur senectus. Eleifend convallis maximus vivamus est condimentum porta est litora litora nunc fringilla maecenas non dui. Duis diam inceptos pharetra habitasse elit nibh eget scelerisque eleifend volutpat ad venenatis tempor iaculis mollis."
}
]
49 changes: 44 additions & 5 deletions index.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ about:
- icon: envelope
text: Email
href: "mailto:[email protected]"
engine: knitr
---

::: {#about-block}
Expand All @@ -30,14 +31,20 @@ about:

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Feugiat ullamcorper nullam ac donec volutpat erat amet tempus quam cubilia egestas torquent nisi mollis lacus. Sagittis urna fringilla himenaeos est nec curabitur iaculis nisl risus amet accumsan venenatis nulla. Orci accumsan hendrerit lacus litora cras placerat et ad ligula tellus platea. Viverra interdum gravida et condimentum quis placerat integer fusce.



## Graphics

Sem iaculis porttitor pellentesque libero cras porttitor tellus ac. Ligula hendrerit praesent enim felis justo eros varius consectetur molestie. Justo suspendisse habitant nunc finibus nam.
Eleifend ad lacinia curabitur taciti amet nisl sodales suspendisse orci consectetur senectus. Eleifend convallis maximus vivamus est condimentum porta est litora litora nunc fringilla maecenas non dui. Duis diam inceptos pharetra habitasse elit nibh eget scelerisque eleifend volutpat ad venenatis tempor iaculis mollis.

Praesent ac integer mi eros odio etiam donec congue pellentesque scelerisque accumsan ultricies. Sodales phasellus senectus metus duis tellus ad tellus auctor congue quam litora quam euismod donec faucibus.

## 2024 colony losses (not real data)
```{r message=F}
# Colony losses (not real data)


```{r message=F}
#| layout-ncol: 2
library(sf)
library(ggplot2)
library(ggiraph)
Expand All @@ -56,12 +63,21 @@ aus_shp_simplified <- aus_shp_simplified[!st_is_empty(aus_shp_simplified), ]
# Generate random numbers between 1 and 100 for each state
set.seed(123) # For reproducibility
aus_shp_simplified$`2024 colony losses` <- sample(1:20, nrow(aus_shp_simplified), replace = TRUE)
years <- 2020:2024
states <- c("New South Wales", "Victoria", "Queensland", "South Australia", "Western Australia", "Tasmania", "Northern Territory", "Australian Capital Territory")
n_states <- length(states)
colony_losses <- data.frame(
state = rep(states, each = length(years)),
year = rep(years, times = n_states),
losses = sample(1:20, n_states * length(years), replace = TRUE)
)
# Create ggplot object with interactive elements
p <- ggplot(aus_shp_simplified) +
geom_sf_interactive(aes(fill = `2024 colony losses`, tooltip = `2024 colony losses`, data_id = `2024 colony losses`)) +
scale_fill_viridis_c() +
theme_minimal() + theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank(), axis.text = element_blank())
theme_minimal() + theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank(), axis.text = element_blank()) + labs(title = "2024 winter losses") + guides(fill = guide_legend(title = NULL))
# Render the interactive plot
girafe(
Expand All @@ -74,5 +90,28 @@ girafe(
)
)
```
p_line <- ggplot(colony_losses, aes(x = year, y = losses, color = state, group = state)) +
geom_line_interactive(aes(tooltip = paste(state, year, losses, sep = ": "), data_id = state)) +
geom_point_interactive(aes(tooltip = paste(state, year, losses, sep = ": "), data_id = state)) +
theme_minimal() +
theme(
panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
axis.text = element_text(size = 12),
axis.title = element_text(size = 14),
legend.position = "bottom"
) +
labs(title = "Losses over 5 years", x = "Year", y = "Colony Losses") +
guides(color = guide_legend(title = NULL))
girafe(
ggobj = p_line,
options = list(
opts_hover(css = "stroke-width:2;"),
opts_hover_inv(css = "opacity:0.5;"),
opts_selection(type = "single", only_shiny = FALSE),
opts_tooltip(css = "font-size: 12px;")
)
)
```

0 comments on commit 67c7eed

Please sign in to comment.