-
Notifications
You must be signed in to change notification settings - Fork 65
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
Modifying the month labelling #59
Comments
There's no obvious way to accomplish this through parameters. Or to be more precise, there's an easy way to have the "M" label only each 4 months, but not an obvious way to start from zero. As these gantt charts are ultimately just ggplot2 objects, it is still possible to customise it as much as you like - in this case, but re-creating the x axis labels - but you should then set manually some parameters. See below examples for both scenarios library("ganttrify")
ganttrify(
project = ganttrify::test_project,
project_start_date = "2025-01",
font_family = "Roboto Condensed",
month_breaks = 4
) # Customising all
start_date <- as.Date("2025-01-15") # place start date in the middle of the relevant month
end_date <- as.Date("2026-01-15")
month_breaks <- 4 # here is where you define the four months
date_breaks <- zoo::as.Date(zoo::as.yearmon(seq.Date(
from = start_date,
to = end_date,
by = paste(month_breaks, "months") # here is where you define the four months
)), frac = 0.5)
ganttrify(
project = ganttrify::test_project,
project_start_date = "2025-01",
font_family = "Roboto Condensed"
) +
ggplot2::scale_x_date(
name = NULL,
breaks = date_breaks,
date_labels = "%b\n%Y",
minor_breaks = NULL,
sec.axis = ggplot2::dup_axis(
labels = paste0("M",
(seq_along(date_breaks)) * month_breaks - (month_breaks)))
)
#> Scale for x is already present.
#> Adding another scale for x, which will replace the existing scale. Created on 2024-12-24 with reprex v2.1.1 |
Thank you for the swift response. This was helpful! |
Is it possible to report the Month label starting from M0 and then continue with M4, M8...? If yes, please clarify how.
The text was updated successfully, but these errors were encountered: