working on org/docs/test

This commit is contained in:
Thomas Breloff 2015-08-31 14:42:08 -04:00
parent b27bff5304
commit bc7f8e26f3
2 changed files with 64 additions and 28 deletions

View File

@ -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::AVec, f::Function; kw...) # one line, y = f(x)
plot(x::AMat, f::Function; kw...) # multiple lines, 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, 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, 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(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(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: 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 # 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: 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 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 # Author

View File

@ -81,21 +81,8 @@ const IMG_DIR = "$(ENV["HOME"])/.julia/v0.4/Plots/img/"
# --------------------------------------------------------- # ---------------------------------------------------------
# Qwt include("qwt.jl")
include("gadfly.jl")
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)
# --------------------------------------------------------- # ---------------------------------------------------------
@ -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): 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(y::AVec; kw...) # one line... x = 1:length(y)
plot(x::AVec, y::AVec; kw...) # one line (will assert length(x) == 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(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::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::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::AVec, f::Function; kw...) # one line, y = f(x)
plot(x::AMat, f::Function; kw...) # multiple lines, 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, 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(y::AVec{AVec}; kw...) # multiple lines, each with x = 1:length(y[i])
plot(x::AVec{AVec}, y::AVec{AVec}; kw...) # multiple lines, will assert length(x[i]) == length(y[i]) plot(x::AVec, y::AVec{AVec}; kw...) # multiple lines, will assert length(x) == length(y[i])
plot(n::Integer; kw...) # n lines, all empty (for updating plots) 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 TODO: DataFrames