giocomai / ganttrify

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

Gray colour in the plot #30

Closed wintermute221 closed 2 years ago

wintermute221 commented 2 years ago

Hi there,

Thank you for your amazing package. I found it really elegant to generate a gantt plot.

I just encountered a problem when I used it in R. This is the code I've used:

install.packages("remotes")
remotes::install_github("giocomai/ganttrify")

library("ganttrify")

test_48 <- WholeEngDPlan
test_48[11,4] <- 48

ganttrify(project = test_48,
          project_start_date = "2021-09", 
          month_breaks = 3,
          hide_wp = TRUE,
          month_number_label = FALSE,
          mark_quarters = TRUE,
          )

But the plot I generated is in gray, not in red and green as shown in the example. So I was just wondering why this happened.

Screenshot 2022-03-10 at 00 23 01

Additionally, can I also ask if I want to add a label 'Sep 2025' to the final row what should I do?

Many thanks.

giocomai commented 2 years ago

Hi, and glad you found the package useful. As you may have guessed from the readme, it was written quickly, and has a number of issues that I plan to fix next time I'll have the chance.

As for the breaks on the x axis, you can customise them as you would in other ggplots, e.g. with:

ganttrify(project = test_48,
          project_start_date = "2021-09", 
          month_breaks = 3,
          hide_wp = TRUE,
          month_number_label = FALSE,
          mark_quarters = TRUE
          ) +
   theme(axis.title.x=element_blank()) +
  scale_x_date(date_labels = "%b %Y",
               breaks = scales::pretty_breaks(10),
               position = "top")

You can of course also set manually all breaks.

As for the grey part... not sure what is going on, as I can't reproduce without your data. Can you make a minimal reproducible example that I can reproduce?

I see that you have a trailing comma at the end of mark_quarters = TRUE,, and it shouldn't be there.

Another thing that may cause issues is when you have different activities with exactly the same name in different WPs. Just add a space or something, and the issue should go.

Your case does seem to be different, but without some example I can reproduce, I can't troubleshoot this further and make sure it is fixed in future releases.

wintermute221 commented 2 years ago

Hi, thank you for getting back to me so quickly.

I think the grey part might be caused by the WP column in my input data as you suggested - I have left the WP column blank since I don't want to divide my data into sections. This is the data I input. Perhaps I shouldn't have left them blank?

Additionally, another question just occurred to me today - is it possible to have two starting dates and two ending dates for one row? Because some of the work will contain two subunits done in different time periods and I want to show them in the figure together. So it will produce something like this:

Screenshot 2022-03-11 at 18 22 32

Hope this question makes sense.

Many thanks.

giocomai commented 2 years ago

I couldn't access the data, but I think I got it.

wintermute221 commented 2 years ago

Amazing. That's exactly the solution to my problem. I just gave it a try and it worked. Thank you so much for your help!