supported functions; renamed a few things package to backend

This commit is contained in:
Thomas Breloff 2015-09-16 13:03:37 -04:00
parent ae48bd1abb
commit ceb58a6fe1
40 changed files with 176 additions and 91 deletions

View File

@ -51,17 +51,17 @@ const examples = PlotExample[
[:(heatmap(randn(10000),randn(10000); nbins=100))]),
PlotExample("Suported line types",
"All options: (:line, :orderedline, :step, :stepinverted, :sticks, :scatter, :none, :heatmap, :hexbin, :hist, :bar)",
[:(types = intersect(supportedTypes(), [:line, :orderedline, :path, :step, :stepinverted, :sticks, :scatter])),
[:(types = intersect(supportedTypes(), [:line, :step, :stepinverted, :sticks, :scatter])),
:(n = length(types)),
:(x = Vector[sort(rand(20)) for i in 1:n]),
:(y = rand(20,n)),
:(plot(x, y; linetype=:auto, labels=map(string,types)))]),
:(plot(x, y; linetypes=types, labels=map(string,types)))]),
PlotExample("Supported line styles",
"All options: (:solid, :dash, :dot, :dashdot, :dashdotdot)",
[:(styles = supportedStyles()), :(plot(rand(20,length(styles)); linestyle=:auto, labels=map(string,styles)))]),
[:(styles = setdiff(supportedStyles(), [:auto])), :(plot(rand(20,length(styles)); linestyle=:auto, labels=map(string,styles)))]),
PlotExample("Supported marker types",
"All options: (:none, :auto, :ellipse, :rect, :diamond, :utriangle, :dtriangle, :cross, :xcross, :star1, :star2, :hexagon)",
[:(markers = supportedMarkers()), :(plot([fill(i,10) for i=1:length(markers)]; marker=:auto, labels=map(string,markers), markersize=10))]),
[:(markers = setdiff(supportedMarkers(), [:none,:auto])), :(plot([fill(i,10) for i=1:length(markers)]; marker=:auto, labels=map(string,markers), markersize=10))]),
PlotExample("Bar",
"x is the midpoint of the bar. (todo: allow passing of edges instead of midpoints)",
[:(bar(randn(1000)))]),
@ -91,7 +91,7 @@ const examples = PlotExample[
function generate_markdown(pkgname::Symbol)
# set up the plotter, and don't show the plots by default
plotter!(pkgname)
pkg = plotter!(pkgname)
# plotDefault!(:show, false)
# mkdir if necessary
@ -102,6 +102,15 @@ function generate_markdown(pkgname::Symbol)
# open the markdown file
md = open("$DOCDIR/$(pkgname)_examples.md", "w")
write(md, "# Examples for backend: $pkgname\n\n")
write(md, "- Supported arguments: $(supportedArgs(pkg))\n")
write(md, "- Supported values for axis: $(supportedAxes(pkg))\n")
write(md, "- Supported values for linetype: $(supportedTypes(pkg))\n")
write(md, "- Supported values for linestyle: $(supportedStyles(pkg))\n")
write(md, "- Supported values for marker: $(supportedMarkers(pkg))\n")
write(md, "- Is `subplot`/`subplot!` supported? $(subplotSupported(pkg) ? "Yes" : "No")\n\n")
for (i,example) in enumerate(examples)
try
@ -147,6 +156,10 @@ end
function test_all_examples(pkgname::Symbol)
plts = Dict()
for i in 1:length(examples)
if examples[i].header == "Subplots" && !subplotSupported()
break
end
try
plt = test_example(pkgname, i)
plts[i] = plt

View File

@ -1,3 +1,12 @@
# Examples for backend: gadfly
- Supported arguments: [:args,:axis,:color,:fillto,:heatmap_c,:kwargs,:label,:legend,:linestyle,:linetype,:marker,:markercolor,:markersize,:nbins,:reg,:size,:title,:width,:windowtitle,:xlabel,:ylabel,:yrightlabel]
- Supported values for axis: [:left]
- Supported values for linetype: [:line,:step,:sticks,:scatter,:heatmap,:hexbin,:hist,:bar]
- Supported values for linestyle: [:solid]
- Supported values for marker: [:rect,:ellipse,:diamond,:cross]
- Is `subplot`/`subplot!` supported? Yes
### Lines
A simple line plot of the 3 columns.
@ -10,7 +19,7 @@ plot(rand(100,3))
### Functions
Plot multiple functions.
Plot multiple functions. You can also put the function first.
```julia
plot(0:0.01:4π,[sin,cos])
@ -30,7 +39,7 @@ plot([sin,cos],0,4π)
###
Or make a parametric plot with plot(fx, fy, umin, umax).
Or make a parametric plot (i.e. plot: (fx(u), fy(u))) with plot(fx, fy, umin, umax).
```julia
plot(sin,(x->begin # /home/tom/.julia/v0.4/Plots/docs/example_generation.jl, line 33:
@ -54,7 +63,7 @@ plot(rand(10); title="TITLE",xlabel="XLABEL",ylabel="YLABEL",background_color=RG
Use the `axis` or `axiss` arguments.
Note: This is only supported with Qwt right now
Note: Currently only supported with Qwt and PyPlot
```julia
plot(Vector[randn(100),randn(100) * 100]; axiss=[:left,:right],ylabel="LEFT",yrightlabel="RIGHT")
@ -102,31 +111,34 @@ heatmap(randn(10000),randn(10000); nbins=100)
![](../img/gadfly/gadfly_example_10.png)
### Lots of line types
### Suported line types
Options: (:line, :step, :stepinverted, :sticks, :scatter, :none, :heatmap, :hexbin, :hist, :bar)
Note: some may not work with all backends
All options: (:line, :orderedline, :step, :stepinverted, :sticks, :scatter, :none, :heatmap, :hexbin, :hist, :bar)
```julia
plot(rand(20,4); linetypes=[:line,:step,:sticks,:scatter],labels=["line","step","sticks","dots"])
types = intersect(supportedTypes(),[:line,:orderedline,:path,:step,:stepinverted,:sticks,:scatter])
n = length(types)
x = Vector[sort(rand(20)) for i = 1:n]
y = rand(20,n)
plot(x,y; linetype=:auto,labels=map(string,types))
```
![](../img/gadfly/gadfly_example_11.png)
### Lots of line styles
### Supported line styles
Options: (:solid, :dash, :dot, :dashdot, :dashdotdot)
Note: some may not work with all backends
All options: (:solid, :dash, :dot, :dashdot, :dashdotdot)
```julia
plot(rand(20,5); linestyles=[:solid,:dash,:dot,:dashdot,:dashdotdot],labels=["solid","dash","dot","dashdot","dashdotdot"])
styles = supportedStyles()
plot(rand(20,length(styles)); linestyle=:auto,labels=map(string,styles))
```
![](../img/gadfly/gadfly_example_12.png)
### Lots of marker types
### Supported marker types
All options: (:none, :auto, :ellipse, :rect, :diamond, :utriangle, :dtriangle, :cross, :xcross, :star1, :star2, :hexagon)
```julia
markers = supportedMarkers()
@ -155,3 +167,38 @@ histogram(randn(1000); nbins=50,fillto=20)
![](../img/gadfly/gadfly_example_15.png)
### Subplots
subplot and subplot! are distinct commands which create many plots and add series to them in a circular fashion.
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`.
Note: Gadfly is not very friendly here, and although you can create a plot and save a PNG, I haven't been able to actually display it.
```julia
subplot(randn(100,5); layout=[1,1,3],linetypes=[:line,:hist,:scatter,:step,:bar],nbins=10,legend=false)
```
![](../img/gadfly/gadfly_example_16.png)
### Adding to subplots
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)
```
![](../img/gadfly/gadfly_example_17.png)
###
```julia
subplot!(randn(100,3))
```
![](../img/gadfly/gadfly_example_18.png)

View File

@ -1,3 +1,12 @@
# Examples for backend: qwt
- Supported arguments: [:args,:axis,:color,:fillto,:heatmap_c,:kwargs,:label,:legend,:linestyle,:linetype,:marker,:markercolor,:markersize,:nbins,:reg,:size,:title,:width,:windowtitle,:xlabel,:ylabel,:yrightlabel]
- Supported values for axis: [:auto,:left,:right]
- Supported values for linetype: [:none,:line,:step,:stepinverted,:sticks,:scatter,:heatmap,:hexbin,:hist,:bar]
- Supported values for linestyle: [:auto,:solid,:dash,:dot,:dashdot,:dashdotdot]
- Supported values for marker: [:none,:auto,:ellipse,:rect,:diamond,:utriangle,:dtriangle,:cross,:xcross,:star1,:star2,:hexagon]
- Is `subplot`/`subplot!` supported? Yes
### Lines
A simple line plot of the 3 columns.
@ -10,7 +19,7 @@ plot(rand(100,3))
### Functions
Plot multiple functions.
Plot multiple functions. You can also put the function first.
```julia
plot(0:0.01:4π,[sin,cos])
@ -30,7 +39,7 @@ plot([sin,cos],0,4π)
###
Or make a parametric plot with plot(fx, fy, umin, umax).
Or make a parametric plot (i.e. plot: (fx(u), fy(u))) with plot(fx, fy, umin, umax).
```julia
plot(sin,(x->begin # /home/tom/.julia/v0.4/Plots/docs/example_generation.jl, line 33:
@ -54,7 +63,7 @@ plot(rand(10); title="TITLE",xlabel="XLABEL",ylabel="YLABEL",background_color=RG
Use the `axis` or `axiss` arguments.
Note: This is only supported with Qwt right now
Note: Currently only supported with Qwt and PyPlot
```julia
plot(Vector[randn(100),randn(100) * 100]; axiss=[:left,:right],ylabel="LEFT",yrightlabel="RIGHT")
@ -102,35 +111,38 @@ heatmap(randn(10000),randn(10000); nbins=100)
![](../img/qwt/qwt_example_10.png)
### Lots of line types
### Suported line types
Options: (:line, :step, :stepinverted, :sticks, :scatter, :none, :heatmap, :hexbin, :hist, :bar)
Note: some may not work with all backends
All options: (:line, :orderedline, :step, :stepinverted, :sticks, :scatter, :none, :heatmap, :hexbin, :hist, :bar)
```julia
plot(rand(20,4); linetypes=[:line,:step,:sticks,:scatter],labels=["line","step","sticks","dots"])
types = intersect(supportedTypes(),[:line,:step,:stepinverted,:sticks,:scatter])
n = length(types)
x = Vector[sort(rand(20)) for i = 1:n]
y = rand(20,n)
plot(x,y; linetype=:auto,labels=map(string,types))
```
![](../img/qwt/qwt_example_11.png)
### Lots of line styles
### Supported line styles
Options: (:solid, :dash, :dot, :dashdot, :dashdotdot)
Note: some may not work with all backends
All options: (:solid, :dash, :dot, :dashdot, :dashdotdot)
```julia
plot(rand(20,5); linestyles=[:solid,:dash,:dot,:dashdot,:dashdotdot],labels=["solid","dash","dot","dashdot","dashdotdot"])
styles = setdiff(supportedStyles(),[:auto])
plot(rand(20,length(styles)); linestyle=:auto,labels=map(string,styles))
```
![](../img/qwt/qwt_example_12.png)
### Lots of marker types
### Supported marker types
Options: (:none, :ellipse, :rect, :diamond, :utriangle, :dtriangle, :cross, :xcross, :star1, :star2, :hexagon)
Note: some may not work with all backends
All options: (:none, :auto, :ellipse, :rect, :diamond, :utriangle, :dtriangle, :cross, :xcross, :star1, :star2, :hexagon)
```julia
plot(repmat(collect(1:10)',10,1); markers=[:ellipse,:rect,:diamond,:utriangle,:dtriangle,:cross,:xcross,:star1,:star2,:hexagon],labels=["ellipse","rect","diamond","utriangle","dtriangle","cross","xcross","star1","star2","hexagon"],linetype=:none,markersize=10)
markers = setdiff(supportedMarkers(),[:none,:auto])
plot([fill(i,10) for i = 1:length(markers)]; marker=:auto,labels=map(string,markers),markersize=10)
```
![](../img/qwt/qwt_example_13.png)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 80 KiB

After

Width:  |  Height:  |  Size: 76 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 94 KiB

After

Width:  |  Height:  |  Size: 82 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 31 KiB

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 64 KiB

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 27 KiB

After

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 44 KiB

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 56 KiB

After

Width:  |  Height:  |  Size: 60 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 77 KiB

After

Width:  |  Height:  |  Size: 75 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 27 KiB

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 32 KiB

After

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 34 KiB

After

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 40 KiB

After

Width:  |  Height:  |  Size: 39 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 42 KiB

After

Width:  |  Height:  |  Size: 37 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 73 KiB

After

Width:  |  Height:  |  Size: 74 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 23 KiB

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 52 KiB

After

Width:  |  Height:  |  Size: 50 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.4 KiB

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 42 KiB

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 68 KiB

After

Width:  |  Height:  |  Size: 59 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 101 KiB

After

Width:  |  Height:  |  Size: 81 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 22 KiB

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 42 KiB

After

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 25 KiB

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 43 KiB

After

Width:  |  Height:  |  Size: 46 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 28 KiB

After

Width:  |  Height:  |  Size: 31 KiB

View File

@ -9,11 +9,16 @@ const TYPES = [:line, :step, :stepinverted, :sticks, :scatter, :heatmap, :hexbin
const STYLES = [:solid, :dash, :dot, :dashdot, :dashdotdot]
const MARKERS = [:ellipse, :rect, :diamond, :utriangle, :dtriangle, :cross, :xcross, :star1, :star2, :hexagon]
supportedAxes(::PlottingPackage) = AXES
supportedTypes(::PlottingPackage) = TYPES
supportedStyles(::PlottingPackage) = STYLES
supportedMarkers(::PlottingPackage) = MARKERS
subplotSupported(::GadflyPackage) = true
const ALL_AXES = vcat(:auto, AXES)
const ALL_TYPES = vcat(:none, TYPES)
const ALL_STYLES = vcat(:auto, STYLES)
const ALL_MARKERS = vcat(:none, :auto, MARKERS)
supportedAxes(::PlottingPackage) = ALL_AXES
supportedTypes(::PlottingPackage) = ALL_TYPES
supportedStyles(::PlottingPackage) = ALL_STYLES
supportedMarkers(::PlottingPackage) = ALL_MARKERS
subplotSupported(::PlottingPackage) = true
supportedAxes() = supportedAxes(plotter())
supportedTypes() = supportedTypes(plotter())
@ -78,6 +83,8 @@ makeplural(s::Symbol) = Symbol(string(s,"s"))
autopick(arr::AVec, idx::Integer) = arr[mod1(idx,length(arr))]
autopick(notarr, idx::Integer) = notarr
autopick_ignore_none_auto(arr::AVec, idx::Integer) = autopick(setdiff(arr, [:none, :auto]), idx)
autopick_ignore_none_auto(notarr, idx::Integer) = notarr
# converts a symbol or string into a colorant (Colors.RGB), and assigns a color automatically
# note: if plt is nothing, we aren't doing anything with the color anyways
@ -146,16 +153,16 @@ function getPlotKeywordArgs(pkg::PlottingPackage, kw, idx::Int, n::Int)
# auto-pick
if n > 0
if d[:axis] == :auto
d[:axis] = autopick(supportedAxes(pkg), n)
end
if d[:linetype] == :auto
d[:linetype] = autopick(supportedTypes(pkg), n)
d[:axis] = autopick_ignore_none_auto(supportedAxes(pkg), n)
end
# if d[:linetype] == :auto
# d[:linetype] = autopick_ignore_none_auto(supportedTypes(pkg), n)
# end
if d[:linestyle] == :auto
d[:linestyle] = autopick(supportedStyles(pkg), n)
d[:linestyle] = autopick_ignore_none_auto(supportedStyles(pkg), n)
end
if d[:marker] == :auto
d[:marker] = autopick(supportedMarkers(pkg), n)
d[:marker] = autopick_ignore_none_auto(supportedMarkers(pkg), n)
end
end

View File

@ -6,11 +6,11 @@ immutable GadflyPackage <: PlottingPackage end
gadfly!() = plotter!(:gadfly)
suppportedArgs(::GadflyPackage) = setdiff(ARGS, [:heatmap_c, :fillto, :pos])
supportedAxes(::GadflyPackage) = [:left]
suppportedArgs(::GadflyPackage) = setdiff(ALL_ARGS, [:heatmap_c, :fillto, :pos])
supportedAxes(::GadflyPackage) = setdiff(ALL_AXES, [:right])
supportedTypes(::GadflyPackage) = setdiff(TYPES, [:stepinverted])
supportedStyles(::GadflyPackage) = [:solid]
supportedMarkers(::GadflyPackage) = [:rect, :ellipse, :diamond, :cross]
supportedStyles(::GadflyPackage) = [:auto, :solid]
supportedMarkers(::GadflyPackage) = [:none, :auto, :rect, :ellipse, :diamond, :cross]
include("gadfly_shapes.jl")

View File

@ -6,7 +6,7 @@ immutable ImmersePackage <: PlottingPackage end
immerse!() = plotter!(:immerse)
suppportedArgs(::ImmersePackage) = setdiff(ARGS, [:heatmap_c, :fillto, :pos])
suppportedArgs(::ImmersePackage) = suppportedArgs(GadflyPackage())
supportedAxes(::ImmersePackage) = supportedAxes(GadflyPackage())
supportedTypes(::ImmersePackage) = supportedTypes(GadflyPackage())
supportedStyles(::ImmersePackage) = supportedStyles(GadflyPackage())

View File

@ -7,11 +7,12 @@ pyplot!() = plotter!(:pyplot)
# -------------------------------
suppportedArgs(::PyPlotPackage) = setdiff(ARGS, [:reg, :heatmap_c, :fillto, :pos])
suppportedArgs(::PyPlotPackage) = setdiff(ALL_ARGS, [:reg, :heatmap_c, :fillto, :pos])
# supportedAxes(::PyPlotPackage) = [:left]
# supportedTypes(::PyPlotPackage) = setdiff(TYPES, [:stepinverted])
supportedStyles(::PyPlotPackage) = [:solid,:dash,:dot,:dashdot]
supportedMarkers(::PyPlotPackage) = [:rect, :ellipse, :diamond, :utriangle, :dtriangle, :cross, :xcross, :star1, :hexagon]
supportedStyles(::PyPlotPackage) = setdiff(ALL_STYLES, [:dashdotdot])
supportedMarkers(::PyPlotPackage) = setdiff(ALL_MARKERS, [:star2])
subplotSupported(::PyPlotPackage) = false
# convert colorant to 4-tuple RGBA
getPyPlotColor(c::Colorant) = map(f->float(f(c)), (red, green, blue, alpha))
@ -180,7 +181,7 @@ function plot!(::PyPlotPackage, plt::Plot; kw...)
extraargs[:label] = d[:label]
# do the plot
@show lt
# @show lt
if lt == :hist
d[:serieshandle] = plotfunc(d[:y]; extraargs...)[1]
elseif lt in (:scatter, :heatmap, :hexbin)

View File

@ -14,6 +14,7 @@ supportedAxes(::[PkgName]Package) = AXES
supportedTypes(::[PkgName]Package) = TYPES
supportedStyles(::[PkgName]Package) = STYLES
supportedMarkers(::[PkgName]Package) = MARKERS
subplotSupported(::[PkgName]Package) = false
# ---------------------------------------------------------------------------

View File

@ -7,11 +7,11 @@ unicodeplots!() = plotter!(:unicodeplots)
# -------------------------------
suppportedArgs(::GadflyPackage) = setdiff(ARGS, [:reg, :heatmap_c, :fillto, :pos])
supportedAxes(::GadflyPackage) = [:left]
supportedTypes(::GadflyPackage) = setdiff(TYPES, [:stepinverted])
supportedStyles(::GadflyPackage) = [:solid]
supportedMarkers(::GadflyPackage) = [:ellipse]
suppportedArgs(::UnicodePlotsPackage) = setdiff(ALL_ARGS, [:reg, :heatmap_c, :fillto, :pos])
supportedAxes(::UnicodePlotsPackage) = [:auto, :left]
supportedTypes(::UnicodePlotsPackage) = setdiff(ALL_TYPES, [:stepinverted])
supportedStyles(::UnicodePlotsPackage) = [:auto, :solid]
supportedMarkers(::UnicodePlotsPackage) = [:none, :auto, :ellipse]
function expandLimits!(lims, x)

View File

@ -21,12 +21,12 @@ Base.display(pkg::PlottingPackage, subplt::Subplot) = error("display($pkg, subpl
# ---------------------------------------------------------
const AVAILABLE_PACKAGES = [:qwt, :gadfly, :unicodeplots, :pyplot, :immerse]
const INITIALIZED_PACKAGES = Set{Symbol}()
backends() = AVAILABLE_PACKAGES
const BACKENDS = [:qwt, :gadfly, :unicodeplots, :pyplot, :immerse]
const INITIALIZED_BACKENDS = Set{Symbol}()
backends() = BACKENDS
function getPlottingPackage(sym::Symbol)
function backend(sym::Symbol)
sym == :qwt && return QwtPackage()
sym == :gadfly && return GadflyPackage()
sym == :unicodeplots && return UnicodePlotsPackage()
@ -36,40 +36,40 @@ function getPlottingPackage(sym::Symbol)
end
type CurrentPackage
type CurrentBackend
sym::Symbol
pkg::PlottingPackage
end
CurrentPackage(sym::Symbol) = CurrentPackage(sym, getPlottingPackage(sym))
CurrentBackend(sym::Symbol) = CurrentBackend(sym, backend(sym))
# ---------------------------------------------------------
function pickDefaultBackend()
try
Pkg.installed("Immerse")
return CurrentPackage(:immerse)
return CurrentBackend(:immerse)
end
try
Pkg.installed("Qwt")
return CurrentPackage(:qwt)
return CurrentBackend(:qwt)
end
try
Pkg.installed("PyPlot")
return CurrentPackage(:pyplot)
return CurrentBackend(:pyplot)
end
try
Pkg.installed("Gadfly")
return CurrentPackage(:gadfly)
return CurrentBackend(:gadfly)
end
try
Pkg.installed("UnicodePlots")
return CurrentPackage(:unicodeplots)
return CurrentBackend(:unicodeplots)
end
warn("You don't have any of the supported backends installed! Chose from ", backends())
return CurrentPackage(:gadfly)
return CurrentBackend(:gadfly)
end
const CURRENT_PACKAGE = pickDefaultBackend()
println("[Plots.jl] Default backend: ", CURRENT_PACKAGE.sym)
const CURRENT_BACKEND = pickDefaultBackend()
println("[Plots.jl] Default backend: ", CURRENT_BACKEND.sym)
# ---------------------------------------------------------
@ -79,12 +79,12 @@ Returns the current plotting package name. Initializes package on first call.
"""
function plotter()
currentPackageSymbol = CURRENT_PACKAGE.sym
if !(currentPackageSymbol in INITIALIZED_PACKAGES)
currentBackendSymbol = CURRENT_BACKEND.sym
if !(currentBackendSymbol in INITIALIZED_BACKENDS)
# initialize
println("[Plots.jl] Initializing package: ", CURRENT_PACKAGE.sym)
if currentPackageSymbol == :qwt
println("[Plots.jl] Initializing package: ", CURRENT_BACKEND.sym)
if currentBackendSymbol == :qwt
try
@eval import Qwt
@eval export Qwt
@ -92,7 +92,7 @@ function plotter()
error("Couldn't import Qwt. Install it with: Pkg.clone(\"https://github.com/tbreloff/Qwt.jl.git\")\n (Note: also requires pyqt and pyqwt)")
end
elseif currentPackageSymbol == :gadfly
elseif currentBackendSymbol == :gadfly
try
@eval import Gadfly, Compose
@eval export Gadfly, Compose
@ -100,7 +100,7 @@ function plotter()
error("Couldn't import Gadfly. Install it with: Pkg.add(\"Gadfly\")")
end
elseif currentPackageSymbol == :unicodeplots
elseif currentBackendSymbol == :unicodeplots
try
@eval import UnicodePlots
@eval export UnicodePlots
@ -108,7 +108,7 @@ function plotter()
error("Couldn't import UnicodePlots. Install it with: Pkg.add(\"UnicodePlots\")")
end
elseif currentPackageSymbol == :pyplot
elseif currentBackendSymbol == :pyplot
try
@eval import PyPlot
@eval export PyPlot
@ -116,7 +116,7 @@ function plotter()
error("Couldn't import PyPlot. Install it with: Pkg.add(\"PyPlot\")")
end
elseif currentPackageSymbol == :immerse
elseif currentBackendSymbol == :immerse
try
@eval import Immerse, Gadfly, Compose, Gtk
@eval export Immerse, Gadfly, Compose, Gtk
@ -125,13 +125,13 @@ function plotter()
end
else
error("Unknown plotter $currentPackageSymbol. Choose from: $AVAILABLE_PACKAGES")
error("Unknown plotter $currentBackendSymbol. Choose from: $BACKENDS")
end
push!(INITIALIZED_PACKAGES, currentPackageSymbol)
push!(INITIALIZED_BACKENDS, currentBackendSymbol)
println("[Plots.jl] done.")
end
CURRENT_PACKAGE.pkg
CURRENT_BACKEND.pkg
end
doc"""
@ -141,22 +141,22 @@ function plotter!(modname)
# set the PlottingPackage
if modname == :qwt
CURRENT_PACKAGE.pkg = QwtPackage()
CURRENT_BACKEND.pkg = QwtPackage()
elseif modname == :gadfly
CURRENT_PACKAGE.pkg = GadflyPackage()
CURRENT_BACKEND.pkg = GadflyPackage()
elseif modname == :unicodeplots
CURRENT_PACKAGE.pkg = UnicodePlotsPackage()
CURRENT_BACKEND.pkg = UnicodePlotsPackage()
elseif modname == :pyplot
CURRENT_PACKAGE.pkg = PyPlotPackage()
CURRENT_BACKEND.pkg = PyPlotPackage()
elseif modname == :immerse
CURRENT_PACKAGE.pkg = ImmersePackage()
CURRENT_BACKEND.pkg = ImmersePackage()
else
error("Unknown plotter $modname. Choose from: $AVAILABLE_PACKAGES")
error("Unknown plotter $modname. Choose from: $BACKENDS")
end
# update the symbol
CURRENT_PACKAGE.sym = modname
CURRENT_BACKEND.sym = modname
# return the package
CURRENT_PACKAGE.pkg
CURRENT_BACKEND.pkg
end

View File

@ -102,6 +102,10 @@ end
# # this adds to a specific subplot... most plot commands will flow through here
function subplot!(subplt::Subplot, args...; kw...)
if !subplotSupported()
error(CURRENT_BACKEND.sym, " does not support the subplot/subplot! commands at this time. Try one of: ", join(filter(pkg->subplotSupported(backend(pkg)), backends()),", "))
end
kwList = createKWargsList(subplt, args...; kw...)
for (i,d) in enumerate(kwList)
subplt.n += 1