Compare commits
29 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 1115ff83bb | |||
| c24550c756 | |||
| b5cdfe30ea | |||
| a10e594da1 | |||
| 63aee387f0 | |||
| ab9de1e199 | |||
| e60c463328 | |||
| 537d74196b | |||
| a8bbbe8582 | |||
| 29471a7aac | |||
| 894a4a5567 | |||
| f7cd5276f0 | |||
| 95b8c71083 | |||
| 52c82e6fe2 | |||
| cef1abd6aa | |||
| 91da261128 | |||
| 1c70346a61 | |||
| 2de017086d | |||
| d6253c72d4 | |||
| e5007b6c87 | |||
| bbc18549b3 | |||
| b6855b6fba | |||
| 70db97d576 | |||
| f632f2f39e | |||
| b23f968d57 | |||
| ea88877a11 | |||
| 1de3decede | |||
| 78045fd2ab | |||
| 7c8898158b |
@@ -4,9 +4,11 @@ os:
|
||||
- linux
|
||||
- osx
|
||||
julia:
|
||||
- 0.3
|
||||
- 0.4
|
||||
- nightly
|
||||
notifications:
|
||||
email: false
|
||||
email: true
|
||||
# uncomment the following lines to override the default test script
|
||||
script:
|
||||
- if [[ -a .git/shallow ]]; then git fetch --unshallow; fi
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
# Plots
|
||||
|
||||
[](https://travis-ci.org/tbreloff/Plots.jl)
|
||||
[](http://pkg.julialang.org/?pkg=Plots&ver=0.3)
|
||||
[](http://pkg.julialang.org/?pkg=Plots&ver=0.4)
|
||||
[](http://pkg.julialang.org/?pkg=Plots&ver=0.5)
|
||||
|
||||
#### Author: Thomas Breloff (@tbreloff)
|
||||
|
||||
@@ -30,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):
|
||||
@@ -64,7 +73,7 @@ using RDatasets
|
||||
iris = dataset("datasets", "iris");
|
||||
|
||||
# This will bring up a browser window with the plot. Add a semicolon at the end to skip display.
|
||||
scatter(iris, :SepalLength, :SepalWidth, group=:Species, ms=12, m=[:+,:d,:s])
|
||||
scatter(iris, :SepalLength, :SepalWidth, group=:Species, m=([:+ :d :s], 12))
|
||||
|
||||
# save a png (equivalent to png("gadfly1.png") and savefig("gadfly1.png"))
|
||||
png("gadfly1")
|
||||
@@ -126,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:
|
||||
@@ -174,6 +192,10 @@ 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)
|
||||
yticks!{T<:Real}(v::AVec{T}) = plot!(yticks = v)
|
||||
xflip!(flip::Bool = true) = plot!(xflip = flip)
|
||||
yflip!(flip::Bool = true) = plot!(yflip = flip)
|
||||
xaxis!(args...) = plot!(xaxis = args)
|
||||
yaxis!(args...) = plot!(yaxis = args)
|
||||
annotate!(anns) = plot!(annotation = anns)
|
||||
```
|
||||
|
||||
@@ -183,41 +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`
|
||||
`:fillto` | `nothing` | Series | `:area`, `:fill`, `:filltos`
|
||||
`: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`
|
||||
`:linestyle` | `solid` | Series | `:linestyles`, `:ls`, `:s`, `:style`
|
||||
`:linetype` | `path` | Series | `:linetypes`, `:lt`, `:t`, `:type`
|
||||
`:marker` | `none` | Series | `:m`, `:markers`, `:shape`
|
||||
`:markercolor` | `match` | Series | `:markercolors`, `:mc`, `:mcolor`
|
||||
`:markersize` | `6` | Series | `:markersizes`, `:ms`, `:msize`
|
||||
`:nbins` | `100` | Series | `:nb`, `:nbin`, `:nbinss`
|
||||
`:reg` | `false` | Series | `:regression`, `:regs`
|
||||
`:ribbon` | `nothing` | Series | `:rib`, `:ribbons`
|
||||
`:width` | `1` | Series | `:linewidth`, `:w`, `:widths`
|
||||
`: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`
|
||||
`: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`
|
||||
`: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` | `(800,600)` | Plot | `:windowsize`, `:wsize`
|
||||
`: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:
|
||||
@@ -274,11 +305,25 @@ Type | Aliases
|
||||
|
||||
__Tip__: You can see the default value for a given argument with `default(arg::Symbol)`, and set the default value with `default(arg::Symbol, value)` or `default(; kw...)`. For example set the default window size and whether we should show a legend with `default(size=(600,400), leg=false)`.
|
||||
|
||||
__Tip__: When plotting multiple lines, you can set all series to use the same value, or pass in an array to cycle through values. Example:
|
||||
__Tip__: There are some helper arguments you can set: `xaxis`, `yaxis`, `line`, `marker`, `fill`. These go through special preprocessing to extract values into individual arguments. The order doesn't matter, and if you pass a single value it's equivalent to wrapping it in a Tuple. Examples:
|
||||
|
||||
```
|
||||
plot(y, xaxis = ("mylabel", :log, :flip, (-1,1))) # this sets the `xlabel`, `xscale`, `xflip`, and `xlims` arguments automatically
|
||||
plot(y, line = (:bar, :blue, :dot, 10)) # this sets the `linetype`, `color`, `linestyle`, and `linewidth` arguments automatically
|
||||
plot(y, marker = (:rect, :red, 10)) # this sets the `markershape`, `markercolor`, and `markersize` arguments automatically
|
||||
plot(y, fill = (:green, 10)) # this sets the `fillcolor` and `fillrange` arguments automatically
|
||||
# Note: `fillrange` can be:
|
||||
a number (fill to horizontal line)
|
||||
a vector of numbers (different for each data point)
|
||||
a tuple of vectors (fill a band)
|
||||
```
|
||||
|
||||
__Tip__: When plotting multiple lines, you can set all series to use the same value, or pass in a matrix to cycle through values. Example:
|
||||
|
||||
```julia
|
||||
plot(rand(100,4); color = [:red, RGB(0,0,1)], # lines 1 and 3 are red, lines 2 and 4 are blue
|
||||
plot(rand(100,4); color = [:red RGB(0,0,1)], # (Matrix) lines 1 and 3 are red, lines 2 and 4 are blue
|
||||
axis = :auto, # lines 1 and 3 are on the left axis, lines 2 and 4 are on the right
|
||||
markershape = [:rect, :star1] # (Vector) ALL lines are passed the vector [:rect, :star1]
|
||||
width = 5) # all lines have a width of 5
|
||||
```
|
||||
|
||||
@@ -291,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
|
||||
|
||||
@@ -3,68 +3,78 @@ module PlotExamples
|
||||
|
||||
using Plots
|
||||
using Colors
|
||||
using Compat
|
||||
|
||||
const DOCDIR = Pkg.dir("Plots") * "/docs"
|
||||
const IMGDIR = Pkg.dir("Plots") * "/img"
|
||||
|
||||
doc"""
|
||||
"""
|
||||
Holds all data needed for a documentation example... header, description, and plotting expression (Expr)
|
||||
"""
|
||||
type PlotExample
|
||||
header::AbstractString
|
||||
desc::AbstractString
|
||||
header::@compat(AbstractString)
|
||||
desc::@compat(AbstractString)
|
||||
exprs::Vector{Expr}
|
||||
end
|
||||
|
||||
|
||||
function fakedata(sz...)
|
||||
y = zeros(sz...)
|
||||
for r in 2:size(y,1)
|
||||
y[r,:] = 0.9 * y[r-1,:] + randn(size(y,2))'
|
||||
end
|
||||
y
|
||||
end
|
||||
|
||||
|
||||
# the examples we'll run for each
|
||||
const examples = PlotExample[
|
||||
PlotExample("Lines",
|
||||
"A simple line plot of the columns.",
|
||||
[:(plot(rand(50,5), w=3))]),
|
||||
[:(plot(fakedata(50,5), w=3))]),
|
||||
PlotExample("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}.",
|
||||
[:(plot(0:0.01:4π, [sin,cos]))]),
|
||||
PlotExample("",
|
||||
"You can also call it with plot(f, xmin, xmax).",
|
||||
[:(plot([sin,cos], 0, 4π))]),
|
||||
PlotExample("",
|
||||
"Or make a parametric plot (i.e. plot: (fx(u), fy(u))) with plot(fx, fy, umin, umax).",
|
||||
[:(plot(sin, x->sin(2x), 0, 2π, legend=false, fillto=0))]),
|
||||
[:(plot(sin, x->sin(2x), 0, 2π, line=4, leg=false, fill=(0,:orange)))]),
|
||||
PlotExample("Colors",
|
||||
"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.",
|
||||
[:(y = rand(100)), :(plot(0:10:100,rand(11,4),lab="lines",w=3, palette=:grays, fill=(0.5,:auto))), :(scatter!(y, z=abs(y-.5), m=(10,:heat), lab="grad"))]),
|
||||
PlotExample("Global",
|
||||
"Change the guides/background/limits/ticks. You can also use shorthand functions: `title!`, `xlabel!`, `ylabel!`, `xlims!`, `ylims!`, `xticks!`, `yticks!`",
|
||||
[:(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))]),
|
||||
"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!`",
|
||||
[:(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))]),
|
||||
PlotExample("Two-axis",
|
||||
"Use the `axis` arguments.\n\nNote: Currently only supported with Qwt and PyPlot",
|
||||
[:(plot(Vector[randn(100), randn(100)*100]; axis = [:l,:r], ylabel="LEFT", yrightlabel="RIGHT"))]),
|
||||
PlotExample("Vectors w/ pluralized args",
|
||||
"Plot multiple series with different numbers of points. Mix arguments that apply to all series (marker/markersize) with arguments unique to each series (colors).",
|
||||
[:(plot(Vector[rand(10), rand(20)]; marker=:ellipse, markersize=8, c=[:red,:blue]))]),
|
||||
[:(plot(Vector[randn(100), randn(100)*100]; axis = [:l :r], ylabel="LEFT", yrightlabel="RIGHT"))]),
|
||||
PlotExample("Arguments",
|
||||
"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.",
|
||||
[:(plot(Vector[rand(10), rand(20)]; marker=(:ellipse,8), line=(:dot,3,[:black :orange])))]),
|
||||
PlotExample("Build plot in pieces",
|
||||
"Start with a base plot...",
|
||||
[:(plot(rand(100)/3, reg=true, fillto=0))]),
|
||||
[:(plot(rand(100)/3, reg=true, fill=(0,:green)))]),
|
||||
PlotExample("",
|
||||
"and add to it later.",
|
||||
[:(scatter!(rand(100), markersize=6, c=:blue))]),
|
||||
[:(scatter!(rand(100), markersize=6, c=:orange))]),
|
||||
PlotExample("Heatmaps",
|
||||
"",
|
||||
[:(heatmap(randn(10000),randn(10000), nbins=100))]),
|
||||
PlotExample("Line types",
|
||||
"",
|
||||
[:(types = intersect(supportedTypes(), [:line, :path, :steppre, :steppost, :sticks, :scatter])),
|
||||
[:(types = intersect(supportedTypes(), [:line, :path, :steppre, :steppost, :sticks, :scatter])'),
|
||||
:(n = length(types)),
|
||||
:(x = Vector[sort(rand(20)) for i in 1: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))]),
|
||||
PlotExample("Line styles",
|
||||
"",
|
||||
[:(styles = setdiff(supportedStyles(), [:auto])), :(plot(cumsum(randn(20,length(styles)),1); style=:auto, label=map(string,styles), w=5))]),
|
||||
[:(styles = setdiff(supportedStyles(), [:auto])'), :(plot(cumsum(randn(20,length(styles)),1); style=:auto, label=map(string,styles), w=5))]),
|
||||
PlotExample("Marker types",
|
||||
"",
|
||||
[:(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))]),
|
||||
[:(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",
|
||||
"x is the midpoint of the bar. (todo: allow passing of edges instead of midpoints)",
|
||||
[:(bar(randn(1000)))]),
|
||||
[:(bar(randn(999)))]),
|
||||
PlotExample("Histogram",
|
||||
"",
|
||||
[:(histogram(randn(1000), nbins=50))]),
|
||||
@@ -74,13 +84,13 @@ const examples = PlotExample[
|
||||
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`.
|
||||
""",
|
||||
[:(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",
|
||||
"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("",
|
||||
"",
|
||||
[:(subplot!(randn(100,3)))]),
|
||||
[:(subplot!(fakedata(100,10)))]),
|
||||
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`.",
|
||||
[:(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))]),
|
||||
@@ -162,7 +172,8 @@ end
|
||||
|
||||
|
||||
# make and display one plot
|
||||
function test_example(pkgname::Symbol, idx::Int)
|
||||
function test_examples(pkgname::Symbol, idx::Int; debug = true)
|
||||
Plots._debugMode.on = debug
|
||||
println("Testing plot: $pkgname:$idx:$(examples[idx].header)")
|
||||
backend(pkgname)
|
||||
backend()
|
||||
@@ -173,7 +184,8 @@ function test_example(pkgname::Symbol, idx::Int)
|
||||
end
|
||||
|
||||
# generate all plots and create a dict mapping idx --> plt
|
||||
function test_all_examples(pkgname::Symbol)
|
||||
function test_examples(pkgname::Symbol; debug = false)
|
||||
Plots._debugMode.on = debug
|
||||
plts = Dict()
|
||||
for i in 1:length(examples)
|
||||
# if examples[i].header == "Subplots" && !subplotSupported()
|
||||
@@ -181,7 +193,7 @@ function test_all_examples(pkgname::Symbol)
|
||||
# end
|
||||
|
||||
try
|
||||
plt = test_example(pkgname, i)
|
||||
plt = test_examples(pkgname, i, debug=debug)
|
||||
plts[i] = plt
|
||||
catch ex
|
||||
# TODO: put error info into markdown?
|
||||
@@ -204,7 +216,7 @@ end
|
||||
# markersize # size of the marker
|
||||
# nbins # number of bins for heatmap/hexbin and histograms
|
||||
# heatmap_c # color cutoffs for Qwt heatmaps
|
||||
# fillto # fillto value for area plots
|
||||
# fill # fill value for area plots
|
||||
# title # string or symbol, title of the plot
|
||||
# xlabel # string or symbol, label on the bottom (x) axis
|
||||
# ylabel # string or symbol, label on the left (y) axis
|
||||
@@ -217,7 +229,7 @@ end
|
||||
|
||||
|
||||
|
||||
const _ltdesc = Dict(
|
||||
@compat const _ltdesc = Dict(
|
||||
:none => "No line",
|
||||
:line => "Lines with sorted x-axis",
|
||||
:path => "Lines",
|
||||
@@ -239,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)
|
||||
|
||||
@@ -280,6 +296,8 @@ function buildReadme()
|
||||
Plots.dumpSupportGraphs()
|
||||
end
|
||||
|
||||
default(size=(600,400))
|
||||
|
||||
# run it!
|
||||
# note: generate separately so it's easy to comment out
|
||||
# @osx_only generate_markdown(:unicodeplots)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# 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 linetype: `:none`, `:line`, `:path`, `:steppost`, `:sticks`, `:scatter`, `:heatmap`, `:hexbin`, `:hist`, `:bar`, `:hline`, `:vline`, `:ohlc`
|
||||
- Supported values for linestyle: `:auto`, `:solid`, `:dash`, `:dot`, `:dashdot`, `:dashdotdot`
|
||||
@@ -19,14 +19,14 @@ gadfly()
|
||||
A simple line plot of the columns.
|
||||
|
||||
```julia
|
||||
plot(rand(50,5),w=3)
|
||||
plot(fakedata(50,5),w=3)
|
||||
```
|
||||
|
||||

|
||||
|
||||
### 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
|
||||
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
|
||||
plot([sin,cos],0,4π)
|
||||
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))
|
||||
```
|
||||
|
||||

|
||||
|
||||
###
|
||||
### 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
|
||||
plot(sin,(x->begin # /home/tom/.julia/v0.4/Plots/docs/example_generation.jl, line 33:
|
||||
sin(2x)
|
||||
end),0,2π,legend=false,fillto=0)
|
||||
y = rand(100)
|
||||
plot(0:10:100,rand(11,4),lab="lines",w=3,palette=:grays,fill=(0.5,:auto))
|
||||
scatter!(y,z=abs(y - 0.5),m=(10,:heat),lab="grad")
|
||||
```
|
||||
|
||||

|
||||
|
||||
### 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
|
||||
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
|
||||
|
||||
```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
|
||||
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...
|
||||
|
||||
```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.
|
||||
|
||||
```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
|
||||
types = intersect(supportedTypes(),[:line,:path,:steppre,:steppost,:sticks,:scatter])
|
||||
types = intersect(supportedTypes(),[:line,:path,:steppre,:steppost,:sticks,:scatter])'
|
||||
n = length(types)
|
||||
x = Vector[sort(rand(20)) for i = 1: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
|
||||
styles = setdiff(supportedStyles(),[:auto])
|
||||
styles = setdiff(supportedStyles(),[:auto])'
|
||||
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
|
||||
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)
|
||||
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)
|
||||
```
|
||||
|
||||

|
||||
@@ -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)
|
||||
|
||||
```julia
|
||||
bar(randn(1000))
|
||||
bar(randn(999))
|
||||
```
|
||||
|
||||

