examples
@ -18,7 +18,7 @@ end
|
|||||||
|
|
||||||
|
|
||||||
function fakedata(sz...)
|
function fakedata(sz...)
|
||||||
y = Array(Float64, sz...)
|
y = zeros(sz...)
|
||||||
for r in 2:size(y,1)
|
for r in 2:size(y,1)
|
||||||
y[r,:] = 0.9 * y[r-1,:] + randn(size(y,2))'
|
y[r,:] = 0.9 * y[r-1,:] + randn(size(y,2))'
|
||||||
end
|
end
|
||||||
@ -57,7 +57,7 @@ const examples = PlotExample[
|
|||||||
[:(scatter!(rand(100), markersize=6, c=:orange))]),
|
[:(scatter!(rand(100), markersize=6, c=:orange))]),
|
||||||
PlotExample("Heatmaps",
|
PlotExample("Heatmaps",
|
||||||
"",
|
"",
|
||||||
[:(heatmap(randn(10000),randn(10000), nbins=(100,20)))]),
|
[:(heatmap(randn(10000),randn(10000), nbins=100))]),
|
||||||
PlotExample("Line types",
|
PlotExample("Line types",
|
||||||
"",
|
"",
|
||||||
[:(types = intersect(supportedTypes(), [:line, :path, :steppre, :steppost, :sticks, :scatter])'),
|
[:(types = intersect(supportedTypes(), [:line, :path, :steppre, :steppost, :sticks, :scatter])'),
|
||||||
@ -73,7 +73,7 @@ const examples = PlotExample[
|
|||||||
[:(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), ms=12))]),
|
[:(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), ms=12))]),
|
||||||
PlotExample("Bar",
|
PlotExample("Bar",
|
||||||
"x is the midpoint of the bar. (todo: allow passing of edges instead of midpoints)",
|
"x is the midpoint of the bar. (todo: allow passing of edges instead of midpoints)",
|
||||||
[:(bar(randn(1000)))]),
|
[:(bar(randn(999)))]),
|
||||||
PlotExample("Histogram",
|
PlotExample("Histogram",
|
||||||
"",
|
"",
|
||||||
[:(histogram(randn(1000), nbins=50))]),
|
[:(histogram(randn(1000), nbins=50))]),
|
||||||
@ -86,10 +86,10 @@ const examples = PlotExample[
|
|||||||
[:(subplot(randn(100,5), layout=[1,1,3], t=[:line :hist :scatter :step :bar], nbins=10, leg=false))]),
|
[:(subplot(randn(100,5), layout=[1,1,3], t=[:line :hist :scatter :step :bar], nbins=10, leg=false))]),
|
||||||
PlotExample("Adding to subplots",
|
PlotExample("Adding to subplots",
|
||||||
"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.",
|
||||||
[:(subplot(randn(100,5), n=4))]),
|
[:(subplot(fakedata(100,10), n=4, palette=[:grays :blues :heat :lightrainbow], bg=[:orange :pink :darkblue :black]))]),
|
||||||
PlotExample("",
|
PlotExample("",
|
||||||
"",
|
"",
|
||||||
[:(subplot!(randn(100,3)))]),
|
[:(subplot!(fakedata(100,10)))]),
|
||||||
PlotExample("Open/High/Low/Close",
|
PlotExample("Open/High/Low/Close",
|
||||||
"Create an OHLC chart. Pass in a vector of OHLC objects 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`.",
|
||||||
[:(n=20), :(hgt=rand(n)+1), :(bot=randn(n)), :(openpct=rand(n)), :(closepct=rand(n)), :(y = [OHLC(openpct[i]*hgt[i]+bot[i], bot[i]+hgt[i], bot[i], closepct[i]*hgt[i]+bot[i]) for i in 1:n]), :(ohlc(y; markersize=8))]),
|
[:(n=20), :(hgt=rand(n)+1), :(bot=randn(n)), :(openpct=rand(n)), :(closepct=rand(n)), :(y = [OHLC(openpct[i]*hgt[i]+bot[i], bot[i]+hgt[i], bot[i], closepct[i]*hgt[i]+bot[i]) for i in 1:n]), :(ohlc(y; markersize=8))]),
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
# Examples for backend: gadfly
|
# Examples for backend: gadfly
|
||||||
|
|
||||||
- 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 arguments: `annotation`, `background_color`, `color`, `color_palette`, `fillrange`, `fillcolor`, `group`, `label`, `layout`, `legend`, `linestyle`, `linetype`, `linewidth`, `markershape`, `markercolor`, `markersize`, `n`, `nbins`, `nc`, `nr`, `reg`, `show`, `size`, `title`, `windowtitle`, `x`, `xlabel`, `xlims`, `xticks`, `y`, `ylabel`, `ylims`, `yticks`, `xscale`, `yscale`, `xflip`, `yflip`, `z`
|
||||||
- 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`
|
||||||
@ -19,14 +19,14 @@ gadfly()
|
|||||||
A simple line plot of the columns.
|
A simple line plot of the columns.
|
||||||
|
|
||||||
```julia
|
```julia
|
||||||
plot(rand(50,5),w=3)
|
plot(fakedata(50,5),w=3)
|
||||||
```
|
```
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
### Functions
|
### Functions
|
||||||
|
|
||||||
Plot multiple functions. You can also put the function first.
|
Plot multiple functions. You can also put the function first, or use the form `plot(f, xmin, xmax)` where f is a Function or AbstractVector{Function}.
|
||||||
|
|
||||||
```julia
|
```julia
|
||||||
plot(0:0.01:4π,[sin,cos])
|
plot(0:0.01:4π,[sin,cos])
|
||||||
@ -36,32 +36,34 @@ plot(0:0.01:4π,[sin,cos])
|
|||||||
|
|
||||||
###
|
###
|
||||||
|
|
||||||
You can also call it with plot(f, xmin, xmax).
|
Or make a parametric plot (i.e. plot: (fx(u), fy(u))) with plot(fx, fy, umin, umax).
|
||||||
|
|
||||||
```julia
|
```julia
|
||||||
plot([sin,cos],0,4π)
|
plot(sin,(x->begin # /home/tom/.julia/v0.4/Plots/docs/example_generation.jl, line 39:
|
||||||
|
sin(2x)
|
||||||
|
end),0,2π,leg=false,fill=(0,:orange))
|
||||||
```
|
```
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
###
|
### Colors
|
||||||
|
|
||||||
Or make a parametric plot (i.e. plot: (fx(u), fy(u))) with plot(fx, fy, umin, umax).
|
Access predefined palettes (or build your own with the `colorscheme` method). Line/marker colors are auto-generated from the plot's palette, unless overridden. Set the `z` argument to turn on series gradients.
|
||||||
|
|
||||||
```julia
|
```julia
|
||||||
plot(sin,(x->begin # /home/tom/.julia/v0.4/Plots/docs/example_generation.jl, line 33:
|
y = rand(100)
|
||||||
sin(2x)
|
plot(0:10:100,rand(11,4),lab="lines",w=3,palette=:grays,fill=(0.5,:auto))
|
||||||
end),0,2π,legend=false,fillto=0)
|
scatter!(y,z=abs(y - 0.5),m=(10,:heat),lab="grad")
|
||||||
```
|
```
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
### Global
|
### Global
|
||||||
|
|
||||||
Change the guides/background/limits/ticks. You can also use shorthand functions: `title!`, `xlabel!`, `ylabel!`, `xlims!`, `ylims!`, `xticks!`, `yticks!`
|
Change the guides/background/limits/ticks. Convenience args `xaxis` and `yaxis` allow you to pass a tuple or value which will be mapped to the relevant args automatically. The `xaxis` below will be replaced with `xlabel` and `xlims` args automatically during the preprocessing step. You can also use shorthand functions: `title!`, `xaxis!`, `yaxis!`, `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),xlim=(-3,13),yticks=0:0.1:1)
|
plot(rand(20,3),title="TITLE",xaxis=("XLABEL",(-5,30),0:2:20,:flip),yaxis=("YLABEL",:log10),background_color=RGB(0.2,0.2,0.2),leg=false)
|
||||||
```
|
```
|
||||||
|
|
||||||

