Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #2177 > unrolled thread
| Started by | "Kevin J. McCann" <Kevin.McCann@umbc.edu> |
|---|---|
| First post | 2011-05-07 11:36 +0000 |
| Last post | 2011-05-10 12:32 +0000 |
| Articles | 3 — 2 participants |
Back to article view | Back to comp.soft-sys.math.mathematica
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
| From | "Kevin J. McCann" <Kevin.McCann@umbc.edu> |
|---|---|
| Date | 2011-05-07 11:36 +0000 |
| Subject | A Request to Fix ShowLegend |
| Message-ID | <iq3ari$fm1$1@smc.vnet.net> |
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
[toc] | [next] | [standalone]
| From | Peter Breitfeld <phbrf@t-online.de> |
|---|---|
| Date | 2011-05-09 10:21 +0000 |
| Message-ID | <iq8f6n$5vm$1@smc.vnet.net> |
| In reply to | #2177 |
"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"]
--
_________________________________________________________________
Peter Breitfeld, Bad Saulgau, Germany -- http://www.pBreitfeld.de
[toc] | [prev] | [next] | [standalone]
| From | "Kevin J. McCann" <Kevin.McCann@umbc.edu> |
|---|---|
| Date | 2011-05-10 12:32 +0000 |
| Message-ID | <iqbb8t$jmt$1@smc.vnet.net> |
| In reply to | #2232 |
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"]
>
[toc] | [prev] | [standalone]
Back to top | Article view | comp.soft-sys.math.mathematica
csiph-web