diff --git a/README.md b/README.md index 658e7d4f..e1d7069a 100644 --- a/README.md +++ b/README.md @@ -33,6 +33,12 @@ First, add the package ```julia 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): @@ -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) ``` +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): ```julia 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]) + +# using shorthands: +xaxis!("mylabel", :log10, :flip) ``` 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) -title!(s::@compat(AbstractString)) = plot!(title = s) -xlabel!(s::@compat(AbstractString)) = plot!(xlabel = s) -ylabel!(s::@compat(AbstractString)) = plot!(ylabel = s) +title!(s::AbstractString) = plot!(title = s) +xlabel!(s::AbstractString) = plot!(xlabel = s) +ylabel!(s::AbstractString) = plot!(ylabel = s) xlims!{T<:Real,S<:Real}(lims::Tuple{T,S}) = plot!(xlims = lims) ylims!{T<:Real,S<:Real}(lims::Tuple{T,S}) = plot!(ylims = lims) xticks!{T<:Real}(v::AVec{T}) = plot!(xticks = v) @@ -190,45 +205,50 @@ Keyword | Default | Type | Aliases ---- | ---- | ---- | ---- `:annotation` | `nothing` | Series | `:ann`, `:annotate`, `:annotations`, `:anns` `: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_palette` | `auto` | Plot | `:palette` +`:fill` | `nothing` | Series | `:area`, `:f` `:fillcolor` | `match` | Series | `:fc`, `:fcolor`, `:fillcolors` `:fillrange` | `nothing` | Series | `:fillranges`, `:fillrng` +`:foreground_color` | `auto` | Plot | `:fg`, `:fg_color`, `:fgcolor`, `:foreground` `:group` | `nothing` | Series | `:g`, `:groups` `:heatmap_c` | `(0.15,0.5)` | Series | `:heatmap_cs` `:label` | `AUTO` | Series | `:lab`, `:labels` +`:layout` | `nothing` | Plot | +`:legend` | `true` | Plot | `:leg` +`:line` | `nothing` | Series | `:l` `:linestyle` | `solid` | Series | `:linestyles`, `:ls`, `:s`, `:style` `:linetype` | `path` | Series | `:linetypes`, `:lt`, `:t`, `:type` `:linewidth` | `1` | Series | `:linewidths`, `:lw`, `:w`, `:width` +`:marker` | `nothing` | Series | `:m`, `:mark` `:markercolor` | `match` | Series | `:markercolors`, `:mc`, `:mcolor` `:markershape` | `none` | Series | `:markershapes`, `:shape` `: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 | +`:nbins` | `100` | Series | `:nb`, `:nbin`, `:nbinss` `:nc` | `-1` | Plot | `:nr` | `-1` | Plot | `:pos` | `(0,0)` | Plot | +`:reg` | `false` | Series | `:regression`, `:regs` `:show` | `false` | Plot | `:display`, `:gui` `:size` | `(600,400)` | Plot | `:windowsize`, `:wsize` `:title` | `` | Plot | `:windowtitle` | `Plots.jl` | Plot | `:wtitle` +`:xaxis` | `nothing` | Plot | `:xflip` | `false` | Plot | `:xlabel` | `` | Plot | `:xlab` `:xlims` | `auto` | Plot | `:xlim`, `:xlimit`, `:xlimits` `:xscale` | `identity` | Plot | `:xticks` | `auto` | Plot | `:xtick` +`:yaxis` | `nothing` | Plot | `:yflip` | `true` | Plot | `:ylabel` | `` | Plot | `:ylab` `:ylims` | `auto` | Plot | `:ylim`, `:ylimit`, `:ylimits` `:yrightlabel` | `` | Plot | `:y2lab`, `:y2label`, `:ylab2`, `:ylabel2`, `:ylabelright`, `:ylabr`, `:yrlab` `:yscale` | `identity` | Plot | `:yticks` | `auto` | Plot | `:ytick` +`:z` | `nothing` | Series | `:zs` 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 DataFrames - [x] Grouping -- [ ] Annotations -- [ ] Scales -- [ ] Categorical Inputs (strings, etc... for hist, bar? or can split one series into multiple?) +- [x] Annotations +- [x] Scales +- [x] Categorical Inputs (strings, etc... for hist, bar? or can split one series into multiple?) - [ ] Custom markers - [ ] Special plots (boxplot, ohlc?) - [x] Subplots diff --git a/docs/example_generation.jl b/docs/example_generation.jl index 3bf51c6b..924bc7cb 100644 --- a/docs/example_generation.jl +++ b/docs/example_generation.jl @@ -251,11 +251,15 @@ function buildReadme() # build keyword arg table table = "Keyword | Default | Type | Aliases \n---- | ---- | ---- | ----\n" - for d in (Plots._seriesDefaults, Plots._plotDefaults) - for k in Plots.sortedkeys(d) - aliasstr = createStringOfMarkDownSymbols(aliases(Plots._keyAliases, k)) - table = string(table, "`:$k` | `$(d[k])` | $(d==Plots._seriesDefaults ? "Series" : "Plot") | $aliasstr \n") - end + allseries = merge(Plots._seriesDefaults, @compat(Dict(:line=>nothing, :marker=>nothing, :fill=>nothing))) + allplots = merge(Plots._plotDefaults, @compat(Dict(:xaxis=>nothing, :yaxis=>nothing))) + alldefs = merge(allseries, allplots) + for k in Plots.sortedkeys(alldefs) + # 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 readme = replace(readme, "[[KEYWORD_ARGS_TABLE]]", table) diff --git a/docs/gadfly_examples.md b/docs/gadfly_examples.md index 148558af..c753071b 100644 --- a/docs/gadfly_examples.md +++ b/docs/gadfly_examples.md @@ -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). ```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) - end),0,2π,leg=false,fill=(0,:orange)) + end),0,2π,line=4,leg=false,fill=(0,:orange)) ``` ![](../img/gadfly/gadfly_example_3.png) diff --git a/docs/immerse_examples.md b/docs/immerse_examples.md index 2a883f77..0557893c 100644 --- a/docs/immerse_examples.md +++ b/docs/immerse_examples.md @@ -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). ```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) - end),0,2π,leg=false,fill=(0,:orange)) + end),0,2π,line=4,leg=false,fill=(0,:orange)) ``` ![](../img/immerse/immerse_example_3.png) diff --git a/docs/pyplot_examples.md b/docs/pyplot_examples.md index f70c449f..d2e21b45 100644 --- a/docs/pyplot_examples.md +++ b/docs/pyplot_examples.md @@ -1,6 +1,6 @@ # 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 linetype: `:none`, `:line`, `:path`, `:step`, `:stepinverted`, `:sticks`, `:scatter`, `:heatmap`, `:hexbin`, `:hist`, `:bar`, `:hline`, `:vline` - 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). ```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) - end),0,2π,leg=false,fill=(0,:orange)) + end),0,2π,line=4,leg=false,fill=(0,:orange)) ``` ![](../img/pyplot/pyplot_example_3.png) diff --git a/docs/qwt_examples.md b/docs/qwt_examples.md index c432fba2..b48bf72e 100644 --- a/docs/qwt_examples.md +++ b/docs/qwt_examples.md @@ -1,6 +1,6 @@ # 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 linetype: `:none`, `:line`, `:path`, `:steppre`, `:steppost`, `:sticks`, `:scatter`, `:heatmap`, `:hexbin`, `:hist`, `:bar`, `:hline`, `:vline` - 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). ```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) end),0,2π,line=4,leg=false,fill=(0,:orange)) ``` diff --git a/docs/readme_template.md b/docs/readme_template.md index 72723812..515ff761 100644 --- a/docs/readme_template.md +++ b/docs/readme_template.md @@ -33,6 +33,12 @@ First, add the package ```julia 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): @@ -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) ``` +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): ```julia 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]) + +# using shorthands: +xaxis!("mylabel", :log10, :flip) ``` 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 DataFrames - [x] Grouping -- [ ] Annotations -- [ ] Scales -- [ ] Categorical Inputs (strings, etc... for hist, bar? or can split one series into multiple?) +- [x] Annotations +- [x] Scales +- [x] Categorical Inputs (strings, etc... for hist, bar? or can split one series into multiple?) - [ ] Custom markers - [ ] Special plots (boxplot, ohlc?) - [x] Subplots diff --git a/img/gadfly/gadfly_example_3.png b/img/gadfly/gadfly_example_3.png index 940e90ab..5d66f615 100644 Binary files a/img/gadfly/gadfly_example_3.png and b/img/gadfly/gadfly_example_3.png differ diff --git a/img/gadfly/gadfly_example_4.png b/img/gadfly/gadfly_example_4.png index a9ca4c71..6397070d 100644 Binary files a/img/gadfly/gadfly_example_4.png and b/img/gadfly/gadfly_example_4.png differ diff --git a/img/immerse/immerse_example_3.png b/img/immerse/immerse_example_3.png index 940e90ab..5d66f615 100644 Binary files a/img/immerse/immerse_example_3.png and b/img/immerse/immerse_example_3.png differ diff --git a/img/immerse/immerse_example_4.png b/img/immerse/immerse_example_4.png index 5ef6812a..69f15fd2 100644 Binary files a/img/immerse/immerse_example_4.png and b/img/immerse/immerse_example_4.png differ diff --git a/img/pyplot/pyplot_example_11.png b/img/pyplot/pyplot_example_11.png index 2bbb971a..a6cc6a4d 100644 Binary files a/img/pyplot/pyplot_example_11.png and b/img/pyplot/pyplot_example_11.png differ diff --git a/img/pyplot/pyplot_example_13.png b/img/pyplot/pyplot_example_13.png index 551eca56..24a9a382 100644 Binary files a/img/pyplot/pyplot_example_13.png and b/img/pyplot/pyplot_example_13.png differ diff --git a/img/pyplot/pyplot_example_3.png b/img/pyplot/pyplot_example_3.png index 9b0926f7..f9068f08 100644 Binary files a/img/pyplot/pyplot_example_3.png and b/img/pyplot/pyplot_example_3.png differ diff --git a/img/pyplot/pyplot_example_4.png b/img/pyplot/pyplot_example_4.png index 678a4d8c..66cffe1b 100644 Binary files a/img/pyplot/pyplot_example_4.png and b/img/pyplot/pyplot_example_4.png differ diff --git a/img/pyplot/pyplot_example_9.png b/img/pyplot/pyplot_example_9.png index e0940937..a4ca8a0a 100644 Binary files a/img/pyplot/pyplot_example_9.png and b/img/pyplot/pyplot_example_9.png differ diff --git a/img/supported/Plots.supportGraphArgs.png b/img/supported/Plots.supportGraphArgs.png index ce47043e..52874a48 100644 Binary files a/img/supported/Plots.supportGraphArgs.png and b/img/supported/Plots.supportGraphArgs.png differ diff --git a/src/args.jl b/src/args.jl index 73996f7b..555f284e 100644 --- a/src/args.jl +++ b/src/args.jl @@ -214,6 +214,7 @@ end :mcolor => :markercolor, :ms => :markersize, :msize => :markersize, + :f => :fill, :area => :fill, :fillrng => :fillrange, :fc => :fillcolor,