dummy-link

PlotRecipes

Assorted recipes to be used with Plots.jl

First Commit

05/07/2016

Last Touched

25 days ago

Commit Count

72 commits

Readme

PlotRecipes

Build Status

Primary author: Thomas Breloff (@tbreloff)

This repo maintains a collection of recipes for machine learning, graph analysis, finance, and more. It uses the powerful machinery of Plots and RecipesBase to turn simple transformations into flexible visualizations.

PlotRecipes also exports the recipes in StatPlots.jl, which is a collection of statistics recipes, including functionality for DataFrames and Distributions.


Examples


Graphs

Spectral

using PlotRecipes
n = 15
A = Float64[(rand()<0.5 ? 0 : rand()) for i=1:n,j=1:n]
for i=1:n
    A[i,1:i-1] = A[1:i-1,i]
end
node_weights = 1:n

graphplot(A,
    node_weights = 1:n,
    marker = (:heat, :rect),
    line = (3, 0.5, :blues),
    marker_z = 1:n,
    names = 1:n
)

graphplot(A,
    node_weights = 1:n,
    dim = 3,
    line = (3, 0.5, :blues),
    marker_z = 1:n
)

Fun with algos. Visualizing a stress-driven layout algorithm

Arc Diagrams

using PlotRecipes
plot(
    arcdiagram(['A','A','A','B'], ['B','C','D','A'], [1,2,3,1]),
    arcdiagram(rand(10), rand(10)),
    arcdiagram(rand(10), rand(10), rand(10)),
    arcdiagram(rand(10,10)),
    arcdiagram(Symmetric(rand(10,10))),
    arcdiagram(sparse([0 0 0; 1 1 0; 1 1 1]))
)


Julia code -- AST

using PlotRecipes
pyplot(ma=0.8,lc=:white,mc=:white,size=(1000,800))
theme(:dark)

code = :(
function transform!{T}(act::Activation{:softmax,T})
    val = forward!(act.input)
    out = act.output.val
    for i=1:act.n
        out[i] = exp(val[i])
    end
    s = one(T) / sum(out)
    for i=1:act.n
        out[i] *= s
    end
    out
end
)

plot(code, fontsize=11, shorten=0.2, axis_buffer=0.05)


Julia Type Trees

using PlotRecipes, Learn
pyplot(size=(800,500))
theme(:dark)
plot(Learnable, method=:tree)


Maps and Shapefile.jl

using PlotRecipes, Shapefile
dir = "https://github.com/nvkelso/natural-earth-vector/raw/master/110m_physical/"
fn = "ne_110m_land.shp"
run(`wget $dir/$fn -P /tmp/`)
shp = open("/tmp/$fn") do fd
    read(fd, Shapefile.Handle)
end
shapeplot(shp.shapes, c=:grey)


Portfolio Composition Maps

using PlotRecipes
tickers = ["IBM", "Google", "Apple", "Intel"]
N = 10
D = length(tickers)
weights = rand(N,D)
weights ./= sum(weights, 2)
returns = sort!((1:N) + D*randn(N))

portfoliocomposition(weights, returns, labels = tickers')


StatPlots.jl


corrplot

using PlotRecipes
M = randn(1000,4)
M[:,2] += 0.8sqrt(abs(M[:,1])) - 0.5M[:,3] + 5
M[:,3] -= 0.7M[:,1].^2 + 2

corrplot(M, label = ["x$i" for i=1:4])

--

Marginal Histograms

using PlotRecipes, Distributions
n = 1000
x = rand(Gamma(2), n)
y = -0.5x + randn(n)

marginalhist(x, y, fc=:plasma, bins=40)