diff --git a/docs/example_generation.jl b/docs/example_generation.jl index 60df484b..4e40e08c 100644 --- a/docs/example_generation.jl +++ b/docs/example_generation.jl @@ -49,6 +49,23 @@ const examples = PlotExample[ PlotExample("Histogram", "note: fillto isn't supported on all backends", [:(histogram(randn(1000); nbins=50, fillto=20))]), + PlotExample("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. + """, + [:(subplot(randn(100,5); layout=[1,1,3], linetypes=[:line,:hist,:dots,:step,:bar], nbins=10, legend=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))]), + PlotExample("Adding to subplots (continued)", + "", + [:(subplot!(randn(100,3)))]), + + ] diff --git a/docs/gadfly_examples.md b/docs/gadfly_examples.md index 5efbf340..a6e612f6 100644 --- a/docs/gadfly_examples.md +++ b/docs/gadfly_examples.md @@ -100,3 +100,38 @@ histogram(randn(1000); nbins=50,fillto=20) ![](../img/gadfly_example_10.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,:dots,:step,:bar],nbins=10,legend=false) +``` + +![](../img/gadfly_example_11.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_example_12.png) + +### Adding to subplots (continued) + + + +```julia +subplot!(randn(100,3)) +``` + +![](../img/gadfly_example_13.png) + diff --git a/docs/qwt_examples.md b/docs/qwt_examples.md index 41d6b221..ad0b7ae6 100644 --- a/docs/qwt_examples.md +++ b/docs/qwt_examples.md @@ -100,3 +100,38 @@ histogram(randn(1000); nbins=50,fillto=20) ![](../img/qwt_example_10.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,:dots,:step,:bar],nbins=10,legend=false) +``` + +![](../img/qwt_example_11.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/qwt_example_12.png) + +### Adding to subplots (continued) + + + +```julia +subplot!(randn(100,3)) +``` + +![](../img/qwt_example_13.png) + diff --git a/img/gadfly_example_1.png b/img/gadfly_example_1.png index 5f3ff3ac..c23d2bd8 100644 Binary files a/img/gadfly_example_1.png and b/img/gadfly_example_1.png differ diff --git a/img/gadfly_example_10.png b/img/gadfly_example_10.png index 6ef8b8fa..303cd4b7 100644 Binary files a/img/gadfly_example_10.png and b/img/gadfly_example_10.png differ diff --git a/img/gadfly_example_11.png b/img/gadfly_example_11.png new file mode 100644 index 00000000..7a54fd4b Binary files /dev/null and b/img/gadfly_example_11.png differ diff --git a/img/gadfly_example_12.png b/img/gadfly_example_12.png new file mode 100644 index 00000000..1523115c Binary files /dev/null and b/img/gadfly_example_12.png differ diff --git a/img/gadfly_example_13.png b/img/gadfly_example_13.png new file mode 100644 index 00000000..30924be9 Binary files /dev/null and b/img/gadfly_example_13.png differ diff --git a/img/gadfly_example_2.png b/img/gadfly_example_2.png index 02320106..28515e94 100644 Binary files a/img/gadfly_example_2.png and b/img/gadfly_example_2.png differ diff --git a/img/gadfly_example_3.png b/img/gadfly_example_3.png index 9c391552..aad5bc18 100644 Binary files a/img/gadfly_example_3.png and b/img/gadfly_example_3.png differ diff --git a/img/gadfly_example_4.png b/img/gadfly_example_4.png index 734ed1e9..c1209d41 100644 Binary files a/img/gadfly_example_4.png and b/img/gadfly_example_4.png differ diff --git a/img/gadfly_example_5.png b/img/gadfly_example_5.png index 51d0907f..3b4a1e95 100644 Binary files a/img/gadfly_example_5.png and b/img/gadfly_example_5.png differ diff --git a/img/gadfly_example_6.png b/img/gadfly_example_6.png index 48d09e3d..7faeb218 100644 Binary files a/img/gadfly_example_6.png and b/img/gadfly_example_6.png differ diff --git a/img/gadfly_example_7.png b/img/gadfly_example_7.png index aa7b6a1a..5ebf7d53 100644 Binary files a/img/gadfly_example_7.png and b/img/gadfly_example_7.png differ diff --git a/img/gadfly_example_8.png b/img/gadfly_example_8.png index 40d215b3..3f75cc1c 100644 Binary files a/img/gadfly_example_8.png and b/img/gadfly_example_8.png differ diff --git a/img/gadfly_example_9.png b/img/gadfly_example_9.png index 317531b3..a5e33857 100644 Binary files a/img/gadfly_example_9.png and b/img/gadfly_example_9.png differ diff --git a/img/qwt_example_1.png b/img/qwt_example_1.png index 06c9e4a8..0aed8e68 100644 Binary files a/img/qwt_example_1.png and b/img/qwt_example_1.png differ diff --git a/img/qwt_example_10.png b/img/qwt_example_10.png index f54f48eb..0bd15be0 100644 Binary files a/img/qwt_example_10.png and b/img/qwt_example_10.png differ diff --git a/img/qwt_example_11.png b/img/qwt_example_11.png new file mode 100644 index 00000000..e4cfaba7 Binary files /dev/null and b/img/qwt_example_11.png differ diff --git a/img/qwt_example_12.png b/img/qwt_example_12.png new file mode 100644 index 00000000..6d6df9e2 Binary files /dev/null and b/img/qwt_example_12.png differ diff --git a/img/qwt_example_13.png b/img/qwt_example_13.png new file mode 100644 index 00000000..93f16d32 Binary files /dev/null and b/img/qwt_example_13.png differ diff --git a/img/qwt_example_2.png b/img/qwt_example_2.png index 399b8809..d04b7672 100644 Binary files a/img/qwt_example_2.png and b/img/qwt_example_2.png differ diff --git a/img/qwt_example_3.png b/img/qwt_example_3.png index 1699bd45..4cf96a3f 100644 Binary files a/img/qwt_example_3.png and b/img/qwt_example_3.png differ diff --git a/img/qwt_example_4.png b/img/qwt_example_4.png index fe17d098..2860df45 100644 Binary files a/img/qwt_example_4.png and b/img/qwt_example_4.png differ diff --git a/img/qwt_example_5.png b/img/qwt_example_5.png index f21b1c3c..0cf212d8 100644 Binary files a/img/qwt_example_5.png and b/img/qwt_example_5.png differ diff --git a/img/qwt_example_6.png b/img/qwt_example_6.png index bba40e75..e4ae05aa 100644 Binary files a/img/qwt_example_6.png and b/img/qwt_example_6.png differ diff --git a/img/qwt_example_7.png b/img/qwt_example_7.png index ef4d3de2..01200c9b 100644 Binary files a/img/qwt_example_7.png and b/img/qwt_example_7.png differ diff --git a/img/qwt_example_8.png b/img/qwt_example_8.png index 348cfa50..09144d18 100644 Binary files a/img/qwt_example_8.png and b/img/qwt_example_8.png differ diff --git a/img/qwt_example_9.png b/img/qwt_example_9.png index 81c01cb4..eda46cb0 100644 Binary files a/img/qwt_example_9.png and b/img/qwt_example_9.png differ diff --git a/src/Plots.jl b/src/Plots.jl index b120d89c..55572c31 100644 --- a/src/Plots.jl +++ b/src/Plots.jl @@ -12,7 +12,7 @@ export plotter!, plot!, subplot!, - + currentPlot, plotDefault, scatter, @@ -69,7 +69,7 @@ heatmap!(args...; kw...) = plot!(args...; kw..., linetype = :heatmap) savepng(args...; kw...) = savepng(currentPlot(), args...; kw...) -savepng(plt::Plot, args...; kw...) = savepng(plt.plotter, plt, args...; kw...) +savepng(plt::PlottingObject, args...; kw...) = savepng(plt.plotter, plt, args...; kw...) # --------------------------------------------------------- diff --git a/src/gadfly.jl b/src/gadfly.jl index 4530b3dc..81f93f14 100644 --- a/src/gadfly.jl +++ b/src/gadfly.jl @@ -104,8 +104,9 @@ function Base.display(::GadflyPackage, plt::Plot) display(plt.o) end +# ------------------------------- -function savepng(::GadflyPackage, plt::Plot, fn::String; +function savepng(::GadflyPackage, plt::PlottingObject, fn::String; w = 6 * Gadfly.inch, h = 4 * Gadfly.inch) Gadfly.draw(Gadfly.PNG(fn, w, h), plt.o) diff --git a/src/subplot.jl b/src/subplot.jl index dea9f1bf..77e3d209 100644 --- a/src/subplot.jl +++ b/src/subplot.jl @@ -115,7 +115,7 @@ function subplot!(subplt::Subplot, args...; kw...) # do we want to show it? d = Dict(kw) if haskey(d, :show) && d[:show] - display(subplt) + draw(subplt) end subplt