Closed HanselPalencia closed 2 years ago
personally, I think this is outside the scope of this package, as it's already something that ggplot handles well with the ylim()
function. for instance:
library(tidyverse)
library(NHSRplotthedots)
ae_df <- NHSRdatasets::ae_attendances |>
summarise(across(where(is.numeric), sum), .groups = "drop") |>
mutate(performance = 1 - breaches / attendances)
ae_spc <- ae_df |>
ptd_spc(
date_field = period,
value_field = performance,
target = 0.95
)
plot(ae_spc) +
ylim(0, NA) # lower bound set to 0, upper bound to NA (will figure out value from data)
I agree with Tom, I think this is out of scope for the package. The addition of the ylim() line solves the problem for both ggplot and plotly output, using the code below:
set.seed(1)
data <- rnorm(30) + 20
date <- seq.Date(from = as.Date("2020-01-01"), length.out = 30, by = "month")
dtf <- data.frame(
data = data,
date = date
)
p <- NHSRplotthedots::ptd_spc(dtf, data, date) %>%
ptd_create_ggplot() +
ylim(0, NA)
p
plotly::ggplotly(p)
Hi Everyone, so I had a project here at work recently where my boss asked me to implement some hard zeroes on some SPC charts. I was able to achieve this by manipulating the original
ptd_create_ggplot
funtion.Basically its just a really simple limits change instead of an overall change in breaks, labels, etc. Can we get this added as regular functionality? (i.e. add some if else statements to account for if someone wants to change initial value of y axis)
I can do it if it's something that the overall community thinks is a good idea.
I would also like to note that attempting to manipulate the limits, labels, etc. is very difficult after the fact as when you feed this plot output into say
ggplotly()
, it absorbs the originalggplot()
limits, labels, etc. Even using thelayout()
function in{plotly}
does not correct the axis limits or labels.