Created
July 17, 2014 19:47
-
-
Save randyzwitch/109f6783696e123da836 to your computer and use it in GitHub Desktop.
Re-creating WordPress chart using Gadfly
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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