Update bbs/plot_title (#3604)

* add the plot_title

* update plot_title for multiple subplots, fix GR warning

Co-authored-by: Simon Christ <SimonChrist@gmx.de>
Co-authored-by: t-bltg <t-bltg@users.noreply.github.com>
This commit is contained in:
t-bltg 2021-07-03 17:07:51 +02:00 committed by GitHub
parent 463f1155d8
commit 3340642d43
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 4 deletions

View File

@ -286,14 +286,14 @@ function _add_plot_title!(plt)
plot_title = plt[:plot_title] plot_title = plt[:plot_title]
if plot_title != "" if plot_title != ""
the_layout = plt.layout the_layout = plt.layout
plt.layout = grid(2,1, heights = [0.0,1.0]) plt.layout = grid(2, 1, heights=(.01, .99))
plt.layout.grid[2,1] = the_layout plt.layout.grid[2, 1] = the_layout
subplot = Subplot(backend(), parent = plt.layout[1,1]) subplot = Subplot(backend(), parent = plt.layout[1, 1])
subplot.plt = plt subplot.plt = plt
subplot[:title] = plot_title subplot[:title] = plot_title
subplot[:subplot_index] = last(plt.subplots)[:subplot_index] + 1 subplot[:subplot_index] = last(plt.subplots)[:subplot_index] + 1
subplot[:framestyle] = :none subplot[:framestyle] = :none
plt.layout.grid[1,1] = subplot plt.layout.grid[1, 1] = subplot
push!(plt.subplots, subplot) push!(plt.subplots, subplot)
end end
return nothing return nothing

View File

@ -159,6 +159,7 @@ function plot!(plt1::Plot, plts_tail::Plot...; kw...)
cmdidx += 1 cmdidx += 1
end end
end end
_add_plot_title!(plt)
# first apply any args for the subplots # first apply any args for the subplots
for (idx,sp) in enumerate(plt.subplots) for (idx,sp) in enumerate(plt.subplots)