MathGroup Archive 2006

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

Search the Archive

RE: line thickness 2D plot legend

  • To: mathgroup at smc.vnet.net
  • Subject: [mg68040] RE: [mg67974] line thickness 2D plot legend
  • From: "David Annetts" <davidannetts at aapt.net.au>
  • Date: Fri, 21 Jul 2006 05:37:33 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

Hi Julia,
> 
> For a 2D Plot in Mathematica: How can I modify the line 
> thickness in the legend of a 2D Plot. The lines in the plot 
> can be made thickner through PlotStyle->{Thickness[0.08]}, 
> but this does not influence the legend. How can I change the 
> line thickness there?

You can control line thickness settings in a legend by making your own.  For
example, whereas you might have something like

Plot[{Sin[x], Cos[x]}, {x, -Pi, Pi}, PlotStyle -> {Red, Blue},
    LegendLabel -> StyleForm["Legend", FontSlant -> "Oblique", FontWeight ->
"Bold", FontSize -> 12], 
	PlotLegend -> {"Sin[x]", "Cos[x]"}, LegendShadow -> None, 
      LegendSize -> {.5, .20}, LegendPosition -> {-.8, .35}
	];

You'll need to construct a legend manually like

lin = Graphics[{ #, Thickness[.2], Line[{{-1, 0}, {1, 0}}]}] & /@ {Red,
Blue};
txt = {"Sin[x]", "Cos[x]"};
lgd = {Transpose[{lin, txt}],
      LegendLabel -> StyleForm["Legend", FontSlant -> "Oblique", FontWeight
->"Bold", FontSize -> 12],
      LegendShadow -> None,
      LegendSize -> {.5, .20}, 
      LegendPosition -> {-.8, .35}
      };

You can use this with the ShowLegend[] command

	plt = Plot[{Sin[x], Cos[x]}, {x, -Pi, Pi}, 
		PlotStyle -> {Red, Blue}, DisplayFunction -> Identity
		];
	ShowLegend[plt, lgd];

The critical thing is the graphics primitives in the legend line (lin = in
the example above).

Regards,

Dave.


  • Prev by Date: Re: MapThread and If
  • Next by Date: Re: orthogonal functions from normalized standing wave functions
  • Previous by thread: RE: line thickness 2D plot legend
  • Next by thread: Re: line thickness 2D plot legend