MathGroup Archive 2003

[Date Index] [Thread Index] [Author Index]

Search the Archive

Fixing the legend

  • To: mathgroup at smc.vnet.net
  • Subject: [mg39088] Fixing the legend
  • From: sergio_r at mail.com (Sergio Rojas)
  • Date: Wed, 29 Jan 2003 03:35:39 -0500 (EST)
  • Sender: owner-wri-mathgroup at wolfram.com

Hello folks,

How can one make the symbols labeling in the legend 
of the following plot to fix inside the surrounding
box? Would it be possible to turn off the symbols
labeling for the 3rd. and 4th. lines, where no
legend is assigned?


(*--------------------------------------------------------------------------*)
 Needs["Graphics`MultipleListPlot`"];
 Needs["Graphics`Legend`"];

Clear[getPlotInfo];
getPlotInfo[data_,x_] :=
  Module[{l2Norm, l2NormToPlot, maxNorm, maxNormToPlot, h , hMin, hMax,
                                                    yl2, l2NormFitedData},
       l2NormToPlot = Table[{ h[i]=data[[i]][[2]],  l2Norm[i]=data[[i]][[3]]},
                                                       {i,1,Length[data]}];
      maxNormToPlot = Table[{      data[[i]][[2]], maxNorm[i]=data[[i]][[4]]},
                                                       {i,1,Length[data]}];
                  h = Log[Table[h[i],{i,1,Length[data]}]];
               hMin = Min[h];
               hMax = Max[h];
             l2Norm = Table[l2Norm[i],{i,1,Length[data]}];
            maxNorm = Table[maxNorm[i],{i,1,Length[data]}];
           yl2[x1_] :=  Evaluate[Fit[Log[l2NormToPlot], {1,x1}, x1]];
    l2NormFitedData = Table[{i,yl2[i]},{i,hMin,hMax,(hMax-hMin)/20}];
     Return[{Log[l2NormToPlot], l2NormFitedData,  yl2[x] }]];

dataM1 =
{{5., 0.25, 0.00217807, 0.00325421}, {10., 0.111111, 0.00042537099999999996,
  0.000712573}, {20., 0.0526316, 0.0000934578, 0.000167083},
 {40., 0.025640999999999997, 0.000021898399999999997, 0.0000404748},
 {80., 0.0126582, 5.300360000000001*^-6, 9.961790000000001*^-6}};

dataM2 =
{{5., 0.25, 0.00880884, 0.010398000000000001},
 {10., 0.111111, 0.00190426, 0.00209391}, {20., 0.0526316, 0.000442025,
  0.000473797}, {40., 0.025640999999999997, 0.00010649599999999999,
  0.00011289800000000002}, {80., 0.0126582, 0.0000261382, 0.000027567}};

Clear[M1LogPlotData, M1FitData, Mi2aFit, leg1, y];
{M1LogPlotData, M1FitData, Mi2aFit} = getPlotInfo[dataM1, y];
leg1=StringJoin["Methods 2-2-2 fit: ",
                           ToString[StringForm["`1`",Mi2aFit /. y -> Ln[x]]]]

Clear[M2LogPlotData, M2FitData, MiSOFit, leg2, y];
{M2LogPlotData, M2FitData, MiSOFit} = getPlotInfo[dataM2, y];
leg2=StringJoin["Methods 1-2-1 fit: ",
                           ToString[StringForm["`1`",MiSOFit /. y -> Ln[x]]]]

Clear[sym1,sym2];
sym1 = PlotSymbol[Box,2]
sym2 = PlotSymbol[Star,4]

Clear[thePlot];
thePlot :=
         MultipleListPlot[M1LogPlotData,
                          M1FitData,
                          M2LogPlotData,
                          M2FitData,
                          PlotJoined -> {False, True, False, True},
                          SymbolShape -> {sym1, None, sym2, None},
                          Axes -> False,
                          Frame -> True,
                          FrameLabel -> {"Ln(x)", "Ln(y)",
                                         "Fitting Test",
                                         "Test 1"},
                          PlotLegend -> {leg1,
                                          "",
                                          leg2,
                                           ""
                                         },
                           LegendSize -> {1.5, .3},
(*
                           LegendBorder -> 0,
                           LegendLabelSpace->.5,
                           LegendTextOffset -> {{-1,0},{-1,0},{-1,0},{-1,0}},
                           LegendTextOffset -> {3,0},
*)
                           LegendPosition -> {-.8, -1}
                         ];
Show[thePlot]


Sergio


  • Prev by Date: Funny 4.0 vs 4.2 behavior
  • Next by Date: Re: Pasting tables into Excel
  • Previous by thread: Funny 4.0 vs 4.2 behavior
  • Next by thread: Re: Fixing the legend