readme and examples

This commit is contained in:
Thomas Breloff 2015-10-08 13:33:14 -04:00
parent a10e594da1
commit b5cdfe30ea
18 changed files with 71 additions and 31 deletions

View File

@ -33,6 +33,12 @@ First, add the package
```julia ```julia
Pkg.add("Plots") Pkg.add("Plots")
# if you want the latest features:
Pkg.checkout("Plots")
# or for the bleeding edge:
Pkg.checkout("Plots", "dev")
``` ```
then get any plotting packages you need (obviously, you should get at least one backend): then get any plotting packages you need (obviously, you should get at least one backend):
@ -129,11 +135,20 @@ plot(1:10, Any[rand(10), sin]) # plot 2 series, y = rand(10) for the
plot(dataset("Ecdat", "Airline"), :Cost) # plot from a DataFrame (call `dataframes()` first to import DataFrames and initialize) plot(dataset("Ecdat", "Airline"), :Cost) # plot from a DataFrame (call `dataframes()` first to import DataFrames and initialize)
``` ```
All plot methods accept a number of keyword arguments (see the tables below), which follow some rules:
- Many arguments have aliases which are replaced during preprocessing. `c` is the same as `color`, `m` is the same as `marker`, etc. You can choose how verbose you'd like to be. (see the tables below)
- There are some special arguments (`xaxis`, `yaxis`, `line`, `marker`, `fill` and the aliases `l`, `m`, `f`) which magically set many related things at once. (see the __Tip__ below)
- If the argument is a "matrix-type", then each column will map to a series, cycling through columns if there are fewer columns than series. Anything else will apply the argument value to every series.
- Many arguments accept many different types... for example the `color` (also `markercolor`, `fillcolor`, etc) argument will accept strings or symbols with a color name, or any `Colors.Colorant`, or a `ColorScheme`, or a symbol representing a `ColorGradient`, or an AbstractVector of colors/symbols/etc...
You can update certain plot settings after plot creation (not supported on all backends): You can update certain plot settings after plot creation (not supported on all backends):
```julia ```julia
plot!(title = "New Title", xlabel = "New xlabel", ylabel = "New ylabel") plot!(title = "New Title", xlabel = "New xlabel", ylabel = "New ylabel")
plot!(xlims = (0, 5.5), ylims = (-2.2, 6), xticks = 0:0.5:10, yticks = [0,1,5,10]) plot!(xlims = (0, 5.5), ylims = (-2.2, 6), xticks = 0:0.5:10, yticks = [0,1,5,10])
# using shorthands:
xaxis!("mylabel", :log10, :flip)
``` ```
With `subplot`, create multiple plots at once, with flexible layout options: With `subplot`, create multiple plots at once, with flexible layout options:
@ -170,9 +185,9 @@ vline!(args...; kw...) = plot!(args...; kw..., linetype = :vline)
ohlc(args...; kw...) = plot(args...; kw..., linetype = :ohlc) ohlc(args...; kw...) = plot(args...; kw..., linetype = :ohlc)
ohlc!(args...; kw...) = plot!(args...; kw..., linetype = :ohlc) ohlc!(args...; kw...) = plot!(args...; kw..., linetype = :ohlc)
title!(s::@compat(AbstractString)) = plot!(title = s) title!(s::AbstractString) = plot!(title = s)
xlabel!(s::@compat(AbstractString)) = plot!(xlabel = s) xlabel!(s::AbstractString) = plot!(xlabel = s)
ylabel!(s::@compat(AbstractString)) = plot!(ylabel = s) ylabel!(s::AbstractString) = plot!(ylabel = s)
xlims!{T<:Real,S<:Real}(lims::Tuple{T,S}) = plot!(xlims = lims) xlims!{T<:Real,S<:Real}(lims::Tuple{T,S}) = plot!(xlims = lims)
ylims!{T<:Real,S<:Real}(lims::Tuple{T,S}) = plot!(ylims = lims) ylims!{T<:Real,S<:Real}(lims::Tuple{T,S}) = plot!(ylims = lims)
xticks!{T<:Real}(v::AVec{T}) = plot!(xticks = v) xticks!{T<:Real}(v::AVec{T}) = plot!(xticks = v)
@ -190,45 +205,50 @@ Keyword | Default | Type | Aliases
---- | ---- | ---- | ---- ---- | ---- | ---- | ----
`:annotation` | `nothing` | Series | `:ann`, `:annotate`, `:annotations`, `:anns` `:annotation` | `nothing` | Series | `:ann`, `:annotate`, `:annotations`, `:anns`
`:axis` | `left` | Series | `:axiss` `:axis` | `left` | Series | `:axiss`
`:background_color` | `RGB{U8}(1.0,1.0,1.0)` | Plot | `:background`, `:bg`, `:bg_color`, `:bgcolor`
`:color` | `auto` | Series | `:c`, `:colors` `:color` | `auto` | Series | `:c`, `:colors`
`:color_palette` | `auto` | Plot | `:palette`
`:fill` | `nothing` | Series | `:area`, `:f`
`:fillcolor` | `match` | Series | `:fc`, `:fcolor`, `:fillcolors` `:fillcolor` | `match` | Series | `:fc`, `:fcolor`, `:fillcolors`
`:fillrange` | `nothing` | Series | `:fillranges`, `:fillrng` `:fillrange` | `nothing` | Series | `:fillranges`, `:fillrng`
`:foreground_color` | `auto` | Plot | `:fg`, `:fg_color`, `:fgcolor`, `:foreground`
`:group` | `nothing` | Series | `:g`, `:groups` `:group` | `nothing` | Series | `:g`, `:groups`
`:heatmap_c` | `(0.15,0.5)` | Series | `:heatmap_cs` `:heatmap_c` | `(0.15,0.5)` | Series | `:heatmap_cs`
`:label` | `AUTO` | Series | `:lab`, `:labels` `:label` | `AUTO` | Series | `:lab`, `:labels`
`:layout` | `nothing` | Plot |
`:legend` | `true` | Plot | `:leg`
`:line` | `nothing` | Series | `:l`
`:linestyle` | `solid` | Series | `:linestyles`, `:ls`, `:s`, `:style` `:linestyle` | `solid` | Series | `:linestyles`, `:ls`, `:s`, `:style`
`:linetype` | `path` | Series | `:linetypes`, `:lt`, `:t`, `:type` `:linetype` | `path` | Series | `:linetypes`, `:lt`, `:t`, `:type`
`:linewidth` | `1` | Series | `:linewidths`, `:lw`, `:w`, `:width` `:linewidth` | `1` | Series | `:linewidths`, `:lw`, `:w`, `:width`
`:marker` | `nothing` | Series | `:m`, `:mark`
`:markercolor` | `match` | Series | `:markercolors`, `:mc`, `:mcolor` `:markercolor` | `match` | Series | `:markercolors`, `:mc`, `:mcolor`
`:markershape` | `none` | Series | `:markershapes`, `:shape` `:markershape` | `none` | Series | `:markershapes`, `:shape`
`:markersize` | `6` | Series | `:markersizes`, `:ms`, `:msize` `:markersize` | `6` | Series | `:markersizes`, `:ms`, `:msize`
`:nbins` | `100` | Series | `:nb`, `:nbin`, `:nbinss`
`:reg` | `false` | Series | `:regression`, `:regs`
`:z` | `nothing` | Series | `:zs`
`:background_color` | `RGB{U8}(1.0,1.0,1.0)` | Plot | `:background`, `:bg`, `:bg_color`, `:bgcolor`
`:color_palette` | `auto` | Plot | `:palette`
`:foreground_color` | `auto` | Plot | `:fg`, `:fg_color`, `:fgcolor`, `:foreground`
`:layout` | `nothing` | Plot |
`:legend` | `true` | Plot | `:leg`
`:n` | `-1` | Plot | `:n` | `-1` | Plot |
`:nbins` | `100` | Series | `:nb`, `:nbin`, `:nbinss`
`:nc` | `-1` | Plot | `:nc` | `-1` | Plot |
`:nr` | `-1` | Plot | `:nr` | `-1` | Plot |
`:pos` | `(0,0)` | Plot | `:pos` | `(0,0)` | Plot |
`:reg` | `false` | Series | `:regression`, `:regs`
`:show` | `false` | Plot | `:display`, `:gui` `:show` | `false` | Plot | `:display`, `:gui`
`:size` | `(600,400)` | Plot | `:windowsize`, `:wsize` `:size` | `(600,400)` | Plot | `:windowsize`, `:wsize`
`:title` | `` | Plot | `:title` | `` | Plot |
`:windowtitle` | `Plots.jl` | Plot | `:wtitle` `:windowtitle` | `Plots.jl` | Plot | `:wtitle`
`:xaxis` | `nothing` | Plot |
`:xflip` | `false` | Plot | `:xflip` | `false` | Plot |
`:xlabel` | `` | Plot | `:xlab` `:xlabel` | `` | Plot | `:xlab`
`:xlims` | `auto` | Plot | `:xlim`, `:xlimit`, `:xlimits` `:xlims` | `auto` | Plot | `:xlim`, `:xlimit`, `:xlimits`
`:xscale` | `identity` | Plot | `:xscale` | `identity` | Plot |
`:xticks` | `auto` | Plot | `:xtick` `:xticks` | `auto` | Plot | `:xtick`
`:yaxis` | `nothing` | Plot |
`:yflip` | `true` | Plot | `:yflip` | `true` | Plot |
`:ylabel` | `` | Plot | `:ylab` `:ylabel` | `` | Plot | `:ylab`
`:ylims` | `auto` | Plot | `:ylim`, `:ylimit`, `:ylimits` `:ylims` | `auto` | Plot | `:ylim`, `:ylimit`, `:ylimits`
`:yrightlabel` | `` | Plot | `:y2lab`, `:y2label`, `:ylab2`, `:ylabel2`, `:ylabelright`, `:ylabr`, `:yrlab` `:yrightlabel` | `` | Plot | `:y2lab`, `:y2label`, `:ylab2`, `:ylabel2`, `:ylabelright`, `:ylabr`, `:yrlab`
`:yscale` | `identity` | Plot | `:yscale` | `identity` | Plot |
`:yticks` | `auto` | Plot | `:ytick` `:yticks` | `auto` | Plot | `:ytick`
`:z` | `nothing` | Series | `:zs`
Plot types: Plot types:
@ -316,9 +336,9 @@ __Tip__: Call `gui()` to display the plot in a window. Interactivity depends on
- [x] Plot vectors/matrices/functions - [x] Plot vectors/matrices/functions
- [x] Plot DataFrames - [x] Plot DataFrames
- [x] Grouping - [x] Grouping
- [ ] Annotations - [x] Annotations
- [ ] Scales - [x] Scales
- [ ] Categorical Inputs (strings, etc... for hist, bar? or can split one series into multiple?) - [x] Categorical Inputs (strings, etc... for hist, bar? or can split one series into multiple?)
- [ ] Custom markers - [ ] Custom markers
- [ ] Special plots (boxplot, ohlc?) - [ ] Special plots (boxplot, ohlc?)
- [x] Subplots - [x] Subplots

