giocomai / ganttrify

Create beautiful Gantt charts with ggplot2
https://ganttrify.europeandatajournalism.eu/
GNU General Public License v3.0
654 stars 61 forks source link

Customize spacing beween activities #56

Closed Jehops closed 1 month ago

Jehops commented 2 months ago

Hello,

Thanks for creating ganttrify!

I was asked to create a Gantt plot for a software release schedule.

image

A request I received was to reduce the vertical space between the point releases (activities) within a major version (wp; not displayed). In this case, it would be the vertical space between the lines for 13.3, 13.4, 13.5 and 14.1, 14.2, 14.3,..., while keeping the current space between major releases such as 13.5 and 14.1. Do you have any suggestions?

giocomai commented 2 months ago

The easiest workaround would be to set the alpha of wp to zero, rather than hide them completely, and then keep all your other customisations... would that work in your case?

library("ganttrify")

ganttrify(
  project = ganttrify::test_project,
  alpha_wp = 0,
  font_family = "Roboto Condensed"
)


ganttrify(
  project = ganttrify::test_project,
  alpha_wp = 0,
  font_family = "Roboto Condensed"
) +
  ggplot2::scale_y_discrete(name = NULL, labels = NULL)
#> Scale for y is already present.
#> Adding another scale for y, which will replace the existing scale.

Created on 2024-07-13 with reprex v2.1.1

Jehops commented 1 month ago

Thank you. That works great. For posterity, here is what I came up with.

library("ganttrify")
library("ggplot2")
setwd("/home/jrm/scm/ff/release_gantt")

rs.df <- read.csv("./schedule.csv")
rs.df$activity <- format(rs.df$activity,nsmall=1)
rel.df <- read.csv("./releases.csv",colClasses=rep("character",3))

png("./gantt_rs.png",3000,2000)
ganttrify(project=rs.df,by_date=T,month_number_label=F,size_text_relative=4,
          line_end_wp="butt",x_axis_position="bottom",show_vertical_lines=F,
          month_breaks=3,alpha_wp=0,font_family="Roboto Condensed",
          hide_activities=F,spots=rel.df,spot_border=0,size_activity=10) +
    scale_y_discrete(name=NULL,breaks=NULL,labels=NULL,expand=c(0,2,0.05,0))
dev.off()

image