|
||||
@@ -182,7 +184,7 @@ histogram(randn(1000),nbins=50)
|
||||
|
||||
|
||||
```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.
|
||||
|
||||
```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
|
||||
subplot!(randn(100,3))
|
||||
subplot!(fakedata(100,10))
|
||||
```
|
||||
|
||||

|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Examples for backend: immerse
|
||||
|
||||
- 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 linetype: `:none`, `:line`, `:path`, `:steppost`, `:sticks`, `:scatter`, `:heatmap`, `:hexbin`, `:hist`, `:bar`, `:hline`, `:vline`, `:ohlc`
|
||||
- Supported values for linestyle: `:auto`, `:solid`, `:dash`, `:dot`, `:dashdot`, `:dashdotdot`
|
||||
@@ -19,14 +19,14 @@ immerse()
|
||||
A simple line plot of the columns.
|
||||
|
||||
```julia
|
||||
plot(rand(50,5),w=3)
|
||||
plot(fakedata(50,5),w=3)
|
||||
```
|
||||
|
||||

|
||||
|
||||
### 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
|
||||
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
|
||||
plot([sin,cos],0,4π)
|
||||
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))
|
||||
```
|
||||
|
||||

|
||||
|
||||
###
|
||||
### 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
|
||||
plot(sin,(x->begin # /home/tom/.julia/v0.4/Plots/docs/example_generation.jl, line 33:
|
||||
sin(2x)
|
||||
end),0,2π,legend=false,fillto=0)
|
||||
y = rand(100)
|
||||
plot(0:10:100,rand(11,4),lab="lines",w=3,palette=:grays,fill=(0.5,:auto))
|
||||
scatter!(y,z=abs(y - 0.5),m=(10,:heat),lab="grad")
|
||||
```
|
||||
|
||||

|
||||
|
||||
### 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
|
||||
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
|
||||
|
||||
```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
|
||||
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...
|
||||
|
||||
```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.
|
||||
|
||||
```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
|
||||
types = intersect(supportedTypes(),[:line,:path,:steppre,:steppost,:sticks,:scatter])
|
||||
types = intersect(supportedTypes(),[:line,:path,:steppre,:steppost,:sticks,:scatter])'
|
||||
n = length(types)
|
||||
x = Vector[sort(rand(20)) for i = 1: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
|
||||
styles = setdiff(supportedStyles(),[:auto])
|
||||
styles = setdiff(supportedStyles(),[:auto])'
|
||||
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
|
||||
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)
|
||||
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)
|
||||
```
|
||||
|
||||

|
||||
@@ -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)
|
||||
|
||||
```julia
|
||||
bar(randn(1000))
|
||||
bar(randn(999))
|
||||
```
|
||||
|
||||

|
||||
@@ -182,7 +184,7 @@ histogram(randn(1000),nbins=50)
|
||||
|
||||
|
||||
```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.
|
||||
|
||||
```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
|
||||
subplot!(randn(100,3))
|
||||
subplot!(fakedata(100,10))
|
||||
```
|
||||
|
||||

