伝説のlegend_*
シリーズは今回で最後です。
legend_foreground_color
, legend_background_color
凡例の外枠の色,背景の色を指定します。特に変わったところはないと思います。
別名
なぜかすごく多いです。理由はよく分かりません。
legend_foreground_color
fg_color_legend
,fg_colour_legend
,fg_legend
,fgcolor_legend
,fgcolorlegend
,fgcolour_legend
,fgcolourlegend
,fglegend
,foreground_color_legend
,foreground_colour_legend
,foreground_legend
,foregroundcolorlegend
,foregroundcolourlegend
,foregroundlegend
,legend_foreground_colors
,legendforegroundcolor
,legendforegroundcolors
legend_background_color
background_color_legend
,background_colour_legend
,background_legend
,backgroundcolorlegend
,backgroundcolourlegend
,backgroundlegend
,bg_color_legend
,bg_colour_legend
,bg_legend
,bgcolor_legend
,bgcolorlegend
,bgcolour_legend
,bgcolourlegend
,bglegend
,legend_background_colors
,legendbackgroundcolor
,legendbackgroundcolors
使用例
実はネットを調べていて昨日気がついたのですが,色の指定方法は色名を示す文字列
も使えるようです。
なお,使える文字列はColors.color_names
あたりを参照ください。
using Plots gr() plts = [plot(sin; legend_foreground_color=x, legend_background_color=y, title="fg=$(x)\nbg=$(y)", titlefontsize=10 ) for x in [:blue, colorant"red", "green"], y in [:yellow, colorant"honeydew", "cyan"]] plot(plts...; size=(900, 600)) savefig("legend_fgbg_color.png")
legend_column
凡例の列挙の「列数」を指定します。
別名
legend_column
legend_columns
legendcolumn
legendcolumns
使用例
変わったところでは-1
の指定です。
この-1
を指定すると列数を最大にします。
列数を指定すると,その列数で凡例を表示します。
上の行から横に表示していき,指定した列数になると次の行,といった表示になります。
using Plots gr() plts = [plot([sin, cos, x -> 2 * sin(x), x -> 2 * cos(x)], label=["sin" "cos" "2sin" "2cos"], title="legend_column=$k", legend_column=k, margin=(5, :mm) ) for k in [-1, 1, 2, 3, 4]] plot(plts..., layout=(2, 3), size=(800, 600)) savefig("legend-column.png")
まとめ
ようやく凡例関係が終わりました。一週間に一回ぐらいだと何年もかかりそうな感じです。
今回の中ではlegend_column
の-1
とかは使うことがあるでしょうか。昔はレイアウトが崩れにくいので,
エクセルとかではlegend_position=:outertop
, legend_column=-1
に相当する図を仕事用の資料で多用していたような気がします。
それではまた。