readme and shorthands for switching plotters
This commit is contained in:
parent
c23d6d62e7
commit
35df39a44b
27
README.md
27
README.md
@ -48,7 +48,7 @@ which saves:
|
|||||||
Do a plot in Qwt, then save a png:
|
Do a plot in Qwt, then save a png:
|
||||||
|
|
||||||
```
|
```
|
||||||
plotter!(:qwt) # switches the backend to Qwt
|
qwt!() # switches the backend to Qwt... equivalent to `plotter!(:qwt)`
|
||||||
plot(rand(10,2); marker = :rect)
|
plot(rand(10,2); marker = :rect)
|
||||||
savepng(Plots.IMG_DIR * "qwt1.png")
|
savepng(Plots.IMG_DIR * "qwt1.png")
|
||||||
```
|
```
|
||||||
@ -57,17 +57,17 @@ which saves:
|
|||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
See the examples pages for much more in every supported backend.
|
||||||
|
|
||||||
## plot and plotter! interface (WIP)
|
## plot and plotter! interface (WIP)
|
||||||
|
|
||||||
The main plot command. Call `plotter!(:module)` to set the current plotting backend.
|
The main plot command. Call `plotter!(:module)` or `module!()` (i.e. `qwt!()`, `unicodeplots!()`, etc) to set the current plotting backend.
|
||||||
Commands are converted into the relevant plotting commands for that package:
|
Commands are converted into the relevant plotting commands for that package:
|
||||||
|
|
||||||
```
|
```
|
||||||
plotter!(:gadfly)
|
gadfly!()
|
||||||
plot(1:10) # this effectively calls `y = 1:10; Gadfly.plot(x=1:length(y), y=y)`
|
plot(1:10) # this effectively calls `y = 1:10; Gadfly.plot(x=1:length(y), y=y)`
|
||||||
plotter!(:qwt)
|
qwt!()
|
||||||
plot(1:10) # this effectively calls `Qwt.plot(1:10)`
|
plot(1:10) # this effectively calls `Qwt.plot(1:10)`
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -88,8 +88,11 @@ Here are some various args to supply, and the implicit mapping (AVec == Abstract
|
|||||||
plot(y::AMat; kw...) # multiple lines (one per column of x), all sharing x = 1:size(y,1)
|
plot(y::AMat; kw...) # multiple lines (one per column of x), all sharing x = 1:size(y,1)
|
||||||
plot(x::AVec, y::AMat; kw...) # multiple lines (one per column of x), all sharing x (will assert length(x) == size(y,1))
|
plot(x::AVec, y::AMat; kw...) # multiple lines (one per column of x), all sharing x (will assert length(x) == size(y,1))
|
||||||
plot(x::AMat, y::AMat; kw...) # multiple lines (one per column of x/y... will assert size(x) == size(y))
|
plot(x::AMat, y::AMat; kw...) # multiple lines (one per column of x/y... will assert size(x) == size(y))
|
||||||
plot(x::AVec, f::Function; kw...) # one line, y = f(x)
|
plot(f::Function, xmin::Real, xmax::Real; kw...) # one line, map function for range [xmin,xmax]
|
||||||
plot(x::AMat, f::Function; kw...) # multiple lines, yᵢⱼ = f(xᵢⱼ)
|
plot(f::AVec{Function}, xmin::Real, xmax::Real; kw...) # multiple lines, map functions for range [xmin,xmax]
|
||||||
|
plot(fx::Function, fy::Function, umin::Real, umax::Real; kw...) # parametric plot... x = fx(u), y = fy(u)
|
||||||
|
plot(x::AVec, f::Function; kw...) # one line, y = f(x)... can swap x and f
|
||||||
|
plot(x::AMat, f::Function; kw...) # multiple lines, yᵢⱼ = f(xᵢⱼ)... can swap f and x
|
||||||
plot(x::AVec, fs::AVec{Function}; kw...) # multiple lines, yᵢⱼ = fⱼ(xᵢ)
|
plot(x::AVec, fs::AVec{Function}; kw...) # multiple lines, yᵢⱼ = fⱼ(xᵢ)
|
||||||
plot(y::AVec{AVec}; kw...) # multiple lines, each with x = 1:length(y[i])
|
plot(y::AVec{AVec}; kw...) # multiple lines, each with x = 1:length(y[i])
|
||||||
plot(x::AVec, y::AVec{AVec}; kw...) # multiple lines, will assert length(x) == length(y[i])
|
plot(x::AVec, y::AVec{AVec}; kw...) # multiple lines, will assert length(x) == length(y[i])
|
||||||
@ -105,10 +108,10 @@ Here are some various args to supply, and the implicit mapping (AVec == Abstract
|
|||||||
|
|
||||||
```
|
```
|
||||||
y = rand(100,3)
|
y = rand(100,3)
|
||||||
subplot(y; layout=(2,2), kw...) # creates 3 lines going into 3 separate plots, laid out on a 2x2 grid (last row is filled with plot #3)
|
subplot(y; n = 3) # create an automatic grid, and let it figure out the nr/nc... will put plots 1 and 2 on the first row, and plot 3 by itself on the 2nd row
|
||||||
subplot(y; layout=(1,3), kw...) # again 3 plots, all in the same row
|
subplot(y; n = 3, nr = 1) # create an automatic grid, but fix the number of rows to 1 (so there are n columns)
|
||||||
subplot(y; layout=[1,[2,3]]) # pass a nested Array to fully specify the layout. here the first plot will take up the first row,
|
subplot(y; n = 3, nc = 1) # create an automatic grid, but fix the number of columns to 1 (so there are n rows)
|
||||||
# and the others will share the second row
|
subplot(y; layout = [1, 2]) # explicit layout by row... plot #1 goes by itself in the first row, plots 2 and 3 split the 2nd row (note the n kw is unnecessary)
|
||||||
```
|
```
|
||||||
|
|
||||||
Shorthands:
|
Shorthands:
|
||||||
@ -213,7 +216,7 @@ When plotting multiple lines, you can give every line the same trait by using th
|
|||||||
- [ ] TextPlots.jl
|
- [ ] TextPlots.jl
|
||||||
- [ ] ASCIIPlots.jl
|
- [ ] ASCIIPlots.jl
|
||||||
- [ ] Sparklines.jl
|
- [ ] Sparklines.jl
|
||||||
- [ ] UnicodePlots.jl
|
- [x] UnicodePlots.jl
|
||||||
- [ ] Hinton.jl
|
- [ ] Hinton.jl
|
||||||
- [ ] ImageTerm.jl
|
- [ ] ImageTerm.jl
|
||||||
- [ ] GraphViz.jl
|
- [ ] GraphViz.jl
|
||||||
|
|||||||
@ -27,7 +27,12 @@ export
|
|||||||
histogram!,
|
histogram!,
|
||||||
heatmap!,
|
heatmap!,
|
||||||
|
|
||||||
savepng
|
savepng,
|
||||||
|
|
||||||
|
backends,
|
||||||
|
qwt!,
|
||||||
|
gadfly!,
|
||||||
|
unicodeplots!
|
||||||
|
|
||||||
# ---------------------------------------------------------
|
# ---------------------------------------------------------
|
||||||
|
|
||||||
|
|||||||
@ -3,6 +3,8 @@
|
|||||||
|
|
||||||
immutable GadflyPackage <: PlottingPackage end
|
immutable GadflyPackage <: PlottingPackage end
|
||||||
|
|
||||||
|
gadfly!() = plotter!(:gadfly)
|
||||||
|
|
||||||
|
|
||||||
# create a blank Gadfly.Plot object
|
# create a blank Gadfly.Plot object
|
||||||
function plot(pkg::GadflyPackage; kw...)
|
function plot(pkg::GadflyPackage; kw...)
|
||||||
|
|||||||
@ -3,6 +3,8 @@
|
|||||||
|
|
||||||
immutable QwtPackage <: PlottingPackage end
|
immutable QwtPackage <: PlottingPackage end
|
||||||
|
|
||||||
|
qwt!() = plotter!(:qwt)
|
||||||
|
|
||||||
# -------------------------------
|
# -------------------------------
|
||||||
|
|
||||||
function adjustQwtKeywords(iscreating::Bool; kw...)
|
function adjustQwtKeywords(iscreating::Bool; kw...)
|
||||||
|
|||||||
@ -3,6 +3,8 @@
|
|||||||
|
|
||||||
immutable UnicodePlotsPackage <: PlottingPackage end
|
immutable UnicodePlotsPackage <: PlottingPackage end
|
||||||
|
|
||||||
|
unicodeplots!() = plotter!(:unicodeplots)
|
||||||
|
|
||||||
# -------------------------------
|
# -------------------------------
|
||||||
|
|
||||||
function expandLimits!(lims, x)
|
function expandLimits!(lims, x)
|
||||||
|
|||||||
@ -17,6 +17,8 @@ Base.display(pkg::PlottingPackage, plt::Plot) = error("display($pkg, plt) is not
|
|||||||
|
|
||||||
const AVAILABLE_PACKAGES = [:qwt, :gadfly, :unicodeplots]
|
const AVAILABLE_PACKAGES = [:qwt, :gadfly, :unicodeplots]
|
||||||
const INITIALIZED_PACKAGES = Set{Symbol}()
|
const INITIALIZED_PACKAGES = Set{Symbol}()
|
||||||
|
backends() = AVAILABLE_PACKAGES
|
||||||
|
|
||||||
|
|
||||||
type CurrentPackage
|
type CurrentPackage
|
||||||
sym::Symbol
|
sym::Symbol
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user