add the plot_title

This commit is contained in:
Simon Christ 2020-05-09 12:44:04 +02:00
parent 4e2ee35125
commit 26ad869c30

View File

@ -248,6 +248,7 @@ function _subplot_setup(plt::Plot, plotattributes::AKW, kw_list::Vector{KW})
sp_attrs[sp] = attr sp_attrs[sp] = attr
end end
_add_plot_title!(plt)
# override subplot/axis args. `sp_attrs` take precendence # override subplot/axis args. `sp_attrs` take precendence
for (idx, sp) in enumerate(plt.subplots) for (idx, sp) in enumerate(plt.subplots)
attr = if !haskey(plotattributes, :subplot) || plotattributes[:subplot] == idx attr = if !haskey(plotattributes, :subplot) || plotattributes[:subplot] == idx
@ -260,12 +261,29 @@ function _subplot_setup(plt::Plot, plotattributes::AKW, kw_list::Vector{KW})
# do we need to link any axes together? # do we need to link any axes together?
link_axes!(plt.layout, plt[:link]) link_axes!(plt.layout, plt[:link])
return nothing
end end
function series_idx(kw_list::AVec{KW}, kw::AKW) function series_idx(kw_list::AVec{KW}, kw::AKW)
Int(kw[:series_plotindex]) - Int(kw_list[1][:series_plotindex]) + 1 Int(kw[:series_plotindex]) - Int(kw_list[1][:series_plotindex]) + 1
end end
function _add_plot_title!(plt)
plot_title = plt[:plot_title]
if plot_title != ""
the_layout = plt.layout
plt.layout = grid(2,1, heights = [0.0,1.0])
plt.layout.grid[2,1] = the_layout
subplot = Subplot(backend(), parent = plt.layout[1,1])
subplot.plt = plt
subplot[:title] = plot_title
subplot[:subplot_index] = last(plt.subplots)[:subplot_index] + 1
subplot[:framestyle] = :none
plt.layout.grid[1,1] = subplot
push!(plt.subplots, subplot)
end
return nothing
end
## Series recipes ## Series recipes