MathGroup Archive 1996

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

Search the Archive

Re: Q: Problems with package legend.m

  • To: mathgroup at
  • Subject: [mg3449] Re: Q: Problems with package legend.m
  • From: ianc (Ian Collier)
  • Date: Fri, 8 Mar 1996 01:30:38 -0500
  • Organization: Wolfram Research, Inc.
  • Sender: owner-wri-mathgroup at

In article <4hm0es$m6m at>, "Alexander K White"
<whiteale at> wrote:

> Hello,
>     I am using Mathematica 2.2 for NeXT and I am having problems with the
> package Legend.m which is included in the graphics package.
>  I created a plot, pl2, which contains the graphs of two functions on the same
> plot.  When I use
>  In [] = ShowLegend[pl2,{{RGBColor[0, 1, 1],
>         "LTBD"},{RGBColor[1,0,1],"hiho"}}]
> I get the error
> Out[]= Graphics::gprim:
>    Unknown Graphics primitive Legend[{RGBColor[0, 1, 1], LTBD}, <<2>>]
>      encountered.
> I looked inside the function ShowLegend and it calls another function Legend.
> When I use
> In[] :=  Show at Graphics@Legend[{{RGBColor[0, 1, 1],
>         "LTBD"},{RGBColor[1,0,1],"hiho"}}]
> Out[]=  picture of the legend.
> It seems that the ShowLegend calls Legend incorrectly.  Has anyone else
> experienced this?  This seems to be a major bug.
> I changed a few lines in ShowLegend from:
>         ls = MapAt[Append[#,LegendPosition->ap]&,ls,1];
>         ls = Apply[Legend,ls,{1}];
> to:
>         ls = Append[ls,LegendPosition->ap];
>         ls = Legend@(Sequence@@ls);
> And it appears to work.  I wonder if I am not using the function correctly, or
> if there are other bugs in the package.
> If this topic has been covered before, I apologize.  Please send an address
> where I can receive information.

You just need to add a another set of braces around the legend 

The reason is that ShowLegend accepts multiple legend specifications, 
each of which has its own options; the extra set of braces is used 
to group the options with each specification.

    pl2 = Plot[ {Sin[x]/x, Cos[x]},{x,-10,10}]

    Needs[ "Graphics`Legend`" ]
    ShowLegend[pl2,{{{RGBColor[0, 1, 1],


Once you have loaded the Legend package you can also simply
use PlotLegend as an option to Plot:

    Plot[{Sin[x]/x, Cos[x]}, {x, -10,10},
       PlotLegend -> {"LTBD", "hiho"},
       PlotStyle -> {RGBColor[0,1,1], RGBColor[1,0,1]}]

The place where you can receive information about this 
and other technical questions about Mathematica and
the standard Mathematica packages is Wolfram Research
Technical Support (support at

I hope this helps.


Ian Collier
Wolfram Research, Inc.
tel:(217) 398-0700   fax:(217) 398-0747    ianc at
Wolfram Research Home Page:


  • Prev by Date: Re: compiling
  • Next by Date: Re: Inverse of Large Matrices
  • Previous by thread: Link to C, Fortran, or MatLab in Win 95
  • Next by thread: Re: Inverse of Large Matrices