View File

@ -251,11 +251,15 @@ function buildReadme()
# build keyword arg table # build keyword arg table
table = "Keyword | Default | Type | Aliases \n---- | ---- | ---- | ----\n" table = "Keyword | Default | Type | Aliases \n---- | ---- | ---- | ----\n"
for d in (Plots._seriesDefaults, Plots._plotDefaults) allseries = merge(Plots._seriesDefaults, @compat(Dict(:line=>nothing, :marker=>nothing, :fill=>nothing)))
for k in Plots.sortedkeys(d) allplots = merge(Plots._plotDefaults, @compat(Dict(:xaxis=>nothing, :yaxis=>nothing)))
aliasstr = createStringOfMarkDownSymbols(aliases(Plots._keyAliases, k)) alldefs = merge(allseries, allplots)
table = string(table, "`:$k` | `$(d[k])` | $(d==Plots._seriesDefaults ? "Series" : "Plot") | $aliasstr \n") for k in Plots.sortedkeys(alldefs)
end # for d in (Plots._seriesDefaults, Plots._plotDefaults)
# for k in Plots.sortedkeys(d)
aliasstr = createStringOfMarkDownSymbols(aliases(Plots._keyAliases, k))
table = string(table, "`:$k` | `$(alldefs[k])` | $(haskey(allseries,k) ? "Series" : "Plot") | $aliasstr \n")
# end
end end
readme = replace(readme, "[[KEYWORD_ARGS_TABLE]]", table) readme = replace(readme, "[[KEYWORD_ARGS_TABLE]]", table)