|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
# Examples for backend: pyplot
|
||||
|
||||
- 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 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`
|
||||
- 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 marker: `:none`, `:auto`, `:rect`, `:ellipse`, `:diamond`, `:utriangle`, `:dtriangle`, `:cross`, `:xcross`, `:star1`, `:hexagon`
|
||||
- Is `subplot`/`subplot!` supported? No
|
||||
@@ -19,14 +19,14 @@ pyplot()
|
||||
A simple line plot of the columns.
|
||||
|
||||
```julia
|
||||
plot(rand(50,5),w=3)
|
||||
plot(fakedata(50,5),w=3)
|
||||
```
|
||||
|
||||

|
||||
|
||||
### 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
|
||||
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
|
||||
plot([sin,cos],0,4π)
|
||||
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))
|
||||
```
|
||||
|
||||

|
||||
|
||||
###
|
||||
### 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
|
||||
plot(sin,(x->begin # /home/tom/.julia/v0.4/Plots/docs/example_generation.jl, line 33:
|
||||
sin(2x)
|
||||
end),0,2π,legend=false,fillto=0)
|
||||
y = rand(100)
|
||||
plot(0:10:100,rand(11,4),lab="lines",w=3,palette=:grays,fill=(0.5,:auto))
|
||||
scatter!(y,z=abs(y - 0.5),m=(10,:heat),lab="grad")
|
||||
```
|
||||
|
||||

|
||||
|
||||
### 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
|
||||
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
|
||||
|
||||
```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
|
||||
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...
|
||||
|
||||
```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.
|
||||
|
||||
```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
|
||||
types = intersect(supportedTypes(),[:line,:path,:steppre,:steppost,:sticks,:scatter])
|
||||
types = intersect(supportedTypes(),[:line,:path,:steppre,:steppost,:sticks,:scatter])'
|
||||
n = length(types)
|
||||
x = Vector[sort(rand(20)) for i = 1: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
|
||||
styles = setdiff(supportedStyles(),[:auto])
|
||||
styles = setdiff(supportedStyles(),[:auto])'
|
||||
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
|
||||
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)
|
||||
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)
|
||||
```
|
||||
|
||||

|
||||
@@ -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)
|
||||
|
||||
```julia
|
||||
bar(randn(1000))
|
||||
bar(randn(999))
|
||||
```
|
||||
|
||||

|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
# Examples for backend: qwt
|
||||
|
||||
- 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 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`
|
||||
- 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 marker: `:none`, `:auto`, `:rect`, `:ellipse`, `:diamond`, `:utriangle`, `:dtriangle`, `:cross`, `:xcross`, `:star1`, `:star2`, `:hexagon`
|
||||
- Is `subplot`/`subplot!` supported? Yes
|
||||
@@ -19,14 +19,14 @@ qwt()
|
||||
A simple line plot of the columns.
|
||||
|
||||
```julia
|
||||
plot(rand(50,5),w=3)
|
||||
plot(fakedata(50,5),w=3)
|
||||
```
|
||||
|
||||

