working on subplot

This commit is contained in:
Thomas Breloff 2015-09-11 12:53:13 -04:00
parent ea7572154c
commit 75dbe9a46e

View File

@ -1,4 +1,19 @@
abstract SubPlotLayout
type AutoGridLayout
maxplts::Int
maxrows::Int
maxcols::Int
end
# create a grid structure that optimally fits in numplts, optionally fixing the numrows/numcols
function AutoGridLayout(numplts::Int; numrows::Int = -1, numcols::Int = -1)
end
# ------------------------------------------------------------
doc""" doc"""
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; 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)
@ -11,6 +26,7 @@ type SubPlot <: PlottingObject
plotter::PlottingPackage plotter::PlottingPackage
p::Int # number of plots p::Int # number of plots
n::Int # number of series n::Int # number of series
layout::SubPlotLayout
end end
Base.string(subplt::SubPlot) = "SubPlot{$(subplt.plotter) p=$(subplt.p) n=$(subplt.n)}" Base.string(subplt::SubPlot) = "SubPlot{$(subplt.plotter) p=$(subplt.p) n=$(subplt.n)}"
@ -23,5 +39,65 @@ getplot(subplt::SubPlot, i::Int) = subplt.plts[mod1(i, subplt.p)]
function subplot(args...; kw...) function subplot(args...; kw...)
subplt = SubPlot(Plot[], plotter(), 0, 0)
d = Dict(kw)
# figure out the layouts
if !haskey(d, :layout) || d[:layout] == :auto
# do an automatic grid layout
else
layout = d[:layout]
end
end end
# # this creates a new plot with args/kw and sets it to be the current plot
# function plot(args...; kw...)
# plt = plot(plotter(); getPlotKeywordArgs(kw, 1, 0)...) # create a new, blank plot
# plot!(plt, args...; kw...) # add to it
# end
# # this adds to the current plot
# function plot!(args...; kw...)
# plot!(currentPlot(), args...; kw...)
# end
# # this adds to a specific plot... most plot commands will flow through here
# function plot!(plt::Plot, args...; kw...)
# # increment n if we're going directly to the package's plot method
# if length(args) == 0
# plt.n += 1
# end
# plot!(plt.plotter, plt, args...; kw...)
# currentPlot!(plt)
# # do we want to show it?
# d = Dict(kw)
# if haskey(d, :show) && d[:show]
# display(plt)
# end
# plt
# end
# # show/update the plot
# function Base.display(plt::Plot)
# display(plt.plotter, plt)
# end
# # most calls should flow through here now... we create a Dict with the keyword args for each series, and plot them
# function plot!(pkg::PlottingPackage, plt::Plot, args...; kw...)
# kwList = createKWargsList(plt, args...; kw...)
# for (i,d) in enumerate(kwList)
# plt.n += 1
# plot!(pkg, plt; d...)
# end
# plt
# end