From bc7f8e26f3e1264a75473673a6c0191be8b44b8f Mon Sep 17 00:00:00 2001 From: Thomas Breloff Date: Mon, 31 Aug 2015 14:42:08 -0400 Subject: [PATCH] working on org/docs/test --- README.md | 48 ++++++++++++++++++++++++++++++++++++++++++++++-- src/Plots.jl | 44 ++++++++++++++++++-------------------------- 2 files changed, 64 insertions(+), 28 deletions(-) diff --git a/README.md b/README.md index 2613d04e..eec42ccb 100644 --- a/README.md +++ b/README.md @@ -92,12 +92,15 @@ Here are some various args to supply, and the implicit mapping (AVec == Abstract plot(x::AVec, f::Function; kw...) # one line, y = f(x) plot(x::AMat, f::Function; kw...) # multiple lines, yᵢⱼ = f(xᵢⱼ) plot(x::AVec, fs::AVec{Function}; kw...) # multiple lines, yᵢⱼ = fⱼ(xᵢ) + plot(y::AVec{AVec}; kw...) # multiple lines, each with x = 1:length(y[i]) plot(x::AVec, y::AVec{AVec}; kw...) # multiple lines, will assert length(x) == length(y[i]) plot(x::AVec{AVec}, y::AVec{AVec}; kw...) # multiple lines, will assert length(x[i]) == length(y[i]) plot(n::Integer; kw...) # n lines, all empty (for updating plots) -``` - TODO: DataFrames + # TODO: how do we handle NA values in dataframes? + plot(df::DataFrame; kw...) # one line per DataFrame column, labels == names(df) + plot(df::DataFrame, columns; kw...) # one line per column, but on a subset of column names +``` You can swap out `plot` for `subplot`. Each line will go into a separate plot. Use the layout keyword: @@ -109,6 +112,14 @@ You can swap out `plot` for `subplot`. Each line will go into a separate plot. # and the others will share the second row ``` +Other potential shorthands: + +``` + hist(args..., kw...) + scatter(args..., kw...) + heatmap(args..., kw...) +``` + Some keyword arguments you can set: ``` @@ -164,6 +175,39 @@ When plotting multiple lines, you can give every line the same trait by using th plot(rand(100,2); colors = [:red, RGB(.5,.5,0)], axiss = [:left, :right], width = 5) # note the width=5 is applied to both lines ``` +# TODO + +- [ ] Plot vectors/matrices +- [ ] Plot DataFrames +- [ ] Subplots +- [ ] Histograms +- [ ] 3D plotting +- [ ] Scenes/Drawing +- [ ] Graphs +- [ ] Interactivity (GUIs) + +- [ ] Gadfly.jl +- [ ] PyPlot.jl +- [ ] Winston.jl +- [ ] Gaston.jl +- [ ] GLPlot.jl +- [ ] Qwt.jl +- [ ] Bokeh.jl +- [ ] Plotly.jl +- [ ] GoogleCharts.jl +- [ ] Vega.jl +- [ ] PLplot.jl + +- [ ] TextPlots.jl +- [ ] ASCIIPlots.jl +- [ ] Sparklines.jl +- [ ] UnicodePlots.jl +- [ ] Hinton.jl (also outputs vector graphics) +- [ ] ImageTerm.jl + +- [ ] GraphViz.jl +- [ ] TikzGraphs.jl +- [ ] GraphLayout.jl # Author diff --git a/src/Plots.jl b/src/Plots.jl index 40497c06..ed00e38b 100644 --- a/src/Plots.jl +++ b/src/Plots.jl @@ -81,21 +81,8 @@ const IMG_DIR = "$(ENV["HOME"])/.julia/v0.4/Plots/img/" # --------------------------------------------------------- -# Qwt - -plot(::QwtPackage, args...; kw...) = Qwt.plot(args...; kw...) -subplot(::QwtPackage, args...; kw...) = Qwt.subplot(args...; kw...) -savepng(::QwtPackage, plt, fn::String, args...) = Qwt.savepng(plt, fn) - -# --------------------------------------------------------- - -# Gadfly - -plot(::GadflyPackage, y; kw...) = Gadfly.plot(; x = 1:length(y), y = y, kw...) -plot(::GadflyPackage, x, y; kw...) = Gadfly.plot(; x = x, y = y, kw...) -plot(::GadflyPackage; kw...) = Gadfly.plot(; kw...) -savepng(::GadflyPackage, plt, fn::String, args...) = Gadfly.draw(Gadfly.PNG(fn, args...), plt) - +include("qwt.jl") +include("gadfly.jl") # --------------------------------------------------------- @@ -156,17 +143,22 @@ Now that you know which plot object you're updating (new, current, or other), I' Here are some various args to supply, and the implicit mapping (AVec == AbstractVector and AMat == AbstractMatrix): ``` - plot(y::AVec; kw...) # one line... x = 1:length(y) - plot(x::AVec, y::AVec; kw...) # one line (will assert length(x) == length(y)) - plot(y::AMat; kw...) # multiple lines (one per column of x), all sharing x = 1:size(y,1) - plot(x::AVec, y::AMat; kw...) # multiple lines (one per column of x), all sharing x (will assert length(x) == size(y,1)) - plot(x::AMat, y::AMat; kw...) # multiple lines (one per column of x/y... will assert size(x) == size(y)) - plot(x::AVec, f::Function; kw...) # one line, y = f(x) - plot(x::AMat, f::Function; kw...) # multiple lines, yᵢⱼ = f(xᵢⱼ) - plot(x::AVec, fs::AVec{Function}; kw...) # multiple lines, yᵢⱼ = fⱼ(xᵢ) - plot(x::AVec, y::AVec{AVec}; kw...) # multiple lines, will assert length(x) == length(y[i]) - plot(x::AVec{AVec}, y::AVec{AVec}; kw...) # multiple lines, will assert length(x[i]) == length(y[i]) - plot(n::Integer; kw...) # n lines, all empty (for updating plots) + plot(y::AVec; kw...) # one line... x = 1:length(y) + plot(x::AVec, y::AVec; kw...) # one line (will assert length(x) == length(y)) + plot(y::AMat; kw...) # multiple lines (one per column of x), all sharing x = 1:size(y,1) + plot(x::AVec, y::AMat; kw...) # multiple lines (one per column of x), all sharing x (will assert length(x) == size(y,1)) + plot(x::AMat, y::AMat; kw...) # multiple lines (one per column of x/y... will assert size(x) == size(y)) + plot(x::AVec, f::Function; kw...) # one line, y = f(x) + plot(x::AMat, f::Function; kw...) # multiple lines, yᵢⱼ = f(xᵢⱼ) + plot(x::AVec, fs::AVec{Function}; kw...) # multiple lines, yᵢⱼ = fⱼ(xᵢ) + plot(y::AVec{AVec}; kw...) # multiple lines, each with x = 1:length(y[i]) + plot(x::AVec, y::AVec{AVec}; kw...) # multiple lines, will assert length(x) == length(y[i]) + plot(x::AVec{AVec}, y::AVec{AVec}; kw...) # multiple lines, will assert length(x[i]) == length(y[i]) + plot(n::Integer; kw...) # n lines, all empty (for updating plots) + + # TODO: how do we handle NA values in dataframes? + plot(df::DataFrame; kw...) # one line per DataFrame column, labels == names(df) + plot(df::DataFrame, columns; kw...) # one line per column, but on a subset of column names ``` TODO: DataFrames