|
||||
|
||||
### 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
|
||||
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
|
||||
plot([sin,cos],0,4π)
|
||||
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))
|
||||
```
|
||||
|
||||

|
||||
|
||||
###
|
||||
### 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
|
||||
plot(sin,(x->begin # /home/tom/.julia/v0.4/Plots/docs/example_generation.jl, line 33:
|
||||
sin(2x)
|
||||
end),0,2π,legend=false,fillto=0)
|
||||
y = rand(100)
|
||||
plot(0:10:100,rand(11,4),lab="lines",w=3,palette=:grays,fill=(0.5,:auto))
|
||||
scatter!(y,z=abs(y - 0.5),m=(10,:heat),lab="grad")
|
||||
```
|
||||
|
||||

|
||||
|
||||
### 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
|
||||
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
|
||||
|
||||
```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 (marker/markersize) with arguments unique to each series (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
|
||||
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...
|
||||
|
||||
```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.
|
||||
|
||||
```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
|
||||
types = intersect(supportedTypes(),[:line,:path,:steppre,:steppost,:sticks,:scatter])
|
||||
types = intersect(supportedTypes(),[:line,:path,:steppre,:steppost,:sticks,:scatter])'
|
||||
n = length(types)
|
||||
x = Vector[sort(rand(20)) for i = 1: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
|
||||
styles = setdiff(supportedStyles(),[:auto])
|
||||
styles = setdiff(supportedStyles(),[:auto])'
|
||||
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
|
||||
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)
|
||||
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)
|
||||
```
|
||||
|
||||

|
||||
@@ -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)
|
||||
|
||||
```julia
|
||||
bar(randn(1000))
|
||||
bar(randn(999))
|
||||
```
|
||||
|
||||

|
||||
@@ -182,7 +184,7 @@ histogram(randn(1000),nbins=50)
|
||||
|
||||
|
||||
```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.
|
||||
|
||||
```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
|
||||
subplot!(randn(100,3))
|
||||
subplot!(fakedata(100,10))
|
||||
```
|
||||
|
||||

|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
# Plots
|
||||
|
||||
[](https://travis-ci.org/tbreloff/Plots.jl)
|
||||
[](http://pkg.julialang.org/?pkg=Plots&ver=0.3)
|
||||
[](http://pkg.julialang.org/?pkg=Plots&ver=0.4)
|
||||
[](http://pkg.julialang.org/?pkg=Plots&ver=0.5)
|
||||
|
||||
#### Author: Thomas Breloff (@tbreloff)
|
||||
|
||||
@@ -30,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):
|
||||
@@ -64,7 +73,7 @@ using RDatasets
|
||||
iris = dataset("datasets", "iris");
|
||||
|
||||
# This will bring up a browser window with the plot. Add a semicolon at the end to skip display.
|
||||
scatter(iris, :SepalLength, :SepalWidth, group=:Species, ms=12, m=[:+,:d,:s])
|
||||
scatter(iris, :SepalLength, :SepalWidth, group=:Species, m=([:+ :d :s], 12))
|
||||
|
||||
# save a png (equivalent to png("gadfly1.png") and savefig("gadfly1.png"))
|
||||
png("gadfly1")
|
||||
@@ -126,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:
|
||||
@@ -174,6 +192,10 @@ 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)
|
||||
yticks!{T<:Real}(v::AVec{T}) = plot!(yticks = v)
|
||||
xflip!(flip::Bool = true) = plot!(xflip = flip)
|
||||
yflip!(flip::Bool = true) = plot!(yflip = flip)
|
||||
xaxis!(args...) = plot!(xaxis = args)
|
||||
yaxis!(args...) = plot!(yaxis = args)
|
||||
annotate!(anns) = plot!(annotation = anns)
|
||||
```
|
||||
|
||||
@@ -196,11 +218,25 @@ Markers:
|
||||
|
||||
__Tip__: You can see the default value for a given argument with `default(arg::Symbol)`, and set the default value with `default(arg::Symbol, value)` or `default(; kw...)`. For example set the default window size and whether we should show a legend with `default(size=(600,400), leg=false)`.
|
||||
|
||||
__Tip__: When plotting multiple lines, you can set all series to use the same value, or pass in an array to cycle through values. Example:
|
||||
__Tip__: There are some helper arguments you can set: `xaxis`, `yaxis`, `line`, `marker`, `fill`. These go through special preprocessing to extract values into individual arguments. The order doesn't matter, and if you pass a single value it's equivalent to wrapping it in a Tuple. Examples:
|
||||
|
||||
```
|
||||
plot(y, xaxis = ("mylabel", :log, :flip, (-1,1))) # this sets the `xlabel`, `xscale`, `xflip`, and `xlims` arguments automatically
|
||||
plot(y, line = (:bar, :blue, :dot, 10)) # this sets the `linetype`, `color`, `linestyle`, and `linewidth` arguments automatically
|
||||
plot(y, marker = (:rect, :red, 10)) # this sets the `markershape`, `markercolor`, and `markersize` arguments automatically
|
||||
plot(y, fill = (:green, 10)) # this sets the `fillcolor` and `fillrange` arguments automatically
|
||||
# Note: `fillrange` can be:
|
||||
a number (fill to horizontal line)
|
||||
a vector of numbers (different for each data point)
|
||||
a tuple of vectors (fill a band)
|
||||
```
|
||||
|
||||
__Tip__: When plotting multiple lines, you can set all series to use the same value, or pass in a matrix to cycle through values. Example:
|
||||
|
||||
```julia
|
||||
plot(rand(100,4); color = [:red, RGB(0,0,1)], # lines 1 and 3 are red, lines 2 and 4 are blue
|
||||
plot(rand(100,4); color = [:red RGB(0,0,1)], # (Matrix) lines 1 and 3 are red, lines 2 and 4 are blue
|
||||
axis = :auto, # lines 1 and 3 are on the left axis, lines 2 and 4 are on the right
|
||||
markershape = [:rect, :star1] # (Vector) ALL lines are passed the vector [:rect, :star1]
|
||||
width = 5) # all lines have a width of 5
|
||||
```
|
||||
|
||||
@@ -213,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
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
# Examples for backend: winston
|
||||
|
||||
- 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 arguments: `annotation`, `color`, `color_palette`, `fillrange`, `fillcolor`, `group`, `label`, `legend`, `linestyle`, `linetype`, `linewidth`, `markershape`, `markercolor`, `markersize`, `nbins`, `reg`, `show`, `size`, `title`, `windowtitle`, `x`, `xlabel`, `xlims`, `y`, `ylabel`, `ylims`, `xscale`, `yscale`
|
||||
- Supported values for axis: `:auto`, `:left`
|
||||
- Supported values for linetype: `:none`, `:line`, `:path`, `:sticks`, `:scatter`, `:hist`, `:bar`
|
||||
- Supported values for linestyle: `:solid`, `:dash`, `:dot`, `:dashdot`
|
||||
- Supported values for marker: `:none`, `:ellipse`, `:rect`, `:diamond`, `:utriangle`, `:dtriangle`, `:cross`, `:xcross`, `:star1`
|
||||
- Supported values for linestyle: `:auto`, `:solid`, `:dash`, `:dot`, `:dashdot`
|
||||
- Supported values for marker: `:none`, `:auto`, `:rect`, `:ellipse`, `:diamond`, `:utriangle`, `:dtriangle`, `:cross`, `:xcross`, `:star1`
|
||||
- Is `subplot`/`subplot!` supported? No
|
||||
|
||||
### Initialize
|
||||
@@ -19,14 +19,14 @@ winston()
|
||||
A simple line plot of the columns.
|
||||
|
||||
```julia
|
||||
plot(rand(50,5),w=3)
|
||||
plot(fakedata(50,5),w=3)
|
||||
```
|
||||
|
||||

|
||||
|
||||
### 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
|
||||
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
|
||||
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π,line=4,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
|
||||
plot(sin,(x->begin # /home/tom/.julia/v0.4/Plots/docs/example_generation.jl, line 33:
|
||||
sin(2x)
|
||||
end),0,2π,legend=false,fillto=0)
|
||||
y = rand(100)
|
||||
plot(0:10:100,rand(11,4),lab="lines",w=3,palette=:grays,fill=(0.5,:auto))
|
||||
scatter!(y,z=abs(y - 0.5),m=(10,:heat),lab="grad")
|
||||
```
|
||||
|
||||

|
||||
|
||||
### 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
|
||||
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
|
||||
|
||||
```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
|
||||
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...
|
||||
|
||||
```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.
|
||||
|
||||
```julia
|
||||
scatter!(rand(100),markersize=6,c=:blue)
|
||||
scatter!(rand(100),markersize=6,c=:orange)
|
||||
```
|
||||
|
||||

|
||||
@@ -113,11 +115,11 @@ scatter!(rand(100),markersize=6,c=:blue)
|
||||
|
||||
|
||||
```julia
|
||||
types = intersect(supportedTypes(),[:line,:path,:steppre,:steppost,:sticks,:scatter])
|
||||
types = intersect(supportedTypes(),[:line,:path,:steppre,:steppost,:sticks,:scatter])'
|
||||
n = length(types)
|
||||
x = Vector[sort(rand(20)) for i = 1: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)
|
||||
```
|
||||
|
||||

|
||||
@@ -127,7 +129,7 @@ plot(x,y,t=types,lab=map(string,types))
|
||||
|
||||
|
||||
```julia
|
||||
styles = setdiff(supportedStyles(),[:auto])
|
||||
styles = setdiff(supportedStyles(),[:auto])'
|
||||
plot(cumsum(randn(20,length(styles)),1); style=:auto,label=map(string,styles),w=5)
|
||||
```
|
||||
|
||||
@@ -138,8 +140,8 @@ plot(cumsum(randn(20,length(styles)),1); style=:auto,label=map(string,styles),w=
|
||||
|
||||
|
||||
```julia
|
||||
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)
|
||||
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)
|
||||
```
|
||||
|
||||

|
||||
@@ -149,7 +151,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)
|
||||
|
||||
```julia
|
||||
bar(randn(1000))
|
||||
bar(randn(999))
|
||||
```
|
||||
|
||||

|
||||
|
||||
|
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: 66 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 |
|
Before Width: | Height: | Size: 56 KiB After Width: | Height: | Size: 77 KiB |
|
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: 83 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 |
|
Before Width: | Height: | Size: 156 KiB After Width: | Height: | Size: 63 KiB |
|
Before Width: | Height: | Size: 363 KiB After Width: | Height: | Size: 186 KiB |
|
Before Width: | Height: | Size: 62 KiB After Width: | Height: | Size: 46 KiB |
|
Before Width: | Height: | Size: 62 KiB After Width: | Height: | Size: 48 KiB |
|
Before Width: | Height: | Size: 29 KiB After Width: | Height: | Size: 44 KiB |
|
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 17 KiB |
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 11 KiB |
|
Before Width: | Height: | Size: 48 KiB After Width: | Height: | Size: 36 KiB |
|
Before Width: | Height: | Size: 34 KiB After Width: | Height: | Size: 28 KiB |
|
Before Width: | Height: | Size: 48 KiB After Width: | Height: | Size: 30 KiB |
|
Before Width: | Height: | Size: 38 KiB After Width: | Height: | Size: 74 KiB |
|
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 29 KiB |
|
Before Width: | Height: | Size: 85 KiB After Width: | Height: | Size: 69 KiB |
|
Before Width: | Height: | Size: 44 KiB After Width: | Height: | Size: 40 KiB |
|
Before Width: | Height: | Size: 59 KiB After Width: | Height: | Size: 61 KiB |
|
Before Width: | Height: | Size: 48 KiB After Width: | Height: | Size: 48 KiB |
|
Before Width: | Height: | Size: 26 KiB After Width: | Height: | Size: 19 KiB |
|
Before Width: | Height: | Size: 23 KiB After Width: | Height: | Size: 17 KiB |
|
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 16 KiB |
|
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 15 KiB |
|
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 11 KiB |
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 9.5 KiB |
|
Before Width: | Height: | Size: 23 KiB After Width: | Height: | Size: 18 KiB |
|
Before Width: | Height: | Size: 27 KiB After Width: | Height: | Size: 27 KiB |
|
Before Width: | Height: | Size: 31 KiB After Width: | Height: | Size: 36 KiB |
|
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 13 KiB |
|
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 8.4 KiB |
|
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 15 KiB |
|
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 10 KiB |
|
Before Width: | Height: | Size: 21 KiB After Width: | Height: | Size: 15 KiB |
|
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 13 KiB |
|
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 13 KiB |
|
Before Width: | Height: | Size: 44 KiB After Width: | Height: | Size: 52 KiB |
|
Before Width: | Height: | Size: 7.3 KiB After Width: | Height: | Size: 6.9 KiB |
|
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 18 KiB |
|
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 10 KiB |
|
Before Width: | Height: | Size: 9.5 KiB After Width: | Height: | Size: 9.4 KiB |
|
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 18 KiB |
|
Before Width: | Height: | Size: 75 KiB After Width: | Height: | Size: 37 KiB |
|
Before Width: | Height: | Size: 25 KiB After Width: | Height: | Size: 42 KiB |
|
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 22 KiB |
|
Before Width: | Height: | Size: 23 KiB After Width: | Height: | Size: 24 KiB |
|
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 18 KiB |