Skip to content

Instantly share code, notes, and snippets.

@randyzwitch
Created July 17, 2014 19:47
Show Gist options
  • Save randyzwitch/109f6783696e123da836 to your computer and use it in GitHub Desktop.
Save randyzwitch/109f6783696e123da836 to your computer and use it in GitHub Desktop.
Re-creating WordPress chart using Gadfly
using Gadfly, DataFrames
set_default_plot_size(24cm, 8.5cm)
#Read in data using DataFrames package
df = readtable("visits_visitors.csv")
#Fill :Visitors with 0 to replace NA
df[:Visitors] = array(df[:Visitors], 0)
plot(df,
layer(x="Month", y="Visitors", Geom.bar,
Theme(default_color=color("#000099"), bar_spacing = 3mm)),
layer(x="Month", y="Views", Geom.bar,
Theme(default_color=color("#278DBC"), bar_spacing = 1mm)),
layer(yintercept=[0:2000:10000], Geom.hline, Theme(default_color=color("lightgray"))), #Make horizontal lines
#Plot properties, not layer properties
Guide.xlabel(""),
Guide.ylabel(""),
Guide.yticks(ticks=[0:2000:10000]), #Set ticks every 2000
Guide.xticks(ticks=[0:5:30]), #Print every 5th label
Scale.y_continuous(format=:plain), #Make y labels print normally, instead of scientific notation
Theme(grid_color=color("white"), grid_color_focused=color("white"))) #Hide grid
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment