       RE: Changing style in Plot

• To: mathgroup at smc.vnet.net
• Subject: [mg39518] RE: [mg39499] Changing style in Plot
• From: "David Park" <djmp at earthlink.net>
• Date: Fri, 21 Feb 2003 04:07:44 -0500 (EST)
• Sender: owner-wri-mathgroup at wolfram.com

```Thomas,

I believe you will have to plot your line in segments and then combine them.
Your line was so thick that I plotted it in gray and used the AxesFront
option from FilledPlot to prevent masking of the axes.

Needs["Graphics`FilledPlot`"]
Needs["Graphics`Colors`"]

Block[{\$DisplayFunction = Identity},
g1 = Plot[3x - 1, {x, 0, 4}, PlotStyle -> {Gray, Thickness[0.1]},
PlotRange -> {{-2, 12}, {-10, 50}},
ImageSize -> 500,
Axes -> True
];
g2 = Plot[3x - 1, {x, 4, 10}, PlotStyle -> {Gray, Thickness[0.2]}]];
Show[g1, g2, AxesFront -> True];

But here is a trick that might be useful. ParametricPlot3D allows a curve to
be drawn with style directives as the 4th argument of the parametrization.
So, make a 3D plot, extract the graphic primitives and project them to 2D.
In the following both the thickness and Hue of the line are varied in a
continuous fashion.

g1 = First[
ParametricPlot3D[{x, 3x - 1, 0, {Thickness[0.005x], Hue[x/10]}}, {x,
0, 10}, DisplayFunction -> Identity]] /. {x_?NumberQ,
y_?NumberQ,
z_?NumberQ} -> {x, y};

Show[Graphics[{g1}],
PlotRange -> {{-2, 12}, {-10, 50}},
AxesFront -> True,
ImageSize -> 500,
Axes -> True];

David Park

From: Thomas Manz [mailto:thomas.manz at physik.uni-regensburg.de]
To: mathgroup at smc.vnet.net

Hello,

I´d like to change the style of a plot in dependency on the x-value. I think
this WRONG example shows, what I want:

Plot[3x-1, {x,0,10}, PlotStyle->If[x>4,Thickness[0.1],Thickness[0.2]]]

Does anyone have an idea how to do this??

Thanks a lot
Thomas

```

• Prev by Date: Re: series expansions in two variables problem
• Next by Date: Re: Solving Alphametics with Mathematica
• Previous by thread: Re: Changing style in Plot
• Next by thread: series expansions in two variables problem