View File

@ -39,9 +39,9 @@ plot(0:0.01:4π,[sin,cos])
Or make a parametric plot (i.e. plot: (fx(u), fy(u))) with plot(fx, fy, umin, umax). Or make a parametric plot (i.e. plot: (fx(u), fy(u))) with plot(fx, fy, umin, umax).
```julia ```julia
plot(sin,(x->begin # /home/tom/.julia/v0.4/Plots/docs/example_generation.jl, line 39: plot(sin,(x->begin # /home/tom/.julia/v0.4/Plots/docs/example_generation.jl, line 40:
sin(2x) sin(2x)
end),0,2π,leg=false,fill=(0,:orange)) end),0,2π,line=4,leg=false,fill=(0,:orange))
``` ```
![](../img/gadfly/gadfly_example_3.png) ![](../img/gadfly/gadfly_example_3.png)

View File

@ -39,9 +39,9 @@ plot(0:0.01:4π,[sin,cos])
Or make a parametric plot (i.e. plot: (fx(u), fy(u))) with plot(fx, fy, umin, umax). Or make a parametric plot (i.e. plot: (fx(u), fy(u))) with plot(fx, fy, umin, umax).
```julia ```julia
plot(sin,(x->begin # /home/tom/.julia/v0.4/Plots/docs/example_generation.jl, line 39: plot(sin,(x->begin # /home/tom/.julia/v0.4/Plots/docs/example_generation.jl, line 40:
sin(2x) sin(2x)
end),0,2π,leg=false,fill=(0,:orange)) end),0,2π,line=4,leg=false,fill=(0,:orange))
``` ```
![](../img/immerse/immerse_example_3.png) ![](../img/immerse/immerse_example_3.png)

