ShowとPlotLegendの行間隔



Show Plotlegend Row Spacing



解決:

アップデート2: 後処理新しい凡例を作成せずにプロット:

Legended [Show [plots [[;; 、1]]、PlotRange-> All]、Column [Join @@ plots [[;; 、2、すべて、1]]、間隔-> -.8]]

Mathematicaグラフィックス



Legended [Show [plots [[;; 、1]]、PlotRange-> All]、Placed [Column [Join @@ plots [[;; 、2、すべて、1]]、間隔-> -.8]、{前、上}]]

Mathematicaグラフィックス

元の投稿:



(afaik)文書化されていないオプションを使用するの「間隔」LineLegend:

legend = LineLegend [Hue [#/ 11]&/ @ Range [10]、( 'Serial' ToString [#])&/ @ Range [10]、LabelStyle-> {FontFamily-> 'Times'、10}、 '間隔 '-> {1、.2}]

または使用するカスタムレイアウト関数を使用したLegendLayout:

legend = LineLegend [Hue [#/ 11]&/ @ Range [10]、( 'Serial' ToString [#])&/ @ Range [10]、LabelStyle-> {FontFamily-> 'Times'、10}、LegendLayout ->(Grid [#、Spacings-> {1、.2}]&)]

取得するため



Mathematicaグラフィックス

その後、使用することができますとの伝説伝説

Legended [Plot [(#x)&/ @ Range [10]、{x、0、1}、Evaluated-> True、PlotStyle->(Hue [#/ 11]&/ @ Range [10])、Frame- > True、FrameLabel-> {'x'、 'y'}、ImageSize-> 4 72、BaseStyle-> {FontFamily-> 'Times'、FontSize-> 10}]、凡例]

またはとPlotLegends

Plot [(#x)&/ @ Range [10]、{x、0、1}、Evaluated-> True、PlotStyle->(Hue [#/ 11]&/ @ Range [10])、Frame-> True 、FrameLabel-> {'x'、 'y'}、ImageSize-> 4 72、BaseStyle-> {FontFamily-> 'Times'、FontSize-> 10}、PlotLegends-> legend]

我々が得る

Mathematicaグラフィックス

アップデート: やり直したくない場合あなたが使用できるプロットでプロット次のような凡例:

Legended [Show [plots [[;;、1]]、PlotRange-> All]、legend]

Mathematicaグラフィックス


たとえば、凡例を最初から再構築したくない場合は、プロットから凡例を抽出して調整することができます。

p = Show [plots、PlotRange-> All]; opt = [email protected] [plots [[1]]、LineLegend [x_List、y_List、opt __]:> {opt}、∞]; lgd = LineLegend [Sequence @@ Transpose [[email protected] [#、LineLegend [x_List、y_List、opt __]:> {x、y}、∞]&/ @ plots]、Sequence @@ FilterRules [opt、Except [LegendLayout ]]、LegendLayout-> {'Column'、2}] Legended [[email protected] [p、Graphics [___]、∞]、lgd]

ここに画像の説明を入力してください

または

lgd = LineLegend [Sequence @@ Transpose [[email protected] [#、LineLegend [x_List、y_List、opt __]:> {x、y}、∞]&/ @ plots]、Sequence @@ FilterRules [opt、Except [LegendLayout ]]、LegendLayout-> {'Row'、2}] Legended [[email protected] [p、Graphics [___]、∞]、Placed [lgd、Bottom]]

ここに画像の説明を入力してください


オプションLegendMarginsを使用すると、間隔を大幅に減らすことができます。

このオプションはに直接追加できますLineLegend

plots = Table [Plot [xi、{x、0、1}、PlotStyle-> {Hue [i / 11]}、PlotLegends-> LineLegend [{'Serial' ToString [i]}、LabelStyle-> {FontFamily-> 'Times'、10}、LegendMargins-> {0、0}]、Frame-> True、FrameLabel-> {'x'、 'y'}、ImageSize-> 4 72、BaseStyle-> {FontFamily-> 'Times '、FontSize-> 10}]、{i、10}]; Show [plots、PlotRange-> All]

プロット1

または後プロットが作成されました。

plots = Table [Plot [xi、{x、0、1}、PlotStyle-> {Hue [i / 11]}、PlotLegends-> LineLegend [{'Serial' ToString [i]}、LabelStyle-> {FontFamily-> 'Times'、10}]、Frame-> True、FrameLabel-> {'x'、 'y'}、ImageSize-> 4 72、BaseStyle-> {FontFamily-> 'Times'、FontSize-> 10}]、 {i、10}]; Show [plots /。 LineLegend [ll __]:> LineLegend [ll、LegendMargins-> {0、0}]、PlotRange-> All]

Plot2

凡例を上から開始するには、追加の交換が1つ必要です。

Show [plots /。 LineLegend [ll __]:> LineLegend [ll、LegendMargins-> {0、0}] /。後-> {後、上}、PlotRange->すべて]

Plot3

負のマージン値は、間隔をさらに縮小します。

Show [plots /。 LineLegend [ll __]:> LineLegend [ll、LegendMargins-> {{5、0}、{-5、-5}}] /。後-> {後、上}、PlotRange->すべて]

Plot4