Table Lens Display

94 views
Skip to first unread message

Simon Dorfman

unread,
Apr 30, 2014, 3:04:28 AM4/30/14
to ggp...@googlegroups.com
Hello,

I'd like to create something like this image:

Does anyone have any tips on how to get started creating such an image with ggplot2 (or some other R package)?​

Some more info about the above image: It comes from the cover of Stephen Few's book "Show Me the Numbers":

Stephen Few calls the above a "Table Lens Display". Is there some other name for it? The above image also has some other nice features like the "vs. Plan" vertical indicators: | and the color coordinated categorization of products.

Here is a tutorial for creating a Table Lens Display in Excel:
...but it is quite cumbersome and I can't figure out how to create those other features ("vs. Plan" vertical indicators: | and the color coordinated categorization of products) in Excel.

Thanks in advance for any help.

-Simon

Martin Bel

unread,
Apr 30, 2014, 9:48:23 AM4/30/14
to Simon Dorfman, ggplot2
Hi Simon,

Perhaps you should consider studying the ggplot2 documentation, TRY SOMETHING, and then ask for help.


Best.


--
--
You received this message because you are subscribed to the ggplot2 mailing list.
Please provide a reproducible example: https://github.com/hadley/devtools/wiki/Reproducibility
 
To post: email ggp...@googlegroups.com
To unsubscribe: email ggplot2+u...@googlegroups.com
More options: http://groups.google.com/group/ggplot2

---
You received this message because you are subscribed to the Google Groups "ggplot2" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ggplot2+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Vivek Patil

unread,
Apr 30, 2014, 1:08:59 PM4/30/14
to Martin Bel, Simon Dorfman, ggplot2
As Martin suggests, an attempt to get "something" done and sending a reproducible example with data greatly helps.Since I had Few's book on my desk when I read this, I put something together to get this started for you. The variance figure is not in percentage, but can be modified, as can other elements.

tea=c("Arabian","French Roast")
Sales=c(10000, 15000)
Plan=c(12000,12000)
Variance=c(-2000,3000)
df=data.frame(tea=tea,Sales=Sales,Plan=Plan,Variance=Variance)

library(ggplot2)
library(gridExtra)
library(ggthemes)
salesplan=ggplot(df,aes(x=tea,y=Sales,fill=tea))+geom_bar(stat="identity")+
  geom_segment(aes(x=as.numeric(df$tea)-.475,xend=as.numeric(df$tea)+.475,y=df$Plan,yend=df$Plan))+
  ggtitle("Sales vs Plan")+ coord_flip() +theme_few()+scale_fill_few("medium")+
  theme(legend.position="None", axis.title.y=element_blank(),axis.title.x=element_blank())

varianceplan=ggplot(df,aes(x=tea,y=Variance,fill=tea))+geom_bar(stat="identity")+
  coord_flip()+ggtitle("Variance to Plan")+theme_few()+scale_fill_few("medium")+
  theme(legend.position="None",axis.text.y = element_blank(),axis.title.y=element_blank(),
        axis.title.x=element_blank())

grid.arrange(salesplan,varianceplan,ncol=2)

Best,
Vivek
Reply all
Reply to author
Forward
0 new messages