examples and readme

This commit is contained in:
Thomas Breloff 2015-09-28 15:44:50 -04:00
parent 001abf684c
commit d3d1181769
17 changed files with 108 additions and 71 deletions

View File

@ -55,7 +55,7 @@ Do a plot in Gadfly (inspired by [this example](http://gadflyjl.org/geom_point.h
```julia ```julia
gadfly() # switch to Gadfly as a backend gadfly() # switch to Gadfly as a backend
dataframes!() # turn on support for DataFrames inputs dataframes() # turn on support for DataFrames inputs
# load some data # load some data
using RDatasets using RDatasets
@ -98,7 +98,7 @@ There are many ways to pass in data to the plot functions... some examples:
- Vectors of Vectors - Vectors of Vectors
- Functions - Functions
- Vectors of Functions - Vectors of Functions
- DataFrames with column symbols (initialize with `dataframes!()`) - DataFrames with column symbols (initialize with `dataframes()`)
In general, you can pass in a `y` only, or an `x` and `y`, both of whatever type(s) you want, and Plots will slice up the data as needed. In general, you can pass in a `y` only, or an `x` and `y`, both of whatever type(s) you want, and Plots will slice up the data as needed.
For matrices, data is split by columns. For functions, data is mapped. For DataFrames, a Symbol/Symbols in place of x/y will map to For matrices, data is split by columns. For functions, data is mapped. For DataFrames, a Symbol/Symbols in place of x/y will map to
@ -118,7 +118,7 @@ plot(rand(10), sin) # same... y = sin(x)
plot([sin,cos], 0:0.1:π) # plot 2 series, sin(x) and cos(x) plot([sin,cos], 0:0.1:π) # plot 2 series, sin(x) and cos(x)
plot([sin,cos], 0, π) # plot sin and cos on the range [0, π] plot([sin,cos], 0, π) # plot sin and cos on the range [0, π]
plot(1:10, Any[rand(10), sin]) # plot 2 series, y = rand(10) for the first, y = sin(x) for the second... x = 1:10 for both plot(1:10, Any[rand(10), sin]) # plot 2 series, y = rand(10) for the first, y = sin(x) for the second... x = 1:10 for both
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)
``` ```
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):
@ -162,14 +162,14 @@ 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::AbstractString) = plot!(title = s) title!(s::AbstractString) = plot!(title = s)
xlabel(s::AbstractString) = plot!(xlabel = s) xlabel!(s::AbstractString) = plot!(xlabel = s)
ylabel(s::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)
yticks!{T<:Real}(v::AVec{T}) = plot!(yticks = v) yticks!{T<:Real}(v::AVec{T}) = plot!(yticks = v)
annotate!(annotations) = plot!(annotation = annotations) annotate!(anns) = plot!(annotation = anns)
``` ```
Some keyword arguments you can set: Some keyword arguments you can set:
@ -187,16 +187,21 @@ Keyword | Default | Type | Aliases
`:label` | `AUTO` | Series | `:lab`, `:labels` `:label` | `AUTO` | Series | `:lab`, `:labels`
`: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`
`:marker` | `none` | Series | `:m`, `:markers` `:marker` | `none` | Series | `:m`, `:markers`, `:shape`
`:markercolor` | `match` | Series | `:markercolors`, `:mc`, `:mcolor` `:markercolor` | `match` | Series | `:markercolors`, `:mc`, `:mcolor`
`:markersize` | `6` | Series | `:markersizes`, `:ms`, `:msize` `:markersize` | `6` | Series | `:markersizes`, `:ms`, `:msize`
`:nbins` | `100` | Series | `:nb`, `:nbin`, `:nbinss` `:nbins` | `100` | Series | `:nb`, `:nbin`, `:nbinss`
`:reg` | `false` | Series | `:regs` `:reg` | `false` | Series | `:regression`, `:regs`
`:ribbon` | `nothing` | Series | `:r`, `:ribbons` `:ribbon` | `nothing` | Series | `:r`, `:ribbons`
`:width` | `1` | Series | `:linewidth`, `:w`, `:widths` `:width` | `1` | Series | `:linewidth`, `:w`, `:widths`
`:background_color` | `RGB{U8}(1.0,1.0,1.0)` | Plot | `:background`, `:bg`, `:bg_color`, `:bgcolor` `:background_color` | `RGB{U8}(1.0,1.0,1.0)` | Plot | `:background`, `:bg`, `:bg_color`, `:bgcolor`
`:foreground_color` | `auto` | Plot | `:fg`, `:fg_color`, `:fgcolor`, `:foreground` `:foreground_color` | `auto` | Plot | `:fg`, `:fg_color`, `:fgcolor`, `:foreground`
`:layout` | `nothing` | Plot |
`:legend` | `true` | Plot | `:leg` `:legend` | `true` | Plot | `:leg`
`:n` | `-1` | Plot |
`:nc` | `-1` | Plot |
`:nr` | `-1` | Plot |
`:pos` | `(0,0)` | Plot |
`:show` | `false` | Plot | `:display`, `:gui` `:show` | `false` | Plot | `:display`, `:gui`
`:size` | `(800,600)` | Plot | `:windowsize`, `:wsize` `:size` | `(800,600)` | Plot | `:windowsize`, `:wsize`
`:title` | `` | Plot | `:title` | `` | Plot |

