Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change to "plot across all stations" #2

Open
sebastiandig opened this issue Jun 10, 2024 · 0 comments
Open

Change to "plot across all stations" #2

sebastiandig opened this issue Jun 10, 2024 · 0 comments

Comments

@sebastiandig
Copy link

@7yl4r

cruise_report_template.qmd#L80

Issue

From the issues in Frank's email about "plot across all stations":

  • it seems all the stations that are near each other in time are stacked. An argument can be added to fix the stacking issue.
    • example: cruise_reports/WS0618, where there are 28 stations present, but only 17 columns on the plot. You may be able to see small white lines on the plot and these are probably the different stations

Possible Update

starting on line 81: cruise_report_template.qmd#L80
you may need to test the result before proceeding.

  1. fix stacking issue
  • geom_col() + to geom_col(position = position_dodge(preserve = "single")) +
  • position_dodge(preserve = "single") this removes the stacking effect to be next to each other
  1. reverse depth to start with 0 m at the top
  • scale_y_reverse() +
  • this just makes 0 depth at the top
  • this can be added after labs() or theme_minimal()

example to see the difference:

librarian::shelf(
  quiet = TRUE,
  librarian,
  ggplot2, lubridate, tibble, dplyr
  )

test_data <- 
  tibble(
  date    = c(rep("2020-01-01", 20), rep("2020-01-10", 10)), 
  station = rep(c("stn1", "stn2", "stn3"), each = 10), 
  value   = rep(1:10, 3)
) |>
  mutate(
    date = as_date(date)
  )
 
# original:
ggplot(test_data, aes(x = date, y = value, fill = station)) +
  geom_col()

# updated:
ggplot(test_data, aes(x = date, y = value, fill = station)) +    
  geom_col(position = position_dodge(preserve = "single")) + # <--- fix stacking
  scale_y_reverse()                                          # <--- reverse depth

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant