Skip to content

Commit

Permalink
- manually define breaks for geom_contour() and geom_label_contour() …
Browse files Browse the repository at this point in the history
…via pretty(), as breaks are not pretty when chosen by geom_label_contour() (fixes Davidatlarge#1)

- add sliderInput() to define number of contours in plot
  • Loading branch information
Marko Lipka committed Aug 23, 2020
1 parent db335fa commit c2f1c4c
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions Shiny_carb_plot.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,17 @@ inputPanel(
selectInput(inputId = "parameter",
label = "dependent parameter",
choices = c("ALK", "DIC", "fCO2", "fCO2insitu", "fCO2pot",
"HCO3", "OmegaAragonite", "OmegaCalcite", "pCO2", "pCO2insitu", "pCO2pot", "pH"))
"HCO3", "OmegaAragonite", "OmegaCalcite", "pCO2", "pCO2insitu", "pCO2pot", "pH")),
sliderInput(inputId = "bins",
label = "number of bins in plot",
min = 3, max = 42, value = 11)
)
renderPlot({
carb.data() %>%
ggplot(aes_string(x = "co2", y = "co3", z = input$parameter)) +
geom_contour(size = 1) +
metR::geom_label_contour() +
geom_contour(size = 1, breaks = pretty(carb.data()[, input$parameter], n = input$bins)) +
metR::geom_label_contour(breaks = pretty(carb.data()[, input$parameter], n = input$bins)) +
scale_x_continuous(expand = c(0, 0)) +
scale_y_continuous(expand = c(0, 0)) +
theme_light() +
Expand Down

0 comments on commit c2f1c4c

Please sign in to comment.