Sankey Diagrams in R?

This plot can be created through the networkD3 package. It allows you to create interactive sankey diagrams. Here you can find an example. I also added a screenshot so you have an idea what it looks like. # Load package library(networkD3) # Load energy projection data # Load energy projection data URL <- paste0( “https://cdn.rawgit.com/christophergandrud/networkD3/”, … Read more

sql joins as venn diagram

I agree with Cade about the limitations of Venn diagrams here. A more apposite visual representation might be this. Tables SELECT A.Colour, B.Colour FROM A CROSS JOIN B SQL Fiddle The cross join (or cartesian product) produces a result with every combination of the rows from the two tables. Each table has 4 rows so … Read more

plot different color for different categorical levels using matplotlib

Imports and Sample DataFrame import matplotlib.pyplot as plt import pandas as pd import seaborn as sns # for sample data from matplotlib.lines import Line2D # for legend handle # DataFrame used for all options df = sns.load_dataset(‘diamonds’) carat cut color clarity depth table price x y z 0 0.23 Ideal E SI2 61.5 55.0 326 … Read more

Side-by-side plots with ggplot2

Any ggplots side-by-side (or n plots on a grid) The function grid.arrange() in the gridExtra package will combine multiple plots; this is how you put two side by side. require(gridExtra) plot1 <- qplot(1) plot2 <- qplot(1) grid.arrange(plot1, plot2, ncol=2) This is useful when the two plots are not based on the same data, for example … Read more