We’re rewarding the question askers & reputations are being recalculated! Read more.

# Tag Info

17

You can post-process ParametricPlot output to change Line to FilledCurve: ParametricPlot[{(1 - Cos[2 π s]) Sin[2 π s], Cos[2 π s] (Sin[2 π s] + 1)}, {s, 0, 1}, Axes -> False, PlotStyle -> Black] /. l_Line :> FilledCurve[l] Use the replacement rule l_Line :> {Opacity[1.], FilledCurve[l]} to get We get the same result if we use a rule ...

12

f1h = HoldForm[10 - Sqrt[10^2 - x^2]]; f1 = f1h // ReleaseHold; f2h = HoldForm[5 - Sqrt[5^2 - (x - 5)^2]]; f2 = f2h // ReleaseHold; f3h = HoldForm[5 + Sqrt[5^2 - (x - 5)^2]]; f3 = f3h // ReleaseHold; The x values for the curve intersections are {x1, x2} = x /. Solve[f1 == #, x][] & /@ {f2, f3}; The point coordinates for the curve intersections ...

10

One simple way to visualize complicated regions in mathematica disk1 = Region[Disk[{5, 5}, 5]] disk2 = Region[Disk[{0, 10}, 10]] disk3 = Region[Disk[{10, 0}, 10]] result = Region[ RegionUnion[RegionDifference[disk1, disk3], RegionDifference[disk1, disk2]]]

8

Filling -> {2 -> {1, Directive[{Opacity[0.4], Red}]}}

6

RegionPlot[ x^2 + y^2 < 25 \[And] ((x - 5)^2 + (y + 5)^2 > 100 \[Or] (x + 5)^2 + (y - 5)^2 > 100), {x, -5, 5}, {y, -5, 5}] Or... z[w_] := EuclideanDistance[{x, y}, w {5, -5}]; RegionPlot[ z < 5 \[And] (z > 10 \[Or] z[-1] > 10), {x, -5, 5}, {y, -5, 5}] Or... z[w_] := (a = ({x, y} - 5 {w, -w})).a; RegionPlot[ z < 25 \[...

5

Update: Since the two surfaces are separated by a plane a much easier approach is to fill both surfaces to a plane (say, the z == 1500 plane) between the two and post-process to remove the polygons whose third coordinates are constant at z: z = 1500.; DeleteCases[Normal[ListPlot3D[{cc, bb}, PlotRange -> {500, 3000}, Filling -> {1 -> {z, ...

5

yintervals = {{5.55, 5.58}, {5.61, 5.66}}; data2 = If[IntervalMemberQ[IntervalUnion @@ (Interval /@ yintervals), #[]], #, {#[], Null}] & /@ movavgjoined; ListLinePlot[{movavgjoined, data2}, Filling -> {2 -> Axis}, PlotStyle -> ColorData] xintervals = {{.05, .08}, {.11, .13}}; data3 = If[IntervalMemberQ[IntervalUnion @@ (Interval ...

5

This is what you need: Manipulate[ParametricPlot[ r (1 + 2 Sin[θ]) {Cos[θ], Sin[θ]}, {θ, 0, thmax}, {r, 0, 1}, PlotRange -> {{-2.25, 2.25}, {-0.5, 3.5}}, PerformanceGoal -> "Quality" ], {thmax, 0.01, 2 Pi}]

3

I don't understand the behavior you're seeing, but you can fix it by specifying a list as the FillingStyle: Plot[ { UnitStep[t-0.75]+0.1, 0.5+UnitStep[t-0.5], 1+UnitStep[t-0.25] }, {t,0,1}, Filling->{1->Axis}, FillingStyle->{None,Opacity} ]

2

You can use Chartingget2DPlotRange[thePlot to get the plot range taking into account plot range paddings and use it to specify the rectangle coordinates: gr = Graphics[{Opacity[.1], Blue, Rectangle @@ Transpose[{Chartingget2DPlotRange[thePlot][], {100, 140}}]}]; Show[thePlot, gr]

2

Scaled[] along with AbsoluteTime[] is usable in Rectangle[], which allows us to produce the following plot: DateListPlot[data, GridLines -> {None, {60, 85, 100, 140}}, GridLinesStyle -> Directive[Gray, Thin], Joined -> True, PlotRange -> {Automatic, {80, 180}}, Prolog -> {Opacity[0.2, Blue], ...

2

You may use Epilog with DateObject locations on the date-axis in DateListPlot. Therefore you can get the DateBounds on the date-axis, expand this date range to cover the padded plot range, plot the Rectangle. The expanded date rage by 1 day on both ends can be obtained with DatePlus and Inner by Inner[DatePlus, DateObject /@ DateBounds@data[[All, 1]...

2

Use PlotLegends -> {None, "Sin", "Cos"}

2

l1 = {{px0, py0}, {px5, py5}}; l2 = {{px1, py1}, {px4, py4}}; ListLinePlot[{l1, l2, Prepend[l1, First@l2], Append[l2, Last@l1]}, PlotStyle -> {Directive[Thick, Blue], Directive[Thick, Red], None, None}, Filling -> {3 -> {{4}, LightBlue}}]

2

Try Plot[{Cos[x], Sin[x] + 1/2}, {x, 0, 4 Pi}, Filling -> {2 -> {0, {Automatic, None}}}] Alternatively, Plot[{Cos[x], Sin[x] + 1/2}, {x, 0, 4 Pi}, Filling -> {2 -> {Axis, {Automatic, None}}}] same picture

1

Here's one way: Plot[{(x - 1)^2 - 1/2, 0}, {x, 0, 3}, PlotStyle -> {Blue, None}, Filling -> {2 -> {{1}, {None, LightGray}}}]

1

use the option Exclusions -> None to prevent extra lines for exclusions post-process to remove the vertical segments of line objects Using an example that combines OP's two examples: plot = Plot[ {0.5 UnitStep[t - 0.6] + 0.5 UnitStep[t - 0.8] + 0.1, 0.5 + UnitStep[t - 0.5], 1 + UnitStep[t - 0.25] }, {t, 0, 1}, Filling -> {1 -> Axis, 2 -&...

1

Thank you so much, Carl. But for more complicated step functions, white vertical lines appear. Please see below. Any idea to make the plot look nicer (i.e., completely fill the space between the two functions) will be greatly appreciated. (Note: I an adjust ImageSize to get rid of some white gaps, but my work involves more complicated step functions and ...

1

Given what you have said, the only thing I can think of is to use Mathematica's graphics drawing tools to draw the boundary freehand, extract the boundary points from the modified graphic, and convert it into a polygon. Here is an example. Contrived data and plot for example. SeedRandom; data = RandomInteger[99, {100, 2}]; ListPlot[data, AspectRatio -&...

1

The filling option works only correct if there is a change in sign regarding the difference of the two functions. If the functions are only touching each other then one needs to use two plotting commands, one without filling for the graphs and and another one for the filling itself. E.g. f[x_] := 2 x; g[x_] := x^2/a + a; a = 1/2;

Only top voted, non community-wiki answers of a minimum length are eligible