|

|
||||||
@ -73,17 +75,17 @@ Use the `axis` arguments.
|
|||||||
Note: Currently only supported with Qwt and PyPlot
|
Note: Currently only supported with Qwt and PyPlot
|
||||||
|
|
||||||
```julia
|
```julia
|
||||||
plot(Vector[randn(100),randn(100) * 100]; axis=[:l,:r],ylabel="LEFT",yrightlabel="RIGHT")
|
plot(Vector[randn(100),randn(100) * 100]; axis=[:l :r],ylabel="LEFT",yrightlabel="RIGHT")
|
||||||
```
|
```
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
### Vectors w/ pluralized args
|
### Arguments
|
||||||
|
|
||||||
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 (marker/markersize) with arguments unique to each series (colors). Special arguments `line`, `marker`, and `fill` will automatically figure out what arguments to set (for example, we are setting the `linestyle`, `linewidth`, and `color` arguments with `line`.) Note that we pass a matrix of colors, and this applies the colors to each series.
|
||||||
|
|
||||||
```julia
|
```julia
|
||||||
plot(Vector[rand(10),rand(20)]; marker=:ellipse,markersize=8,c=[:red,:blue])
|
plot(Vector[rand(10),rand(20)]; marker=(:ellipse,8),line=(:dot,3,[:black :orange]))
|
||||||
```
|
```
|
||||||
|
|
||||||

|

|
||||||
@ -93,7 +95,7 @@ plot(Vector[rand(10),rand(20)]; marker=:ellipse,markersize=8,c=[: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,fill=(0,:green))
|
||||||
```
|
```
|
||||||
|
|
||||||

|

|
||||||
@ -103,7 +105,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=:orange)
|
||||||
```
|
```
|
||||||
|
|
||||||

|

