Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #2963 > unrolled thread
| Started by | DrMajorBob <btreat1@austin.rr.com> |
|---|---|
| First post | 2011-06-05 11:01 +0000 |
| Last post | 2011-06-05 11:01 +0000 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.soft-sys.math.mathematica
Re: ContourPlot ColorFunction Question DrMajorBob <btreat1@austin.rr.com> - 2011-06-05 11:01 +0000
| From | DrMajorBob <btreat1@austin.rr.com> |
|---|---|
| Date | 2011-06-05 11:01 +0000 |
| Subject | Re: ContourPlot ColorFunction Question |
| Message-ID | <isfnmv$bpl$1@smc.vnet.net> |
You have to turn off ColorFunctionScaling.
Here are the two branches plotted separately, including list plots for the
arguments passed to ColorFunction:
{y1, y2} = y /. Solve[y^2 + x == y, y];
{plot, args} =
Reap@Plot[y1, {x, -3, 2}, Frame -> True, Axes -> False,
PlotRange -> {-2, 2}, AspectRatio -> 1,
ColorFunctionScaling -> False,
ColorFunction -> ((Sow@{#1, #2}; If[#2 > 0, Red, Green]) &)];
args = First@args;
Show[plot, ListPlot@args]
{plot, args} =
Reap@Plot[y2, {x, -3, 2}, Frame -> True, Axes -> False,
PlotRange -> {-2, 2}, AspectRatio -> 1,
ColorFunctionScaling -> False,
ColorFunction -> ((Sow@{#1, #2}; If[#2 > 0, Red, Green]) &)];
args = First@args;
Show[plot, ListPlot@args]
Try the same without ColorFunctionScaling -> False, to fully see what's
going on in your original code.
Bobby
On Sat, 04 Jun 2011 05:21:30 -0500, Jody Sorensen <jodo11@yahoo.com> wrote:
> Thanks for the suggestions. It's an improvement, but it still doesn't
> do what I think it should be doing. In this simple example:
>
> Plot[x /. Solve[x^2 + c == x, x], {c, -3, 2}, Frame -> True,
> Axes -> False, PlotRange -> {-2, 2}, AspectRatio -> 1,
> ColorFunction -> (If[#2 > 0, Red, Green] &)]
>
> the whole graph is drawn in red, whereas anything below the axis should
> be green.
>
> Any ideas?
>
> Jody Sorensen
>
> --- On Fri, 6/3/11, Bob Hanlon <hanlonr@cox.net> wrote:
>
> From: Bob Hanlon <hanlonr@cox.net>
> Subject: Re: ContourPlot ColorFunction Question
> To: mathgroup@smc.vnet.net, "Jody Sorensen" <jodo11@yahoo.com>
> Date: Friday, June 3, 2011, 7:26 AM
>
>
> For ContourPlot, there is only one argument for ColorFunction. That
> argument is the contour levels.
>
> ContourPlot[x^2 + c - x, {c, -2, 2}, {x, -2, 2},
> ColorFunction -> (If[# > 0, Red, Green] &),
> Contours -> {0}]
>
> Plot[
> Evaluate[x /. Solve[x^2 + c == x, x]],
> {c, -2, 2},
> Frame -> True,
> Axes -> False,
> PlotRange -> {-2, 2},
> AspectRatio -> 1,
> PlotStyle -> {Green, Red}]
>
> Plot[
> x /. Solve[x^2 + c == x, x],
> {c, -2, 2},
> Frame -> True,
> Axes -> False,
> PlotRange -> {-2, 2},
> AspectRatio -> 1,
> ColorFunction -> (If[2 #2 > 1, Red, Green] &)]
>
>
> Bob Hanlon
>
> ---- Jody Sorensen <jodo11@yahoo.com> wrote:
>
> ==========================
> I'm new to this list and possibly out of my depth, but I'd appreciate
> any help on this issue.
>
> We are trying to plot an implicit function using ContourPlot and have
> the points on the curve colored based on the x and y values (which we
> call c and x) - specifically based on the value of the derivative.
>
> We have tried things like the following without success, even though
> similar commands work with Plot:
> ContourPlot[x^2+c = x, {c, -2, 2}, {x, -2, 2},
> ColorFunction -> (If[2 #1 > 1, Red, Green] &)]
>
> Any suggestions or solutions would be great to hear!
>
> Thanks!
> Jody Sorensen
--
DrMajorBob@yahoo.com
Back to top | Article view | comp.soft-sys.math.mathematica
csiph-web