diff --git a/docs/example_generation.jl b/docs/example_generation.jl index 9a193b99..b4fca168 100644 --- a/docs/example_generation.jl +++ b/docs/example_generation.jl @@ -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 diff --git a/docs/gadfly_examples.md b/docs/gadfly_examples.md index 7756526c..4d2cb519 100644 --- a/docs/gadfly_examples.md +++ b/docs/gadfly_examples.md @@ -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) + diff --git a/docs/qwt_examples.md b/docs/qwt_examples.md index c0d961bb..b4bf974b 100644 --- a/docs/qwt_examples.md +++ b/docs/qwt_examples.md @@ -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) diff --git a/img/gadfly/gadfly_example_1.png b/img/gadfly/gadfly_example_1.png index 23d323cc..4b8cde8d 100644 Binary files a/img/gadfly/gadfly_example_1.png and b/img/gadfly/gadfly_example_1.png differ diff --git a/img/gadfly/gadfly_example_10.png b/img/gadfly/gadfly_example_10.png index 2398bb92..7e9eea73 100644 Binary files a/img/gadfly/gadfly_example_10.png and b/img/gadfly/gadfly_example_10.png differ diff --git a/img/gadfly/gadfly_example_11.png b/img/gadfly/gadfly_example_11.png index a0f98162..df6f8d6f 100644 Binary files a/img/gadfly/gadfly_example_11.png and b/img/gadfly/gadfly_example_11.png differ diff --git a/img/gadfly/gadfly_example_12.png b/img/gadfly/gadfly_example_12.png index ac61e347..b4ce1389 100644 Binary files a/img/gadfly/gadfly_example_12.png and b/img/gadfly/gadfly_example_12.png differ diff --git a/img/gadfly/gadfly_example_14.png b/img/gadfly/gadfly_example_14.png index 72c79b6a..415a5b1f 100644 Binary files a/img/gadfly/gadfly_example_14.png and b/img/gadfly/gadfly_example_14.png differ diff --git a/img/gadfly/gadfly_example_15.png b/img/gadfly/gadfly_example_15.png index 35a28fcd..e9d6d7cf 100644 Binary files a/img/gadfly/gadfly_example_15.png and b/img/gadfly/gadfly_example_15.png differ diff --git a/img/gadfly/gadfly_example_16.png b/img/gadfly/gadfly_example_16.png index 7bf8bab3..d4aa3958 100644 Binary files a/img/gadfly/gadfly_example_16.png and b/img/gadfly/gadfly_example_16.png differ diff --git a/img/gadfly/gadfly_example_17.png b/img/gadfly/gadfly_example_17.png index 3e45d0fe..7987e389 100644 Binary files a/img/gadfly/gadfly_example_17.png and b/img/gadfly/gadfly_example_17.png differ diff --git a/img/gadfly/gadfly_example_18.png b/img/gadfly/gadfly_example_18.png index 7c4995b5..fcc059d9 100644 Binary files a/img/gadfly/gadfly_example_18.png and b/img/gadfly/gadfly_example_18.png differ diff --git a/img/gadfly/gadfly_example_5.png b/img/gadfly/gadfly_example_5.png index 5ce22eb1..4a85b7b5 100644 Binary files a/img/gadfly/gadfly_example_5.png and b/img/gadfly/gadfly_example_5.png differ diff --git a/img/gadfly/gadfly_example_6.png b/img/gadfly/gadfly_example_6.png index 218edadd..9fe47e6d 100644 Binary files a/img/gadfly/gadfly_example_6.png and b/img/gadfly/gadfly_example_6.png differ diff --git a/img/gadfly/gadfly_example_7.png b/img/gadfly/gadfly_example_7.png index c366d541..d6ceb64f 100644 Binary files a/img/gadfly/gadfly_example_7.png and b/img/gadfly/gadfly_example_7.png differ diff --git a/img/gadfly/gadfly_example_8.png b/img/gadfly/gadfly_example_8.png index 09a4f6d7..965060f4 100644 Binary files a/img/gadfly/gadfly_example_8.png and b/img/gadfly/gadfly_example_8.png differ diff --git a/img/gadfly/gadfly_example_9.png b/img/gadfly/gadfly_example_9.png index d5ac1690..53eb15f6 100644 Binary files a/img/gadfly/gadfly_example_9.png and b/img/gadfly/gadfly_example_9.png differ diff --git a/img/qwt/qwt_example_1.png b/img/qwt/qwt_example_1.png index 96c57029..b703c24e 100644 Binary files a/img/qwt/qwt_example_1.png and b/img/qwt/qwt_example_1.png differ diff --git a/img/qwt/qwt_example_10.png b/img/qwt/qwt_example_10.png index bbaa6fe0..02ff6cf4 100644 Binary files a/img/qwt/qwt_example_10.png and b/img/qwt/qwt_example_10.png differ diff --git a/img/qwt/qwt_example_11.png b/img/qwt/qwt_example_11.png index 53e0620d..b8da6763 100644 Binary files a/img/qwt/qwt_example_11.png and b/img/qwt/qwt_example_11.png differ diff --git a/img/qwt/qwt_example_12.png b/img/qwt/qwt_example_12.png index da2dd1de..9950ff8a 100644 Binary files a/img/qwt/qwt_example_12.png and b/img/qwt/qwt_example_12.png differ diff --git a/img/qwt/qwt_example_13.png b/img/qwt/qwt_example_13.png index 3f785f4f..424cadee 100644 Binary files a/img/qwt/qwt_example_13.png and b/img/qwt/qwt_example_13.png differ diff --git a/img/qwt/qwt_example_14.png b/img/qwt/qwt_example_14.png index 857551df..913f8a46 100644 Binary files a/img/qwt/qwt_example_14.png and b/img/qwt/qwt_example_14.png differ diff --git a/img/qwt/qwt_example_15.png b/img/qwt/qwt_example_15.png index f636a0f7..796e638d 100644 Binary files a/img/qwt/qwt_example_15.png and b/img/qwt/qwt_example_15.png differ diff --git a/img/qwt/qwt_example_16.png b/img/qwt/qwt_example_16.png index e8548935..531c67f5 100644 Binary files a/img/qwt/qwt_example_16.png and b/img/qwt/qwt_example_16.png differ diff --git a/img/qwt/qwt_example_17.png b/img/qwt/qwt_example_17.png index 0b070a39..44251318 100644 Binary files a/img/qwt/qwt_example_17.png and b/img/qwt/qwt_example_17.png differ diff --git a/img/qwt/qwt_example_18.png b/img/qwt/qwt_example_18.png index 40ef3788..1af93a56 100644 Binary files a/img/qwt/qwt_example_18.png and b/img/qwt/qwt_example_18.png differ diff --git a/img/qwt/qwt_example_5.png b/img/qwt/qwt_example_5.png index d56b4cac..ec07d8d5 100644 Binary files a/img/qwt/qwt_example_5.png and b/img/qwt/qwt_example_5.png differ diff --git a/img/qwt/qwt_example_6.png b/img/qwt/qwt_example_6.png index 723d2359..76cdf280 100644 Binary files a/img/qwt/qwt_example_6.png and b/img/qwt/qwt_example_6.png differ diff --git a/img/qwt/qwt_example_7.png b/img/qwt/qwt_example_7.png index f97672bc..f4d6da72 100644 Binary files a/img/qwt/qwt_example_7.png and b/img/qwt/qwt_example_7.png differ diff --git a/img/qwt/qwt_example_8.png b/img/qwt/qwt_example_8.png index 26e269bb..f373b9b0 100644 Binary files a/img/qwt/qwt_example_8.png and b/img/qwt/qwt_example_8.png differ diff --git a/img/qwt/qwt_example_9.png b/img/qwt/qwt_example_9.png index df9c64fb..2ab8ae98 100644 Binary files a/img/qwt/qwt_example_9.png and b/img/qwt/qwt_example_9.png differ diff --git a/src/args.jl b/src/args.jl index 5dbc8df9..fb6ef6fe 100644 --- a/src/args.jl +++ b/src/args.jl @@ -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 diff --git a/src/backends/gadfly.jl b/src/backends/gadfly.jl index 40e036ed..33c8359b 100644 --- a/src/backends/gadfly.jl +++ b/src/backends/gadfly.jl @@ -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") diff --git a/src/backends/immerse.jl b/src/backends/immerse.jl index e19c2d98..2c03d151 100644 --- a/src/backends/immerse.jl +++ b/src/backends/immerse.jl @@ -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()) diff --git a/src/backends/pyplot.jl b/src/backends/pyplot.jl index 7a0abb2e..dfa9efb7 100644 --- a/src/backends/pyplot.jl +++ b/src/backends/pyplot.jl @@ -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) diff --git a/src/backends/template.jl b/src/backends/template.jl index 9f9c988e..5f902dd0 100644 --- a/src/backends/template.jl +++ b/src/backends/template.jl @@ -14,6 +14,7 @@ supportedAxes(::[PkgName]Package) = AXES supportedTypes(::[PkgName]Package) = TYPES supportedStyles(::[PkgName]Package) = STYLES supportedMarkers(::[PkgName]Package) = MARKERS +subplotSupported(::[PkgName]Package) = false # --------------------------------------------------------------------------- diff --git a/src/backends/unicodeplots.jl b/src/backends/unicodeplots.jl index 9cdfe97d..340f04e9 100644 --- a/src/backends/unicodeplots.jl +++ b/src/backends/unicodeplots.jl @@ -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) diff --git a/src/plotter.jl b/src/plotter.jl index 686fb02d..0aecaeb5 100644 --- a/src/plotter.jl +++ b/src/plotter.jl @@ -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 diff --git a/src/subplot.jl b/src/subplot.jl index 2787cc89..b41adcab 100644 --- a/src/subplot.jl +++ b/src/subplot.jl @@ -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