|
||||||
@ -123,11 +125,11 @@ heatmap(randn(10000),randn(10000),nbins=100)
|
|||||||
|
|
||||||
|
|
||||||
```julia
|
```julia
|
||||||
types = intersect(supportedTypes(),[:line,:path,:steppre,:steppost,:sticks,:scatter])
|
types = intersect(supportedTypes(),[:line,:path,:steppre,:steppost,:sticks,:scatter])'
|
||||||
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,line=(types,3),lab=map(string,types),ms=15)
|
||||||
```
|
```
|
||||||
|
|
||||||

|

|
||||||
@ -137,7 +139,7 @@ plot(x,y,t=types,lab=map(string,types))
|
|||||||
|
|
||||||
|
|
||||||
```julia
|
```julia
|
||||||
styles = setdiff(supportedStyles(),[:auto])
|
styles = setdiff(supportedStyles(),[:auto])'
|
||||||
plot(cumsum(randn(20,length(styles)),1); style=:auto,label=map(string,styles),w=5)
|
plot(cumsum(randn(20,length(styles)),1); style=:auto,label=map(string,styles),w=5)
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -148,8 +150,8 @@ 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),ms=10)
|
scatter(0.5:9.5,[fill(i - 0.5,10) for i = length(markers):-1:1]; marker=:auto,label=map(string,markers),ms=12)
|
||||||
```
|
```
|
||||||
|
|
||||||

|

|
||||||
@ -159,7 +161,7 @@ scatter(0.5:9.5,[fill(i - 0.5,10) for i = length(markers):-1:1]; marker=:auto,la
|
|||||||
x is the midpoint of the bar. (todo: allow passing of edges instead of midpoints)
|
x is the midpoint of the bar. (todo: allow passing of edges instead of midpoints)
|
||||||
|
|
||||||
```julia
|
```julia
|
||||||
bar(randn(1000))
|
bar(randn(999))
|
||||||
```
|
```
|
||||||
|
|
||||||

|

|
||||||
@ -182,7 +184,7 @@ histogram(randn(1000),nbins=50)
|
|||||||
|
|
||||||
|
|
||||||
```julia
|
```julia
|
||||||
subplot(randn(100,5),layout=[1,1,3],t=[:line,:hist,:scatter,:step,:bar],nbins=10,leg=false)
|
subplot(randn(100,5),layout=[1,1,3],t=[:line :hist :scatter :step :bar],nbins=10,leg=false)
|
||||||
```
|
```
|
||||||
|
|
||||||

|

|
||||||
@ -192,7 +194,7 @@ subplot(randn(100,5),layout=[1,1,3],t=[:line,:hist,:scatter,:step,:bar],nbins=10
|
|||||||
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(fakedata(100,10),n=4,palette=[:grays :blues :heat :lightrainbow],bg=[:orange :pink :darkblue :black])
|
||||||
```
|
```
|
||||||
|
|
||||||

|

|
||||||
@ -202,7 +204,7 @@ subplot(randn(100,5),n=4)
|
|||||||
|
|
||||||
|
|
||||||
```julia
|
```julia
|
||||||
subplot!(randn(100,3))
|
subplot!(fakedata(100,10))
|
||||||
```
|
```
|
||||||
|
|
||||||

|

|
||||||
|
|||||||
|
Before Width: | Height: | Size: 188 KiB After Width: | Height: | Size: 64 KiB |
|
Before Width: | Height: | Size: 119 KiB After Width: | Height: | Size: 66 KiB |
|
Before Width: | Height: | Size: 62 KiB After Width: | Height: | Size: 54 KiB |
|
Before Width: | Height: | Size: 71 KiB After Width: | Height: | Size: 46 KiB |
|
Before Width: | Height: | Size: 50 KiB After Width: | Height: | Size: 64 KiB |
|
Before Width: | Height: | Size: 39 KiB After Width: | Height: | Size: 27 KiB |
|
Before Width: | Height: | Size: 25 KiB After Width: | Height: | Size: 18 KiB |
|
Before Width: | Height: | Size: 77 KiB After Width: | Height: | Size: 52 KiB |
|
Before Width: | Height: | Size: 94 KiB After Width: | Height: | Size: 80 KiB |
|
Before Width: | Height: | Size: 124 KiB After Width: | Height: | Size: 98 KiB |
|
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 16 KiB |
|
Before Width: | Height: | Size: 54 KiB After Width: | Height: | Size: 36 KiB |
|
Before Width: | Height: | Size: 40 KiB After Width: | Height: | Size: 27 KiB |
|
Before Width: | Height: | Size: 54 KiB After Width: | Height: | Size: 96 KiB |
|
Before Width: | Height: | Size: 127 KiB After Width: | Height: | Size: 75 KiB |
|
Before Width: | Height: | Size: 50 KiB After Width: | Height: | Size: 50 KiB |
|
Before Width: | Height: | Size: 52 KiB After Width: | Height: | Size: 38 KiB |
|
Before Width: | Height: | Size: 51 KiB After Width: | Height: | Size: 43 KiB |
|
Before Width: | Height: | Size: 80 KiB After Width: | Height: | Size: 56 KiB |
|
Before Width: | Height: | Size: 67 KiB After Width: | Height: | Size: 56 KiB |