匹配图例和绘图大小

500*_*500 4 plot wolfram-mathematica mathematica-8

请考虑 :

intense = Reverse[Round[Rationalize /@ N[10^Range[0, 3, 1/3]]]];
values = Range[0, 9/10, 1/10];

intensityLegend = Column[Prepend[MapThread[
                         Function[{intensity, values},
                         Row[{Graphics[{(Lighter[Blue, values]),
                         Rectangle[{0, 0}, {4, 1}], Black, 
                         Text[Style[ToString[intensity], 16, Bold], {2, .5}]}]}]],
                        {intense, values}], Text[Style["Photons Number", Bold, 15]]]];

IntersectionDp1={{1., 588.377}, {2.15443, 580.306}, {4.64159, 573.466}, {10.,560.664}, 
                 {21.5443, 552.031}, {46.4159, 547.57}, {100.,545.051}, 
                 {215.443, 543.578}, {464.159, 542.281}, {1000., 541.346}}


FindD1=ListLogLinearPlot[Map[List, IntersectionDp1], 
                  Frame -> True, 
                  AxesOrigin -> {-1, 0}, 
                  PlotMarkers -> 
                  With[{markerSize = 0.04}, {Graphics[{Lighter[Blue, #], Disk[]}], 
                       markerSize} & /@Range[9/10, 0, -1/10]], Filling -> Axis, 
                  FillingStyle -> Opacity[0.8], 
                  PlotRange -> {{.5, 1100}, {540, 600}},
                  ImageSize->400];

Grid[{{intensityLegend, FindD1}, {intensityLegend, FindD1}}, 
      ItemSize -> {50, 20}, Frame -> True]
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

如何获得图例列大小以适应绘图区域的高度?

当Row调整大小时我需要使用Grid.这就是我在网格中重复的原因.

Dr.*_*ius 9

使用图像大小.(*< - *)标志着对代码的重要修改,其余主要是字体大小的东西:

intense = Reverse[Round[Rationalize /@ N[10^Range[0, 3, 1/3]]]];
values = Range[0, 9/10, 1/10];
imgSize = 400;                                                          (* <- *) 
Off[Ticks::ticks]

IntersectionDp1 =  {{1., 588.377},     {2.15443, 580.306}, {4.64159, 573.466}, 
   {10., 560.664}, {21.5443, 552.031}, {46.4159, 547.57},  {100., 545.051},
   {215.443, 543.578}, {464.159, 542.281}, {1000., 541.346}}

FindD1 = ListLogLinearPlot[Map[List, IntersectionDp1], Frame -> True, 
   AxesOrigin -> {-1, 0}, 
   PlotMarkers -> 
    With[{markerSize = 0.04}, 
     {Graphics[{Lighter[Blue, #], Disk[]}], markerSize} & 
       /@ Range[9/10, 0, -1/10]], Filling -> Axis, FillingStyle -> Opacity[0.8], 
       PlotRange -> {{.5, 1100}, {540, 600}}, ImageSize -> imgSize];    (* <- *) 

intensityLegend =
  Rasterize[Column[
    Prepend[
     Reverse@MapThread[                                                 (* <- *) 
      Function[{intensity, values}, 
       Row[{Graphics[{(Lighter[Blue, values]), 
           Rectangle[{0, 0}, {4, 1}], Black, 
           Text[Style[ToString[intensity], 30, Bold], {2, .5}]}]}]],
      {intense, values}],
     Text[Style["Photons Number", Bold, 25]]]], 
   ImageSize -> {Automatic,                                             (* <- *) 
     IntegerPart@                            
      First[imgSize Cases[AbsoluteOptions[FindD1], 
         HoldPattern[AspectRatio -> x_] -> x]]}];

Grid[{{intensityLegend, FindD1}, {intensityLegend, FindD1}}, Frame -> True]
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

我为了审美目的而颠倒了强度柱.

编辑

如果您没有为Plot明确指定ImageSize选项,那么您将会失望地发现AbsoluteOptions[Plot, "ImageSize"]返回"Automatic"!

编辑 回答@ 500的评论

表达方式:

   ImageSize -> {Automatic,                                             (* <- *) 
     IntegerPart@                            
      First[imgSize Cases[AbsoluteOptions[FindD1], 
         HoldPattern[AspectRatio -> x_] -> x]]}];
Run Code Online (Sandbox Code Playgroud)

对于应该工作但不能获得Plot的图像大小的东西来说,它确实是一个有效的替代品:

   ImageSize -> {Automatic, Last@AbsoluteOptions[FindD1,"ImageSize"]}   
Run Code Online (Sandbox Code Playgroud)

那么,什么IntegerPart[...]东西正在做的是让剧情图像的垂直尺寸,乘imgSizeAspectRatio情节的.
要了解它的工作原理,请运行代码,然后键入:

AbsoluteOptions[FindD1] 
Run Code Online (Sandbox Code Playgroud)

你会在那里看到Plot选项.Cases []函数只是提取AspectRatio选项.

事实上,有一种更简洁的方法可以完成Cases []所做的事情.它是:

AbsoluteOptions[FindD1,"AspectRatio"] 
Run Code Online (Sandbox Code Playgroud)

但AbsoluteOptions函数中还有另一个错误,它阻止我们以这种方式使用它.