View File

@ -1,6 +1,6 @@
# Examples for backend: pyplot # Examples for backend: pyplot
- Supported arguments: `annotation`, `axis`, `background_color`, `color`, `fillrange`, `fillcolor`, `foreground_color`, `group`, `label`, `layout`, `legend`, `linestyle`, `linetype`, `linewidth`, `markershape`, `markercolor`, `markersize`, `n`, `nbins`, `nc`, `nr`, `show`, `size`, `title`, `windowtitle`, `x`, `xlabel`, `xlims`, `xticks`, `y`, `ylabel`, `ylims`, `yrightlabel`, `yticks`, `xscale`, `yscale`, `xflip`, `yflip` - Supported arguments: `annotation`, `axis`, `background_color`, `color`, `color_palette`, `fillrange`, `fillcolor`, `foreground_color`, `group`, `label`, `layout`, `legend`, `linestyle`, `linetype`, `linewidth`, `markershape`, `markercolor`, `markersize`, `n`, `nbins`, `nc`, `nr`, `show`, `size`, `title`, `windowtitle`, `x`, `xlabel`, `xlims`, `xticks`, `y`, `ylabel`, `ylims`, `yrightlabel`, `yticks`, `xscale`, `yscale`, `xflip`, `yflip`, `z`
- Supported values for axis: `:auto`, `:left`, `:right` - Supported values for axis: `:auto`, `:left`, `:right`
- Supported values for linetype: `:none`, `:line`, `:path`, `:step`, `:stepinverted`, `:sticks`, `:scatter`, `:heatmap`, `:hexbin`, `:hist`, `:bar`, `:hline`, `:vline` - Supported values for linetype: `:none`, `:line`, `:path`, `:step`, `:stepinverted`, `:sticks`, `:scatter`, `:heatmap`, `:hexbin`, `:hist`, `:bar`, `:hline`, `:vline`
- Supported values for linestyle: `:auto`, `:solid`, `:dash`, `:dot`, `:dashdot` - Supported values for linestyle: `:auto`, `:solid`, `:dash`, `:dot`, `:dashdot`
@ -39,9 +39,9 @@ plot(0:0.01:4π,[sin,cos])
Or make a parametric plot (i.e. plot: (fx(u), fy(u))) with plot(fx, fy, umin, umax). Or make a parametric plot (i.e. plot: (fx(u), fy(u))) with plot(fx, fy, umin, umax).
```julia ```julia
plot(sin,(x->begin # /home/tom/.julia/v0.4/Plots/docs/example_generation.jl, line 39: plot(sin,(x->begin # /home/tom/.julia/v0.4/Plots/docs/example_generation.jl, line 40:
sin(2x) sin(2x)
end),0,2π,leg=false,fill=(0,:orange)) end),0,2π,line=4,leg=false,fill=(0,:orange))
``` ```
![](../img/pyplot/pyplot_example_3.png) ![](../img/pyplot/pyplot_example_3.png)

