Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #2269
| From | "Kevin J. McCann" <Kevin.McCann@umbc.edu> |
|---|---|
| Newsgroups | comp.soft-sys.math.mathematica |
| Subject | Re: A Request to Fix ShowLegend |
| Date | 2011-05-10 12:32 +0000 |
| Organization | Steven M. Christensen and Associates, Inc and MathTensor, Inc. |
| Message-ID | <iqbb8t$jmt$1@smc.vnet.net> (permalink) |
| References | <iq3ari$fm1$1@smc.vnet.net> <iq8f6n$5vm$1@smc.vnet.net> |
Nice. You are way ahead of me on this stuff.
Kevin
On 5/9/2011 6:21 AM, Peter Breitfeld wrote:
> "Kevin J. McCann" wrote:
>
>> 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
>>
>
> This might be a starter:
>
> Options[plot3DWithLegend] = Union[Options[Plot3D], {cf -> "Rainbow"}];
>
> plot3DWithLegend[f_, {x_, xmin_, xmax_}, {y_, ymin_, ymax_},
> opt : OptionsPattern[]] :=
> Module[{min, max, cfOpt, plotOpt},
> cfOpt = OptionValue[cf];
> plotOpt = Evaluate[FilterRules[{opt}, Options[Plot3D]]];
> min = NMinValue[{f, xmin<= x<= xmax, ymin<= y<= ymax}, {x, y}];
> max = NMaxValue[{f, ymin<= y<= xmax, ymin<= y<= ymax}, {x, y}];
> ShowLegend[
> Plot3D[f, {x, xmin, xmax}, {y, ymin, ymax}, ColorFunction -> cfOpt,
> Evaluate@plotOpt],
> {ColorData[cfOpt][1 - #]&, 10, ToString@max, ToString@min,
> LegendPosition -> {1.1, -0.4}}
> ]
> ]
>
> plot3DWithLegend[2 Sin[x y], {x, 0, \[Pi]}, {y, 0, \[Pi]},
> Background -> LightGreen, cf -> "Pastel"]
>
Back to comp.soft-sys.math.mathematica | Previous | Next — Previous in thread | Find similar | Unroll thread
A Request to Fix ShowLegend "Kevin J. McCann" <Kevin.McCann@umbc.edu> - 2011-05-07 11:36 +0000
Re: A Request to Fix ShowLegend Peter Breitfeld <phbrf@t-online.de> - 2011-05-09 10:21 +0000
Re: A Request to Fix ShowLegend "Kevin J. McCann" <Kevin.McCann@umbc.edu> - 2011-05-10 12:32 +0000
csiph-web