I'm working on a Quarto project in VS code with a .qmd
file that includes a ggplot2 plot. The plot displays correctly in an interactive R session, but when I preview or render the .qmd
to HTML, I get a 404 error referencing a missing figure file:
"
Watching files for changes
Browse at http://localhost:5335/
Rendering HTML preview [index.qmd]
GET: /
GET: /notebooks/01_data_exploration-preview.html
/notebooks/01_data_exploration_files/figure-html/germ-1.png (404: Not Found) "
My code block looks like this:
# Filter only for Germany
mean_per_regiontype_DE <- mean_per_regiontype %>%
filter(country == "DE")
# Create plot
p <- ggplot(mean_per_regiontype_DE, aes(x = month, y = mean_active_per_100k, color = lage_typ)) +
geom_line() +
geom_point() +
scale_x_date(date_breaks = "1 month", date_labels = "%b %Y") +
labs(title = "Germany: Mean active per 100k pro Regionstyp",
x = "Month",
y = "Mean active per 100k",
color = "Region type") +
theme_minimal() +
theme(axis.text.x = element_text(angle = 90, hjust = 1))
# Explicitly print the plot
print(p)
The figure actually seems to be saved in a different folder than Quarto expects. How can I make sure Quarto places the figure in the correct location so it shows up in my final HTML document?
Any help or suggestions are much appreciated!