ggplot2: Plotting two or more overlapping density plots on the same graph

Learning R

One R Tip A Day uses a custom R function to plot two or more overlapping density plots on the same graph.

The same can be very easily accomplished in ggplot2.

View original post 126 more words


ggplot2: Don’t Try This With Excel

Learning R

Building on the original blog post “VBA to Split Data Range into Multiple Chart Series” by Jon Peltier, and the R version in this blog and in his blog, Charts & Graphs blog “shows 4 charts of the same data to demonstrate what Excel chart users are missing by not having a more powerful charting tool. /?/ These analytical displays are not readily available to even advanced Excel users”.

He is using base graphics to draw the plots, I will present the ggplot2 version.

View original post 479 more words

How Color Can Trick The Eye: 12 Fascinating Optical Illusions

Michael Sandberg's Data Visualization Blog

Source: Ann Swanson, 12 fascinating optical illusions show how color can trick the eye, The Washington Post, February 27, 2015,

It sounds inane, but the dress question was actually tricky: Some declared themselves firmly in the blue and black camp, only to have the dress appear white and gold when they looked back a few hours later.Wired had the best explanation of the science behind the dress’ shifting colors. When your brain tries to figure out what color something is, it essentially subtracts the lighting and background colors around it, or as the neuroscientist interviewed by Wired says, tries to “discount…

View original post 420 more words

How to Create Coefficient Plots in R the Easy Way

Didier Ruedin

Presenting regression analyses as figures (rather than tables) has many advantages, despite what some reviewers may think

coefplottables2graphs has useful examples including R code, but there’s a simpler way. There’s an R package for (almost) everything, and (of course) you’ll find one to produce coefficient plots. Actually there are several ones.

The one I end up using most is the coefplot function in the package arm. It handles most common models out of the box. For those it doesn’t, you can simply supply the coefficients. Here’s the code for the coefficient plot shown. The first two lines are just to get the data in case you’re interested in full replication.

The default in arm is to use a vertical layout, so coefplot(m1) works wonderfully. Often I prefer the horizontal layout, which is easily done with vertical=FALSE; I also add custom margins so that the variable…

View original post 361 more words