1
$\begingroup$

I am analyzing a population movement pattern and I would like to design a visualization like this one:

Desired sample data visualization.

Is there any tool or language (preferably R) I can use for that purpose?

Here is a sample of my dataset.

$\endgroup$

2 Answers 2

1
$\begingroup$

Of course you can reproduce that graph with some ggplot!

enter image description here

Here is the code to create it:

library(ggplot2)
library(scales)

df <- read.csv2('Graphs_SK.csv')    

p <- ggplot(data = df, aes(x = Governorate)) +
  geom_segment(aes(y = Mid.May.2015, yend = Dec.16, xend = Governorate),
               color = 'grey', size = 1) +
  geom_point(aes(y = Mid.May.2015, color = 'start'), size = 2) +
  geom_point(aes(y = Dec.16, color = 'end'), size = 2) +
  scale_colour_manual(name = '(Population in millions)', 
                      labels = c('May 2015', 'Dec 2016'), 
                      values = c('start' = 'steelblue4', 'end' = 'steelblue')) +
  scale_y_continuous(labels = comma, name = '', position = 'top') +
  coord_flip() +
  ggtitle('1 Year of something of Governorate') +
  guides(colour = guide_legend(title.position = 'right')) +
  theme(panel.background = element_rect(fill = 'white'),
        legend.position = c(-.15, 1.03),
        legend.direction = 'horizontal',
        legend.justification = c(0, 0),
        legend.key = element_rect(fill = NA),
        legend.title = element_text(size = 10),
        axis.text.y = element_text(hjust = 0),
        axis.ticks.y = element_line(size = NA), 
        plot.title = element_text(hjust = .5))
$\endgroup$
2
  • $\begingroup$ when I use Source or Source with Echo to run the script does not produce the plots. Even when I select the whole script with Ctrl+A, then Run the current line or selection (Ctrl+Enter) the does not produce the plot. Any clue? Thank you. Here is a PrtScn: dropbox.com/s/t2po7hd54f85om0/ggplots.jpg?dl=0 $\endgroup$
    – Samy Koffi
    Feb 18, 2017 at 9:30
  • $\begingroup$ Type p or print(p) in the console $\endgroup$
    – GGamba
    Feb 18, 2017 at 11:36
0
$\begingroup$

Gantt chart is what you need. There're numbers of visualization libraries which supports gantt chart.

Checkout this post: https://stackoverflow.com/questions/3550341/gantt-charts-with-r

$\endgroup$
1
  • $\begingroup$ Thank you, will try to address it in a Gantt chart perspective. $\endgroup$
    – Samy Koffi
    Feb 17, 2017 at 9:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.