View File

@ -1,6 +1,6 @@
# Examples for backend: immerse # Examples for backend: immerse
- Supported arguments: `args`, `axis`, `background_color`, `color`, `fillto`, `foreground_color`, `group`, `kwargs`, `label`, `legend`, `linestyle`, `linetype`, `marker`, `markercolor`, `markersize`, `nbins`, `reg`, `ribbon`, `show`, `size`, `title`, `width`, `windowtitle`, `xlabel`, `xticks`, `ylabel`, `yrightlabel`, `yticks` - Supported arguments: `annotation`, `args`, `background_color`, `color`, `fillto`, `group`, `kwargs`, `label`, `layout`, `legend`, `linestyle`, `linetype`, `marker`, `markercolor`, `markersize`, `n`, `nbins`, `nc`, `nr`, `reg`, `show`, `size`, `title`, `width`, `windowtitle`, `x`, `xlabel`, `xlims`, `xticks`, `y`, `ylabel`, `ylims`, `yticks`
- Supported values for axis: `:auto`, `:left` - Supported values for axis: `:auto`, `:left`
- Supported values for linetype: `:none`, `:line`, `:path`, `:steppost`, `:sticks`, `:scatter`, `:heatmap`, `:hexbin`, `:hist`, `:bar`, `:hline`, `:vline`, `:ohlc` - Supported values for linetype: `:none`, `:line`, `:path`, `:steppost`, `:sticks`, `:scatter`, `:heatmap`, `:hexbin`, `:hist`, `:bar`, `:hline`, `:vline`, `:ohlc`
- Supported values for linestyle: `:auto`, `:solid`, `:dash`, `:dot`, `:dashdot`, `:dashdotdot` - Supported values for linestyle: `:auto`, `:solid`, `:dash`, `:dot`, `:dashdot`, `:dashdotdot`
@ -11,12 +11,12 @@
```julia ```julia
using Plots using Plots
immerse() immerse!()
``` ```
### Lines ### Lines
A simple line plot of the 3 columns. A simple line plot of the columns.
```julia ```julia
plot(rand(50,5),w=3) plot(rand(50,5),w=3)
@ -58,17 +58,17 @@ plot(sin,(x->begin # /home/tom/.julia/v0.4/Plots/docs/example_generation.jl, li
### Global ### Global
Change the guides/background without a separate call. Change the guides/background/limits/ticks. You can also use shorthand functions: `title!`, `xlabel!`, `ylabel!`, `xlims!`, `ylims!`, `xticks!`, `yticks!`
```julia ```julia
plot(rand(10); title="TITLE",xlabel="XLABEL",ylabel="YLABEL",background_color=RGB(0.2,0.2,0.2)) plot(rand(10),title="TITLE",xlabel="XLABEL",ylabel="YLABEL",background_color=RGB(0.2,0.2,0.2),xlim=(-3,13),yticks=0:0.1:1)
``` ```
![](../img/immerse/immerse_example_5.png) ![](../img/immerse/immerse_example_5.png)
### Two-axis ### Two-axis
Use the `axis` or `axiss` arguments. Use the `axis` arguments.
Note: Currently only supported with Qwt and PyPlot Note: Currently only supported with Qwt and PyPlot
@ -83,7 +83,7 @@ plot(Vector[randn(100),randn(100) * 100]; axis=[:l,:r],ylabel="LEFT",yrightlabel
Plot multiple series with different numbers of points. Mix arguments that apply to all series (singular... see `marker`) with arguments unique to each series (pluralized... see `colors`). Plot multiple series with different numbers of points. Mix arguments that apply to all series (singular... see `marker`) with arguments unique to each series (pluralized... see `colors`).
```julia ```julia
plot(Vector[rand(10),rand(20)]; marker=:ellipse,markersize=8,colors=[:red,:blue]) plot(Vector[rand(10),rand(20)]; marker=:ellipse,markersize=8,c=[:red,:blue])
``` ```
![](../img/immerse/immerse_example_7.png) ![](../img/immerse/immerse_example_7.png)
@ -93,7 +93,7 @@ plot(Vector[rand(10),rand(20)]; marker=:ellipse,markersize=8,colors=[:red,:blue]
Start with a base plot... Start with a base plot...
```julia ```julia
plot(rand(100) / 3; reg=true,fillto=0) plot(rand(100) / 3,reg=true,fillto=0)
``` ```
![](../img/immerse/immerse_example_8.png) ![](../img/immerse/immerse_example_8.png)
@ -103,7 +103,7 @@ plot(rand(100) / 3; reg=true,fillto=0)
and add to it later. and add to it later.
```julia ```julia
scatter!(rand(100); markersize=6,c=:blue) scatter!(rand(100),markersize=6,c=:blue)
``` ```
![](../img/immerse/immerse_example_9.png) ![](../img/immerse/immerse_example_9.png)
@ -113,7 +113,7 @@ scatter!(rand(100); markersize=6,c=:blue)
```julia ```julia
heatmap(randn(10000),randn(10000); nbins=100) heatmap(randn(10000),randn(10000),nbins=100)
``` ```
![](../img/immerse/immerse_example_10.png) ![](../img/immerse/immerse_example_10.png)
@ -127,7 +127,7 @@ types = intersect(supportedTypes(),[:line,:path,:steppre,:steppost,:sticks,:scat
n = length(types) n = length(types)
x = Vector[sort(rand(20)) for i = 1:n] x = Vector[sort(rand(20)) for i = 1:n]
y = rand(20,n) y = rand(20,n)
plot(x,y; t=types,lab=map(string,types)) plot(x,y,t=types,lab=map(string,types))
``` ```
![](../img/immerse/immerse_example_11.png) ![](../img/immerse/immerse_example_11.png)
@ -149,7 +149,7 @@ plot(cumsum(randn(20,length(styles)),1); style=:auto,label=map(string,styles),w=
```julia ```julia
markers = setdiff(supportedMarkers(),[:none,:auto]) markers = setdiff(supportedMarkers(),[:none,:auto])
scatter(0.5:9.5,[fill(i - 0.5,10) for i = length(markers):-1:1]; marker=:auto,label=map(string,markers),markersize=10) scatter(0.5:9.5,[fill(i - 0.5,10) for i = length(markers):-1:1]; marker=:auto,label=map(string,markers),ms=10)
``` ```
![](../img/immerse/immerse_example_13.png) ![](../img/immerse/immerse_example_13.png)
@ -169,7 +169,7 @@ bar(randn(1000))
```julia ```julia
histogram(randn(1000); nbins=50) histogram(randn(1000),nbins=50)
``` ```
![](../img/immerse/immerse_example_15.png) ![](../img/immerse/immerse_example_15.png)
@ -180,11 +180,9 @@ histogram(randn(1000); nbins=50)
You can define the layout with keyword params... either set the number of plots `n` (and optionally number of rows `nr` or You can define the layout with keyword params... either set the number of plots `n` (and optionally number of rows `nr` or
number of columns `nc`), or you can set the layout directly with `layout`. number of columns `nc`), or you can set the layout directly with `layout`.
Note: Gadfly is not very friendly here, and although you can create a plot and save a PNG, I haven't been able to actually display it.
```julia ```julia
subplot(randn(100,5); layout=[1,1,3],linetypes=[:line,:hist,:scatter,:step,:bar],nbins=10,legend=false) subplot(randn(100,5),layout=[1,1,3],t=[:line,:hist,:scatter,:step,:bar],nbins=10,leg=false)
``` ```
![](../img/immerse/immerse_example_16.png) ![](../img/immerse/immerse_example_16.png)
@ -194,7 +192,7 @@ subplot(randn(100,5); layout=[1,1,3],linetypes=[:line,:hist,:scatter,:step,:bar]
Note here the automatic grid layout, as well as the order in which new series are added to the plots. Note here the automatic grid layout, as well as the order in which new series are added to the plots.
```julia ```julia
subplot(randn(100,5); n=4) subplot(randn(100,5),n=4)
``` ```
![](../img/immerse/immerse_example_17.png) ![](../img/immerse/immerse_example_17.png)
@ -211,7 +209,7 @@ subplot!(randn(100,3))
### Open/High/Low/Close ### Open/High/Low/Close
Create an OHLC chart. Pass in a vector of 4-tuples as your `y` argument. Adjust the tick width with arg `markersize`. Create an OHLC chart. Pass in a vector of OHLC objects as your `y` argument. Adjust the tick width with arg `markersize`.
```julia ```julia
n = 20 n = 20
@ -225,3 +223,15 @@ ohlc(y; markersize=8)
![](../img/immerse/immerse_example_19.png) ![](../img/immerse/immerse_example_19.png)
### Annotations
Currently only text annotations are supported. Pass in a tuple or vector-of-tuples: (x,y,text). `annotate!(ann)` is shorthand for `plot!(; annotation=ann)`
```julia
y = rand(10)
plot(y,ann=(3,y[3],"this is #3"))
annotate!([(5,y[5],"this is #5"),(9,y[10],"this is #10")])
```
![](../img/immerse/immerse_example_20.png)

View File

@ -1,6 +1,6 @@
# Examples for backend: pyplot # Examples for backend: pyplot
- Supported arguments: `args`, `axis`, `background_color`, `color`, `foreground_color`, `group`, `kwargs`, `label`, `legend`, `linestyle`, `linetype`, `marker`, `markercolor`, `markersize`, `nbins`, `ribbon`, `show`, `size`, `title`, `width`, `windowtitle`, `xlabel`, `xticks`, `ylabel`, `yrightlabel`, `yticks` - Supported arguments: `annotation`, `args`, `axis`, `background_color`, `color`, `foreground_color`, `group`, `kwargs`, `label`, `layout`, `legend`, `linestyle`, `linetype`, `marker`, `markercolor`, `markersize`, `n`, `nbins`, `nc`, `nr`, `show`, `size`, `title`, `width`, `windowtitle`, `x`, `xlabel`, `y`, `ylabel`, `yrightlabel`
- 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` - Supported values for linetype: `:none`, `:line`, `:path`, `:step`, `:stepinverted`, `:sticks`, `:scatter`, `:heatmap`, `:hexbin`, `:hist`, `:bar`
- Supported values for linestyle: `:auto`, `:solid`, `:dash`, `:dot`, `:dashdot` - Supported values for linestyle: `:auto`, `:solid`, `:dash`, `:dot`, `:dashdot`
@ -11,12 +11,12 @@
```julia ```julia
using Plots using Plots
pyplot() pyplot!()
``` ```
### Lines ### Lines
A simple line plot of the 3 columns. A simple line plot of the columns.
```julia ```julia
plot(rand(50,5),w=3) plot(rand(50,5),w=3)
@ -58,17 +58,17 @@ plot(sin,(x->begin # /home/tom/.julia/v0.4/Plots/docs/example_generation.jl, li
### Global ### Global
Change the guides/background without a separate call. Change the guides/background/limits/ticks. You can also use shorthand functions: `title!`, `xlabel!`, `ylabel!`, `xlims!`, `ylims!`, `xticks!`, `yticks!`
```julia ```julia
plot(rand(10); title="TITLE",xlabel="XLABEL",ylabel="YLABEL",background_color=RGB(0.2,0.2,0.2)) plot(rand(10),title="TITLE",xlabel="XLABEL",ylabel="YLABEL",background_color=RGB(0.2,0.2,0.2),xlim=(-3,13),yticks=0:0.1:1)
``` ```
![](../img/pyplot/pyplot_example_5.png) ![](../img/pyplot/pyplot_example_5.png)
### Two-axis ### Two-axis
Use the `axis` or `axiss` arguments. Use the `axis` arguments.
Note: Currently only supported with Qwt and PyPlot Note: Currently only supported with Qwt and PyPlot
@ -83,7 +83,7 @@ plot(Vector[randn(100),randn(100) * 100]; axis=[:l,:r],ylabel="LEFT",yrightlabel
Plot multiple series with different numbers of points. Mix arguments that apply to all series (singular... see `marker`) with arguments unique to each series (pluralized... see `colors`). Plot multiple series with different numbers of points. Mix arguments that apply to all series (singular... see `marker`) with arguments unique to each series (pluralized... see `colors`).
```julia ```julia
plot(Vector[rand(10),rand(20)]; marker=:ellipse,markersize=8,colors=[:red,:blue]) plot(Vector[rand(10),rand(20)]; marker=:ellipse,markersize=8,c=[:red,:blue])
``` ```
![](../img/pyplot/pyplot_example_7.png) ![](../img/pyplot/pyplot_example_7.png)
@ -93,7 +93,7 @@ plot(Vector[rand(10),rand(20)]; marker=:ellipse,markersize=8,colors=[:red,:blue]
Start with a base plot... Start with a base plot...
```julia ```julia
plot(rand(100) / 3; reg=true,fillto=0) plot(rand(100) / 3,reg=true,fillto=0)
``` ```
![](../img/pyplot/pyplot_example_8.png) ![](../img/pyplot/pyplot_example_8.png)
@ -103,7 +103,7 @@ plot(rand(100) / 3; reg=true,fillto=0)
and add to it later. and add to it later.
```julia ```julia
scatter!(rand(100); markersize=6,c=:blue) scatter!(rand(100),markersize=6,c=:blue)
``` ```
![](../img/pyplot/pyplot_example_9.png) ![](../img/pyplot/pyplot_example_9.png)
@ -113,7 +113,7 @@ scatter!(rand(100); markersize=6,c=:blue)
```julia ```julia
heatmap(randn(10000),randn(10000); nbins=100) heatmap(randn(10000),randn(10000),nbins=100)
``` ```
![](../img/pyplot/pyplot_example_10.png) ![](../img/pyplot/pyplot_example_10.png)
@ -127,7 +127,7 @@ types = intersect(supportedTypes(),[:line,:path,:steppre,:steppost,:sticks,:scat
n = length(types) n = length(types)
x = Vector[sort(rand(20)) for i = 1:n] x = Vector[sort(rand(20)) for i = 1:n]
y = rand(20,n) y = rand(20,n)
plot(x,y; t=types,lab=map(string,types)) plot(x,y,t=types,lab=map(string,types))
``` ```
![](../img/pyplot/pyplot_example_11.png) ![](../img/pyplot/pyplot_example_11.png)
@ -149,7 +149,7 @@ plot(cumsum(randn(20,length(styles)),1); style=:auto,label=map(string,styles),w=
```julia ```julia
markers = setdiff(supportedMarkers(),[:none,:auto]) markers = setdiff(supportedMarkers(),[:none,:auto])
scatter(0.5:9.5,[fill(i - 0.5,10) for i = length(markers):-1:1]; marker=:auto,label=map(string,markers),markersize=10) scatter(0.5:9.5,[fill(i - 0.5,10) for i = length(markers):-1:1]; marker=:auto,label=map(string,markers),ms=10)
``` ```
![](../img/pyplot/pyplot_example_13.png) ![](../img/pyplot/pyplot_example_13.png)
@ -169,8 +169,20 @@ bar(randn(1000))
```julia ```julia
histogram(randn(1000); nbins=50) histogram(randn(1000),nbins=50)
``` ```
![](../img/pyplot/pyplot_example_15.png) ![](../img/pyplot/pyplot_example_15.png)
### Annotations
Currently only text annotations are supported. Pass in a tuple or vector-of-tuples: (x,y,text). `annotate!(ann)` is shorthand for `plot!(; annotation=ann)`
```julia
y = rand(10)
plot(y,ann=(3,y[3],"this is #3"))
annotate!([(5,y[5],"this is #5"),(9,y[10],"this is #10")])
```
![](../img/pyplot/pyplot_example_20.png)

View File

@ -1,6 +1,6 @@
# Examples for backend: qwt # Examples for backend: qwt
- Supported arguments: `args`, `axis`, `background_color`, `color`, `fillto`, `foreground_color`, `group`, `heatmap_c`, `kwargs`, `label`, `legend`, `linestyle`, `linetype`, `marker`, `markercolor`, `markersize`, `nbins`, `reg`, `ribbon`, `show`, `size`, `title`, `width`, `windowtitle`, `xlabel`, `xticks`, `ylabel`, `yrightlabel`, `yticks` - Supported arguments: `annotation`, `args`, `axis`, `background_color`, `color`, `fillto`, `foreground_color`, `group`, `heatmap_c`, `kwargs`, `label`, `layout`, `legend`, `linestyle`, `linetype`, `marker`, `markercolor`, `markersize`, `n`, `nbins`, `nc`, `nr`, `pos`, `reg`, `show`, `size`, `title`, `width`, `windowtitle`, `x`, `xlabel`, `y`, `ylabel`, `yrightlabel`
- 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` - Supported values for linetype: `:none`, `:line`, `:path`, `:steppre`, `:steppost`, `:sticks`, `:scatter`, `:heatmap`, `:hexbin`, `:hist`, `:bar`
- Supported values for linestyle: `:auto`, `:solid`, `:dash`, `:dot`, `:dashdot`, `:dashdotdot` - Supported values for linestyle: `:auto`, `:solid`, `:dash`, `:dot`, `:dashdot`, `:dashdotdot`
@ -11,12 +11,12 @@
```julia ```julia
using Plots using Plots
qwt() qwt!()
``` ```
### Lines ### Lines
A simple line plot of the 3 columns. A simple line plot of the columns.
```julia ```julia
plot(rand(50,5),w=3) plot(rand(50,5),w=3)
@ -58,17 +58,17 @@ plot(sin,(x->begin # /home/tom/.julia/v0.4/Plots/docs/example_generation.jl, li
### Global ### Global
Change the guides/background without a separate call. Change the guides/background/limits/ticks. You can also use shorthand functions: `title!`, `xlabel!`, `ylabel!`, `xlims!`, `ylims!`, `xticks!`, `yticks!`
```julia ```julia
plot(rand(10); title="TITLE",xlabel="XLABEL",ylabel="YLABEL",background_color=RGB(0.2,0.2,0.2)) plot(rand(10),title="TITLE",xlabel="XLABEL",ylabel="YLABEL",background_color=RGB(0.2,0.2,0.2),xlim=(-3,13),yticks=0:0.1:1)
``` ```
![](../img/qwt/qwt_example_5.png) ![](../img/qwt/qwt_example_5.png)
### Two-axis ### Two-axis
Use the `axis` or `axiss` arguments. Use the `axis` arguments.
Note: Currently only supported with Qwt and PyPlot Note: Currently only supported with Qwt and PyPlot
@ -83,7 +83,7 @@ plot(Vector[randn(100),randn(100) * 100]; axis=[:l,:r],ylabel="LEFT",yrightlabel
Plot multiple series with different numbers of points. Mix arguments that apply to all series (singular... see `marker`) with arguments unique to each series (pluralized... see `colors`). Plot multiple series with different numbers of points. Mix arguments that apply to all series (singular... see `marker`) with arguments unique to each series (pluralized... see `colors`).
```julia ```julia
plot(Vector[rand(10),rand(20)]; marker=:ellipse,markersize=8,colors=[:red,:blue]) plot(Vector[rand(10),rand(20)]; marker=:ellipse,markersize=8,c=[:red,:blue])
``` ```
![](../img/qwt/qwt_example_7.png) ![](../img/qwt/qwt_example_7.png)
@ -93,7 +93,7 @@ plot(Vector[rand(10),rand(20)]; marker=:ellipse,markersize=8,colors=[:red,:blue]
Start with a base plot... Start with a base plot...
```julia ```julia
plot(rand(100) / 3; reg=true,fillto=0) plot(rand(100) / 3,reg=true,fillto=0)
``` ```
![](../img/qwt/qwt_example_8.png) ![](../img/qwt/qwt_example_8.png)
@ -103,7 +103,7 @@ plot(rand(100) / 3; reg=true,fillto=0)
and add to it later. and add to it later.
```julia ```julia
scatter!(rand(100); markersize=6,c=:blue) scatter!(rand(100),markersize=6,c=:blue)
``` ```
![](../img/qwt/qwt_example_9.png) ![](../img/qwt/qwt_example_9.png)
@ -113,7 +113,7 @@ scatter!(rand(100); markersize=6,c=:blue)
```julia ```julia
heatmap(randn(10000),randn(10000); nbins=100) heatmap(randn(10000),randn(10000),nbins=100)
``` ```
![](../img/qwt/qwt_example_10.png) ![](../img/qwt/qwt_example_10.png)
@ -127,7 +127,7 @@ types = intersect(supportedTypes(),[:line,:path,:steppre,:steppost,:sticks,:scat
n = length(types) n = length(types)
x = Vector[sort(rand(20)) for i = 1:n] x = Vector[sort(rand(20)) for i = 1:n]
y = rand(20,n) y = rand(20,n)
plot(x,y; t=types,lab=map(string,types)) plot(x,y,t=types,lab=map(string,types))
``` ```
![](../img/qwt/qwt_example_11.png) ![](../img/qwt/qwt_example_11.png)
@ -149,7 +149,7 @@ plot(cumsum(randn(20,length(styles)),1); style=:auto,label=map(string,styles),w=
```julia ```julia
markers = setdiff(supportedMarkers(),[:none,:auto]) markers = setdiff(supportedMarkers(),[:none,:auto])
scatter(0.5:9.5,[fill(i - 0.5,10) for i = length(markers):-1:1]; marker=:auto,label=map(string,markers),markersize=10) scatter(0.5:9.5,[fill(i - 0.5,10) for i = length(markers):-1:1]; marker=:auto,label=map(string,markers),ms=10)
``` ```
![](../img/qwt/qwt_example_13.png) ![](../img/qwt/qwt_example_13.png)
@ -169,7 +169,7 @@ bar(randn(1000))
```julia ```julia
histogram(randn(1000); nbins=50) histogram(randn(1000),nbins=50)
``` ```
![](../img/qwt/qwt_example_15.png) ![](../img/qwt/qwt_example_15.png)
@ -180,11 +180,9 @@ histogram(randn(1000); nbins=50)
You can define the layout with keyword params... either set the number of plots `n` (and optionally number of rows `nr` or You can define the layout with keyword params... either set the number of plots `n` (and optionally number of rows `nr` or
number of columns `nc`), or you can set the layout directly with `layout`. number of columns `nc`), or you can set the layout directly with `layout`.
Note: Gadfly is not very friendly here, and although you can create a plot and save a PNG, I haven't been able to actually display it.
```julia ```julia
subplot(randn(100,5); layout=[1,1,3],linetypes=[:line,:hist,:scatter,:step,:bar],nbins=10,legend=false) subplot(randn(100,5),layout=[1,1,3],t=[:line,:hist,:scatter,:step,:bar],nbins=10,leg=false)
``` ```
![](../img/qwt/qwt_example_16.png) ![](../img/qwt/qwt_example_16.png)
@ -194,7 +192,7 @@ subplot(randn(100,5); layout=[1,1,3],linetypes=[:line,:hist,:scatter,:step,:bar]
Note here the automatic grid layout, as well as the order in which new series are added to the plots. Note here the automatic grid layout, as well as the order in which new series are added to the plots.
```julia ```julia
subplot(randn(100,5); n=4) subplot(randn(100,5),n=4)
``` ```
![](../img/qwt/qwt_example_17.png) ![](../img/qwt/qwt_example_17.png)

View File

@ -1,6 +1,6 @@
# Examples for backend: winston # Examples for backend: winston
- Supported arguments: `args`, `axis`, `color`, `foreground_color`, `group`, `kwargs`, `label`, `legend`, `linestyle`, `linetype`, `marker`, `markersize`, `nbins`, `reg`, `ribbon`, `show`, `size`, `title`, `width`, `windowtitle`, `xlabel`, `xticks`, `ylabel`, `yrightlabel`, `yticks` - Supported arguments: `annotation`, `color`, `fillto`, `group`, `label`, `legend`, `linestyle`, `linetype`, `marker`, `markercolor`, `markersize`, `nbins`, `reg`, `show`, `size`, `title`, `width`, `windowtitle`, `x`, `xlabel`, `y`, `ylabel`
- Supported values for axis: `:auto`, `:left` - Supported values for axis: `:auto`, `:left`
- Supported values for linetype: `:none`, `:line`, `:path`, `:sticks`, `:scatter`, `:hist`, `:bar` - Supported values for linetype: `:none`, `:line`, `:path`, `:sticks`, `:scatter`, `:hist`, `:bar`
- Supported values for linestyle: `:solid`, `:dash`, `:dot`, `:dashdot` - Supported values for linestyle: `:solid`, `:dash`, `:dot`, `:dashdot`
@ -11,12 +11,12 @@
```julia ```julia
using Plots using Plots
winston() winston!()
``` ```
### Lines ### Lines
A simple line plot of the 3 columns. A simple line plot of the columns.
```julia ```julia
plot(rand(50,5),w=3) plot(rand(50,5),w=3)
@ -58,17 +58,17 @@ plot(sin,(x->begin # /home/tom/.julia/v0.4/Plots/docs/example_generation.jl, li
### Global ### Global
Change the guides/background without a separate call. Change the guides/background/limits/ticks. You can also use shorthand functions: `title!`, `xlabel!`, `ylabel!`, `xlims!`, `ylims!`, `xticks!`, `yticks!`
```julia ```julia
plot(rand(10); title="TITLE",xlabel="XLABEL",ylabel="YLABEL",background_color=RGB(0.2,0.2,0.2)) plot(rand(10),title="TITLE",xlabel="XLABEL",ylabel="YLABEL",background_color=RGB(0.2,0.2,0.2),xlim=(-3,13),yticks=0:0.1:1)
``` ```
![](../img/winston/winston_example_5.png) ![](../img/winston/winston_example_5.png)
### Two-axis ### Two-axis
Use the `axis` or `axiss` arguments. Use the `axis` arguments.
Note: Currently only supported with Qwt and PyPlot Note: Currently only supported with Qwt and PyPlot
@ -83,7 +83,7 @@ plot(Vector[randn(100),randn(100) * 100]; axis=[:l,:r],ylabel="LEFT",yrightlabel
Plot multiple series with different numbers of points. Mix arguments that apply to all series (singular... see `marker`) with arguments unique to each series (pluralized... see `colors`). Plot multiple series with different numbers of points. Mix arguments that apply to all series (singular... see `marker`) with arguments unique to each series (pluralized... see `colors`).
```julia ```julia
plot(Vector[rand(10),rand(20)]; marker=:ellipse,markersize=8,colors=[:red,:blue]) plot(Vector[rand(10),rand(20)]; marker=:ellipse,markersize=8,c=[:red,:blue])
``` ```
![](../img/winston/winston_example_7.png) ![](../img/winston/winston_example_7.png)
@ -93,7 +93,7 @@ plot(Vector[rand(10),rand(20)]; marker=:ellipse,markersize=8,colors=[:red,:blue]
Start with a base plot... Start with a base plot...
```julia ```julia
plot(rand(100) / 3; reg=true,fillto=0) plot(rand(100) / 3,reg=true,fillto=0)
``` ```
![](../img/winston/winston_example_8.png) ![](../img/winston/winston_example_8.png)
@ -103,7 +103,7 @@ plot(rand(100) / 3; reg=true,fillto=0)
and add to it later. and add to it later.
```julia ```julia
scatter!(rand(100); markersize=6,c=:blue) scatter!(rand(100),markersize=6,c=:blue)
``` ```
![](../img/winston/winston_example_9.png) ![](../img/winston/winston_example_9.png)
@ -117,7 +117,7 @@ types = intersect(supportedTypes(),[:line,:path,:steppre,:steppost,:sticks,:scat
n = length(types) n = length(types)
x = Vector[sort(rand(20)) for i = 1:n] x = Vector[sort(rand(20)) for i = 1:n]
y = rand(20,n) y = rand(20,n)
plot(x,y; t=types,lab=map(string,types)) plot(x,y,t=types,lab=map(string,types))
``` ```
![](../img/winston/winston_example_11.png) ![](../img/winston/winston_example_11.png)
@ -139,7 +139,7 @@ plot(cumsum(randn(20,length(styles)),1); style=:auto,label=map(string,styles),w=
```julia ```julia
markers = setdiff(supportedMarkers(),[:none,:auto]) markers = setdiff(supportedMarkers(),[:none,:auto])
scatter(0.5:9.5,[fill(i - 0.5,10) for i = length(markers):-1:1]; marker=:auto,label=map(string,markers),markersize=10) scatter(0.5:9.5,[fill(i - 0.5,10) for i = length(markers):-1:1]; marker=:auto,label=map(string,markers),ms=10)
``` ```
![](../img/winston/winston_example_13.png) ![](../img/winston/winston_example_13.png)
@ -159,8 +159,20 @@ bar(randn(1000))
```julia ```julia
histogram(randn(1000); nbins=50) histogram(randn(1000),nbins=50)
``` ```
![](../img/winston/winston_example_15.png) ![](../img/winston/winston_example_15.png)
### Annotations
Currently only text annotations are supported. Pass in a tuple or vector-of-tuples: (x,y,text). `annotate!(ann)` is shorthand for `plot!(; annotation=ann)`
```julia
y = rand(10)
plot(y,ann=(3,y[3],"this is #3"))
annotate!([(5,y[5],"this is #5"),(9,y[10],"this is #10")])
```
![](../img/winston/winston_example_20.png)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 60 KiB

After

Width:  |  Height:  |  Size: 62 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 54 KiB

After

Width:  |  Height:  |  Size: 50 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 75 KiB

After

Width:  |  Height:  |  Size: 77 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 45 KiB

After

Width:  |  Height:  |  Size: 50 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 52 KiB

After

Width:  |  Height:  |  Size: 51 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 81 KiB

After

Width:  |  Height:  |  Size: 80 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 64 KiB

After

Width:  |  Height:  |  Size: 67 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 33 KiB

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 12 KiB