Something a little different today for a quick chat about my latest
project and why I’m finding the plotly
package so helpful!
Are you like me and physically can’t function unless you’ve got a to do list in front of you? Well even if you’re not, imagine my pain while I’m wearing my non - Locke Data hat and trying to plan out the final year of my PhD thesis!
I needed something that updated easily, something visual and something
to keep my supervisors in the know. I’ve previously made gantt charts
using LaTeX but found it ridiculously clunky to get working and decided
there had to be a better way. And if I could include interactivity then
all the better, which is how I discovered plotly
.
Plotly
The plotly package makes interactive, publication quality graphs online. It uses the JavaScript graphing library and is really versatile! You can make graphs, maps, 3D plots and, as I’m about to explain, gantt charts.
Step by Step Gantt Chart
Install the packages you need for generating the gantt chart
1 |
|
Setting fonts isn’t necessary as there are defaults, but it’s always nice to know how to do it should you want to.
1 |
|
Set a title for the X axis. Uncomment the Y axis if you’d like to label that too :)
1 |
|
Read in your data
To make this gantt chart work, you need a column with a date you intend
to start
the task - we’ll make sure this is formatted in a minute. You
also need a column with a duration
to generate the length of the bar
for each task (this is in days in my case!) and if you want to group and colour code your tasks, it’s
the Chapter
column which does this.
The Task
and Progress
columns aren’t necessary, but they are good
for labelling and keeping yourself accountable, and an easy way to share
updates with people who are checking up on your
progress!
1 |
|
1 |
|
Make sure your date column is correctly formatted
1 |
|
Next generate a list of colours. This corresponds to my Chapter
column, so change this accordingly. It creates a list assigning a colour
to each group of
tasks
1 |
|
The next chunk of code generates a date line updated automatically based on your computer’s system date.
1 |
|
Build your plot combining all the elements you generated earlier. Change
the text
section to personalise your chart
1 |
|
Now simply plot your chart and add axis labels, your title and ‘Today’s date’ - The plotly package will generate an interactive chart that you can zoom, hover and share!
1 |
|
Ta-Dah! Now all I have to do is stick to it…