MathGroup Archive 2001

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

Search the Archive

RE: Lines in a legend are too short

  • To: mathgroup at smc.vnet.net
  • Subject: [mg30538] RE: [mg30514] Lines in a legend are too short
  • From: "David Park" <djmp at earthlink.net>
  • Date: Tue, 28 Aug 2001 04:54:42 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

Rienhold,

There is, to my way of thinking, a minor bug in Legend, in that it does not
utilize the full width of the key box to draw a line. That makes it
difficult to obtain long lines in the keys. The reason is that the internals
have not used a proper AspectRatio for for producing the key box graphics.
There is a fix, and that is to use ShowLegend and abandon MultipleListPlot.
(No one really needs MultipleListPlot since it is easy enough to draw the
lines yourself.)

Needs["Graphics`Legend`"]

This generates a data set which also contains {x,y} pairs instead of just y
values. You really have only seven different names, so I am producing only
seven point sets.

plotlist2 = Table[Table[{i, Sin[j]Random[]}, {i, 1, 30}], {j, 1, 7}];

These are your style definitions. Your line thicknesses will not really be
distinguished, at least on my system, but I will ignore that. (You should
probably use AbsoluteThickness[1] and AbsoluteThickness[2].)

 EPSStylesTemp[n_] :=
  Take[{AbsoluteDashing[{}], AbsoluteDashing[{Dash, Dash}],
      AbsoluteDashing[{Dot}], AbsoluteDashing[{Dash, Dot}],
AbsoluteDashing[{Dash, Dot, Dot}], AbsoluteDashing[{LongDash, Dot}]}, n]

EPSStyles[n_] :=
  Join[({AbsoluteThickness[0.4], #1} &) /@
      EPSStylesTemp[n], ({AbsoluteThickness[0.2], #1} &) /@
      EPSStylesTemp[n], ({Thickness[0.0005], #1} &) /@ EPSStylesTemp[n]]

The following generates a table of your first seven styles and names.

style = Take[EPSStyles[5], 7];
name = {"pareto", "weibull", "gamma", "lognormal", "paretoint",
"weibullint",
      "gammaint", "lognormalint"};

Now we can make the plot using ShowLegend. The only really tricky part was
generating the Table for the key box graphics. We had to add the AspectRatio
option to get the lines to fill the width of the key boxes.

ShowLegend[Graphics[
{Table[Join[style[[i]], {Line[plotlist2[[i]]]}], {i, 7}]},
 Axes -> True,
 AxesLabel -> {"u", "\[Phi](u,1)"},
 TextStyle -> {FontFamily -> "Helvetica", FontSize -> 20},
 ImageSize -> 800],
 {Table[{Graphics[Flatten[{style[[i]], Line[{{0, 0}, {1, 0}}]}],
AspectRatio -> 0.3],
      name[[i]]}, {i, 7}],
  LegendPosition -> {1., -0.5},
  LegendSize -> {1, 1},
  LegendBorderSpace -> 0.1,
  LegendSpacing -> 0,
  LegendTextOffset -> {-1, 0},
  LegendShadow -> None}];

David Park
djmp at earthlink.net
http://home.earthlink.net/~djmp/


> From: Reinhold Kainhofer [mailto:reinhold at kainhofer.com]
To: mathgroup at smc.vnet.net
>
> Hello,
>
> I need to make several plots and list plots with 8 to 15 functions and a
> legend to distinguish the different curves. However, in the legend the
> lines are much too short to be able to distinguish Dashing[{Dash, Dot}]
> from Dashing[{Dash, Dot, Dot}], or even Dashing[{Dash}] from
> Dashing[{Dash, Dot}].  The plots are then automatically exported to eps
> and included in a large LaTeX-Paper.
>
> How can I make the lines in the legend longer? I'd really like to have
> them twice as long as they are now.
>
>
> I found out that the shape of the key boxes resembles the shape of the
> whole legend, e.g. if you have LegendSize->{4,1}, the keybox is also 4
> times wider than with LegendSize->{1,1}, but my LegendSize can't be much
> wider, but the keyboxes (or rather the lines inside) should.
>
> Using the ShowLegend function is not really an option, either, since it
> would take ways too long to manually prepare the whole legend for each
> of the plots.
>
>
> Here is a sample of my plot calls (most options are taken from a global
> variable, so I manually inserted them here to make the whole thing
> shorter):
>
> plotlist=Table[Table[Sin[i]Random[], {30}], {i,1,10}]; (* just random
> data here, this is taken from lengthy calculations*)
>
> EPSStylesTemp[n_]:=
>   Take[{AbsoluteDashing[{}],AbsoluteDashing[{Dash,Dash}],
>       AbsoluteDashing[{Dot}],AbsoluteDashing[{Dash,Dot}],
>
> AbsoluteDashing[{Dash,Dot,Dot}],AbsoluteDashing[{LongDash,Dot}]},n]
>
> EPSStyles[n_]:=
>   Join[({AbsoluteThickness[0.4],#1}&)/@
>       EPSStylesTemp[n],({AbsoluteThickness[0.2],#1}&)/@
>       EPSStylesTemp[n],({Thickness[0.0005],#1}&)/@EPSStylesTemp[n]]
>
> ModelBProbZinsVergleichGraphBconst=MultipleListPlot[plotlist,
>       PlotLegend->{"pareto", "weibull", "gamma", "lognormal",
> "paretoint",
>           "weibullint", "gammaint", "lognormalint"},
>       AxesLabel\[Rule]{"u", "\[Phi](u,1)"},
>       TextStyle\[Rule]{FontFamily\[Rule]"Helvetica",FontSize\[Rule]20},
>       PlotStyle\[Rule]EPSStyles[5],LegendSize\[Rule]{1.2, 1},
>       LegendPosition\[Rule]{0.8,-0.5},
>
> LegendBorderSpace\[Rule]1,LegendSpacing\[Rule]0,LegendShadow\[Rule]None,
>       ImageSize\[Rule]{800,Automatic},
>       PlotJoined\[Rule]True,SymbolShape\[Rule]None
>       ];
>
> Thanks
> Reinhold
> --
> ------------------------------------------------------------------
> DI Reinhold Kainhofer, Graz, Austria
> email: reinhold at kainhofer.com, http://reinhold.kainhofer.com/
>  * Mathematics Department, Technical University of Graz
>  * Theoretical Physics Department, University of Graz
> ------------------------------------------------------------------
>


  • Prev by Date: Transparent evalaution of a notebook
  • Next by Date: Re: file association
  • Previous by thread: Re: Transparent evalaution of a notebook
  • Next by thread: Re: file association