MathGroup Archive 2011

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

Search the Archive

A Request to Fix ShowLegend

  • To: mathgroup at smc.vnet.net
  • Subject: [mg118706] A Request to Fix ShowLegend
  • From: "Kevin J. McCann" <Kevin.McCann at umbc.edu>
  • Date: Sat, 7 May 2011 07:36:32 -0400 (EDT)

Sorry for the rant, but here it is:

This has come up before in the ng, but today it is really irritating me; 
so, I thought I would bring it up again. The issue is the putting of 
legends on plots. In particular colorbars. Here is the example from the 
ShowLegend documentation:

ShowLegend[
  Plot3D[Sin[x y], {x, 0, \[Pi]}, {y, 0, \[Pi]},
   ColorFunction -> "Rainbow"], {ColorData["Rainbow"][1 - #1] &, 10,
   " 1", "-1", LegendPosition -> {1.1, -.4}}]

And, yes, it works just fine. However if you change the plotted function 
to 2 Sin[x y], you get EXACTLY the same colorbar. This is nonsense. So, 
in order to use ShowLegend, you have to do three things:

1) Do the Plot3D, or whatever the plot with its own ColorFunction;
2) As one of the arguments to ShowLegend, you define the Colorfunction, 
but it is Reversed (how awkward is that?);
3) You have to know AND specify the limits of the colorbar, i.e. these 
are just symbols and have absolutely nothing to do with the function 
values that are plotted, and these are also reversed from the "normal" 
way, i.e. "1","-1" instead of "-1","1", which is what I would have 
guessed. As I said, you could put anything for these limits.

This makes this part of the Legend suite useless or, at best, 
extraordinarily cumbersome to use.

I just wonder what the folks at Wolfram are thinking when they put out 
the software this way with two really easy ways to mess it up, i.e. (2) 
and (3) above.

Now, I know that there is a package out there, ColorbarPlots, and it 
works reasonably well and certainly makes my life easier; however it has 
some limitations, in particular for the ColorFunction choices. Shouldn't 
something like this be a part of Mathematica? Is there a good reason for 
leaving ShowLegend the way it is? I am just wondering about the logic 
here, and I am willing to admit that I might have missed something; 
however, if there isn't a good reason, maybe it is time to fix it.

Kevin


  • Prev by Date: Undocumented function to determine em-width of font in points (or mm)
  • Next by Date: Re: anything faster than Solve[] for solving sets of polynomial equations symbolically?
  • Previous by thread: Undocumented function to determine em-width of font in points (or mm)
  • Next by thread: Re: bug... GraphicsGrid ItemAspectRatio Spacings