View File

@ -1,6 +1,6 @@
# Examples for backend: qwt # Examples for backend: qwt
- Supported arguments: `annotation`, `axis`, `background_color`, `color`, `fillrange`, `fillcolor`, `foreground_color`, `group`, `heatmap_c`, `label`, `layout`, `legend`, `linestyle`, `linetype`, `linewidth`, `markershape`, `markercolor`, `markersize`, `n`, `nbins`, `nc`, `nr`, `pos`, `reg`, `show`, `size`, `title`, `windowtitle`, `x`, `xlabel`, `xlims`, `xticks`, `y`, `ylabel`, `ylims`, `yrightlabel`, `yticks`, `xscale`, `yscale` - Supported arguments: `annotation`, `axis`, `background_color`, `color`, `color_palette`, `fillrange`, `fillcolor`, `foreground_color`, `group`, `heatmap_c`, `label`, `layout`, `legend`, `linestyle`, `linetype`, `linewidth`, `markershape`, `markercolor`, `markersize`, `n`, `nbins`, `nc`, `nr`, `pos`, `reg`, `show`, `size`, `title`, `windowtitle`, `x`, `xlabel`, `xlims`, `xticks`, `y`, `ylabel`, `ylims`, `yrightlabel`, `yticks`, `xscale`, `yscale`
- Supported values for axis: `:auto`, `:left`, `:right` - Supported values for axis: `:auto`, `:left`, `:right`
- Supported values for linetype: `:none`, `:line`, `:path`, `:steppre`, `:steppost`, `:sticks`, `:scatter`, `:heatmap`, `:hexbin`, `:hist`, `:bar`, `:hline`, `:vline` - Supported values for linetype: `:none`, `:line`, `:path`, `:steppre`, `:steppost`, `:sticks`, `:scatter`, `:heatmap`, `:hexbin`, `:hist`, `:bar`, `:hline`, `:vline`
- Supported values for linestyle: `:auto`, `:solid`, `:dash`, `:dot`, `:dashdot`, `:dashdotdot` - Supported values for linestyle: `:auto`, `:solid`, `:dash`, `:dot`, `:dashdot`, `:dashdotdot`
@ -39,7 +39,7 @@ plot(0:0.01:4π,[sin,cos])
Or make a parametric plot (i.e. plot: (fx(u), fy(u))) with plot(fx, fy, umin, umax). Or make a parametric plot (i.e. plot: (fx(u), fy(u))) with plot(fx, fy, umin, umax).
```julia ```julia
plot(sin,(x->begin # /home/tom/.julia/v0.4/Plots/docs/example_generation.jl, line 39: plot(sin,(x->begin # /home/tom/.julia/v0.4/Plots/docs/example_generation.jl, line 40:
sin(2x) sin(2x)
end),0,2π,line=4,leg=false,fill=(0,:orange)) end),0,2π,line=4,leg=false,fill=(0,:orange))
``` ```

View File

