Ganttrify
Create beautiful Gantt charts with ggplot2
Install / Use
/learn @giocomai/GanttrifyREADME
ganttrify
<!-- badges: start --> <!-- badges: end -->ganttrify facilitates the creation of nice-looking Gantt charts,
commonly used in project proposals and project management.
If you just want to check this out in an interactive web interface, click here and enjoy. Some more context in this blog post.
Read on for more details and examples.
Motivation
It is possible to find online documented attempts at facilitating the creation of Gantt charts from R. Some of them (e.g. this and this) use ‘ggplot2’, but I feel they do not look very nice. The same goes for the answers I found in the relevant Stackoverflow question.
Even Plotly enables the creation of Gantt charts in R, but again, I don’t like the end result.
I did find a solution that was rather visually satisfying, but it was in base R, and all the cool kids nowadays know that base plotting in R exists only for compatibility with S: not an option! (Hey, I’m joking, don’t @ me!)
Given what is evidently my posh taste for Gantt charts, I had no other option than making this package with a pretentious, gentrified name, instead of the obvious “ganttr”.
Please welcome ganttrify.
Disclaimer
More seriously, this has been a quick attempt at making decent-looking Gantt charts.
And yes, I will enable all the customisations you like, but first I actually need to submit this project.
[Thanks to all who contributed suggestions via issues and pull requests!]
[This package has been developed as a personal endeavour, originally conceived for grant writing at my employer (OBCT/CCI)]. The Shiny interface, now hosted in a separate repository, has been developed for EDJNet, the European Data Journalism Network.
Features
Take an adequately formatted spreadsheet and turn it into a Gantt chart made with ggplot2.
Installation
You can install the development version from GitHub with:
# install.packages("remotes")
remotes::install_github("giocomai/ganttrify")
Or from R-universe:
install.packages("ganttrify",
repos = c(
"https://giocomai.r-universe.dev",
"https://cloud.r-project.org"
)
)
Example
Here is an example project:
| wp | activity | start_date | end_date | |:---------------------------|:----------------------------|-----------:|---------:| | WP1 - Whatever admin | 1.1. That admin activity | 1 | 6 | | WP1 - Whatever admin | 1.2. Another admin activity | 3 | 6 | | WP1 - Whatever admin | 1.3. Fancy admin activity | 4 | 7 | | WP2 - Whatever actual work | 2.1. Actual stuff | 5 | 10 | | WP2 - Whatever actual work | 2.2. Actual R&D stuff | 6 | 12 | | WP2 - Whatever actual work | 2.3. Really real research | 9 | 12 | | WP2 - Whatever actual work | 2.4. Ethics! | 3 | 5 | | WP2 - Whatever actual work | 2.4. Ethics! | 8 | 9 | | WP3 - Dissemination | 3.1. Disseminate near | 6 | 9 | | WP3 - Dissemination | 3.1. Disseminate near | 12 | 12 | | WP3 - Dissemination | 3.2. Disseminate far | 8 | 12 |
Month since the beginning of the project are used as reference in order to make it easier to change the date when the project starts without needing to change the timing of all activities.
If you prefer to include dates instead of month numbers, please see additional examples below.
library("ganttrify")
ganttrify(
project = ganttrify::test_project,
project_start_date = "2021-03",
font_family = "Roboto Condensed"
)
<img src="man/figures/README-gantt_chart-1.png" width="100%" /> [all
examples in this page will use the Roboto condensed font; if it is not
installed, you can use the default sans. See the Troubleshooting
section at the bottom of this readme.]
“But what if I wanted to add spot labels for events, deliverables, outputs, milestones, things like that?”, you asked.
Just put them in a table with these column names, and you will be served.
| activity | spot_type | spot_date | |:---------------------------|:----------|----------:| | 1.1. That admin activity | D | 5 | | 1.3. Fancy admin activity | E | 7 | | 2.2. Actual R&D stuff | O | 7 | | 2.2. Actual R&D stuff | O | 9 | | 2.2. Actual R&D stuff | O | 11 | | WP2 - Whatever actual work | M | 6 |
ganttrify(
project = ganttrify::test_project,
spots = ganttrify::test_spots,
project_start_date = "2021-03",
font_family = "Roboto Condensed"
)
<img src="man/figures/README-gantt_charts_with_events-1.png" width="100%" />
“I can’t read the text, can I change the text size?”, I heard. “Also, is it possible to outline quarters?”
You’re welcome.
ganttrify(
project = ganttrify::test_project,
spots = ganttrify::test_spots,
project_start_date = "2021-03",
size_text_relative = 1.2,
mark_quarters = TRUE,
font_family = "Roboto Condensed"
)
<img src="man/figures/README-gantt_charts_resized_text-1.png" width="100%" />
It appears that some of you don’t like having a line for the working
package and are fine with just lines for activities. Did you mean it
like this? (also, consider setting hide_activities to TRUE if on the
contrary you want to hide activities and keep only working packages)
ganttrify(
project = ganttrify::test_project,
hide_wp = TRUE,
font_family = "Roboto Condensed"
)
<img src="man/figures/README-gantt_no_wp-1.png" width="100%" />
Or perhaps, you did want to keep the name of working package on the left, but just felt that the horizontal line for the WP is redundant? Let’s make the WP lines invisible, and nobody will ever know they’re there!
ganttrify(
project = ganttrify::test_project,
alpha_wp = 0,
font_family = "Roboto Condensed"
)
<img src="man/figures/README-gantt_no_wp_with_title-1.png" width="100%" />
I felt that rounded line endings for the working packages, and “butt” ending for activities is the best combination of elegance and clarity.
Also, I like full opacity for the lines, but it’s ok if you don’t:
ganttrify(
project = ganttrify::test_project,
project_start_date = "2021-04",
alpha_wp = 0.9,
alpha_activity = 0.6,
line_end_wp = "round", # alternative values: "butt" or "square"
line_end_activity = "round", # alternative values: "butt" or "square"
font_family = "Roboto Condensed"
)
<img src="man/figures/README-gantt_butt_line_transparency-1.png" width="100%" />
If you use spot events, then there’s all sorts of opinions you can have
about the color and transparency of spot events, as well as the size and
padding around the text. Say, you want a larger box around the text, but
a semi-transparent background? There you go!
ganttrify(
project = ganttrify::test_project,
spots = ganttrify::test_spots,
project_start_date = "2021-04",
font_family = "Roboto Condensed",
spot_size_text_relative = 1.5,
spot_fill = ggplot2::alpha(c("white"), 0.7),
spot_padding = ggplot2::unit(0.4, "lines")
)
<img src="man/figures/README-spot_customisations-1.png" width="100%" />
Or perhaps you actually just want the label text, without any
background, or perhaps change the text colour. Be mindful that the text
may become hard to read on darker backgrounds, especially if reviewers
then print your proposal, but… you have been warned:
ganttrify(
project = ganttrify::test_project,
spots = ganttrify::test_spots,
project_start_date = "2021-04",
font_family = "Roboto Condensed",
spot_text_colour = "grey10",
spot_fontface = "bold",
spot_fill = NA,
spot_border = NA
)
<img src="man/figures/README-spot_text-1.png" width="100%" />
Some of us work on very long projects, and may need to declutter the chart to increase readability. So let’s show the month number only once every three months, and hide the thin vertical lines included by default.
test_36 <- ganttrify::test_project
test_36[11, 4] <- 36
ganttrify(
project = test_36,
project_start_date = "2021-04",
month_breaks = 3,
show_vertical_lines = FALSE,
font_family = "Roboto Condensed"
)
<img src="man/figures/README-gantt_36_months-1.png" width="100%" />
If you have many working packages, you may want to adjust the size of
the output, and choose palettes with more colours. You can always pass a
custom palette (e.g. by setting
colour_palette = c("#6ACCEA", "#00FFB8", "#B90000", "#6C919C")), but
if you’re looking for some inspiration, the package
MetBrewer with palettes
inspired by works at the Metropolitan Museum of Art in New York has some
options that may make your gantt chart even fancier.
test_project_df <- dplyr::bind_rows(
ganttrify::test_project,
tibble::tibble(
wp = ganttrify::test_project$wp %>% stringr::str_replace(pattern = "1", replacement = "4") %>% stringr::str_replace(
Related Skills
node-connect
338.0kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
83.4kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
338.0kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
commit-push-pr
83.4kCommit, push, and open a PR