@ -33,6 +33,12 @@ First, add the package
```julia ```julia
Pkg.add("Plots") Pkg.add("Plots")
# if you want the latest features:
Pkg.checkout("Plots")
# or for the bleeding edge:
Pkg.checkout("Plots", "dev")
``` ```
then get any plotting packages you need (obviously, you should get at least one backend): then get any plotting packages you need (obviously, you should get at least one backend):
@ -129,11 +135,20 @@ plot(1:10, Any[rand(10), sin]) # plot 2 series, y = rand(10) for the
plot(dataset("Ecdat", "Airline"), :Cost) # plot from a DataFrame (call `dataframes()` first to import DataFrames and initialize) plot(dataset("Ecdat", "Airline"), :Cost) # plot from a DataFrame (call `dataframes()` first to import DataFrames and initialize)
``` ```
All plot methods accept a number of keyword arguments (see the tables below), which follow some rules:
- Many arguments have aliases which are replaced during preprocessing. `c` is the same as `color`, `m` is the same as `marker`, etc. You can choose how verbose you'd like to be. (see the tables below)
- There are some special arguments (`xaxis`, `yaxis`, `line`, `marker`, `fill` and the aliases `l`, `m`, `f`) which magically set many related things at once. (see the __Tip__ below)
- If the argument is a "matrix-type", then each column will map to a series, cycling through columns if there are fewer columns than series. Anything else will apply the argument value to every series.
- Many arguments accept many different types... for example the `color` (also `markercolor`, `fillcolor`, etc) argument will accept strings or symbols with a color name, or any `Colors.Colorant`, or a `ColorScheme`, or a symbol representing a `ColorGradient`, or an AbstractVector of colors/symbols/etc...
You can update certain plot settings after plot creation (not supported on all backends): You can update certain plot settings after plot creation (not supported on all backends):
```julia ```julia
plot!(title = "New Title", xlabel = "New xlabel", ylabel = "New ylabel") plot!(title = "New Title", xlabel = "New xlabel", ylabel = "New ylabel")
plot!(xlims = (0, 5.5), ylims = (-2.2, 6), xticks = 0:0.5:10, yticks = [0,1,5,10]) plot!(xlims = (0, 5.5), ylims = (-2.2, 6), xticks = 0:0.5:10, yticks = [0,1,5,10])
# using shorthands:
xaxis!("mylabel", :log10, :flip)
``` ```
With `subplot`, create multiple plots at once, with flexible layout options: With `subplot`, create multiple plots at once, with flexible layout options:
@ -234,9 +249,9 @@ __Tip__: Call `gui()` to display the plot in a window. Interactivity depends on
- [x] Plot vectors/matrices/functions - [x] Plot vectors/matrices/functions
- [x] Plot DataFrames - [x] Plot DataFrames
- [x] Grouping - [x] Grouping
- [ ] Annotations - [x] Annotations
- [ ] Scales - [x] Scales
- [ ] Categorical Inputs (strings, etc... for hist, bar? or can split one series into multiple?) - [x] Categorical Inputs (strings, etc... for hist, bar? or can split one series into multiple?)
- [ ] Custom markers - [ ] Custom markers
- [ ] Special plots (boxplot, ohlc?) - [ ] Special plots (boxplot, ohlc?)
- [x] Subplots - [x] Subplots

Binary file not shown.

Before

Width:  |  Height:  |  Size: 96 KiB

After

Width:  |  Height:  |  Size: 96 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 75 KiB

After

Width:  |  Height:  |  Size: 66 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 96 KiB

After

Width:  |  Height:  |  Size: 96 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 82 KiB

After

Width:  |  Height:  |  Size: 83 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 49 KiB

After

Width:  |  Height:  |  Size: 46 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 27 KiB

After

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 29 KiB

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 58 KiB

After

Width:  |  Height:  |  Size: 74 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 40 KiB

After

Width:  |  Height:  |  Size: 48 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 52 KiB

After

Width:  |  Height:  |  Size: 52 KiB

View File

@ -214,6 +214,7 @@ end
:mcolor => :markercolor, :mcolor => :markercolor,
:ms => :markersize, :ms => :markersize,
:msize => :markersize, :msize => :markersize,
:f => :fill,
:area => :fill, :area => :fill,
:fillrng => :fillrange, :fillrng => :fillrange,
:fc => :fillcolor, :fc => :fillcolor,