Hot answers tagged

28

An alternative is to use Piecewise as follows Plot[{Sin[x], Piecewise[{{Sin[x], -Pi <= x <= Pi}}, _]}, {x, -2 Pi, 2 Pi}, Filling -> {2 -> {Axis, Yellow}}, PlotStyle -> {Green, Directive[Red, Thick]}] which gives Or Use Show to superimpose two variants (the second one with your choice of the variable bounds -- -Pi and 2Pi in the ...


25

This is a simple little hack that will replace the polygons created by your Filling command with a set of random points. By default I'm scaling the number of random points by the number of points in the polygon, so that the density of points stays relatively constant. dotFillPlot[plot_, ndots_: 5] := plot // Normal // ReplaceAll[ Polygon[a__] :> ...


23

Update 2: Finally ... in version 12.1 you can use the new directives HatchFilling and PatternFilling: Graphics[{EdgeForm[{Thick, Black}], #, blob}, ImageSize -> 300] & /@ {HatchFilling[], Directive[Red, HatchFilling[Pi/2, 2, 10]]} // Row Graphics[{EdgeForm[{Thick, Black}], PatternFilling[#, ImageScaled[1/20]], blob}, ImageSize -> 300] &...


22

I was sure Histogram can be modified to have the hatching style. Little late but what about this! g[{{xmin_, xmax_}, {ymin_, ymax_}}, ___] := Module[{yval, line}, yval = Range[ymin, ymax, 15]; line = Line /@ Transpose@{Most@({xmin, #} & /@ yval),Rest@({xmax, #} & /@ yval)}; {FaceForm[White],Polygon[{{xmin, ymin}, {xmax, ymin}, {xmax, ymax}, {...


19

Something like this? RegionPlot[y < 1/x && y + 0.3 > 1/(x + 0.3) , {x, 0, 3}, {y, 0, 4}, AxesOrigin -> {0, 0}, Frame -> False, Axes -> Automatic, Mesh -> 20, MeshFunctions -> {#1 - #2 &}, BoundaryStyle -> None]~Show~ Plot[1/x, {x, 0, 3}] You can add PlotStyle -> Transparent to the RegionPlot if you don't ...


18

Plot[{0.8333*H + 16.928*H^0.25 - 85, Max[-9 + Max[H - 80, 0], H - 80]}, {H, 0, 700}, PlotStyle -> {Directive[Black, Thick], Black}, Filling -> {1 -> {{2}, {Yellow, Transparent}}}]


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 ...


16

I would do something like: t = RandomVariate[NormalDistribution[0, 1], 10000]; a = Histogram[t, 30, ChartStyle -> White]; b = Histogram[t, 30, ChartElements -> Graphics[{Black, Line[{{0, 0}, {1, 1}}]}]]; Show[a, b]


16

I have distilled a minimal dataset reproducing the problem: data = {{{45.904`, 227.46`}, {46.012`, 222.72`}, {46.076`, 215.51`}, {46.107`, 206.26`}, {46.119`, 196.15`}, {46.119`, 186.97`}, {46.118`, 178.5`}, {46.104`, 168.16`}, {46.079`, 156.43`}}, {{45.912`, 212.72`}, {45.976`, 205.51`}, {46.007`, 196.26`}, {46.019`, 186.15`}, {46.019`, ...


14

Here's happy: Plot[{Sin[9 \[Pi] t/10], 2 Sin[7 \[Pi] t/10]}, {t, 0, 20}, AspectRatio -> 0.2, AxesLabel -> {"weeks", "affection"}, Filling -> {1 -> {Axis, {None, Green}}, 1 -> {{2}, White}}]


14

Here is extended version of PlatoManiac's solution which allows changing of the direction of the hatching and also tuning the distance between hatches: g[step_?NumberQ][{{xmin_, xmax_}, {ymin_, ymax_}}, ___] := Module[{yval, lines, xstart, xend}, yval = Range[ymin, ymax, Abs[step]]; If[step > 0, {xstart, xend} = {xmin, xmax}, {xstart, xend} = {...


13

Alternatively, you can use the +/- option of Filling Plot[{x + 7, 9 - x^2}, {x, 0, 1.5}, Filling -> {1 -> {{2}, {LightBlue, White}}}]


13

im = Binarize@Import["http://i.stack.imgur.com/ZDeYq.jpg"]; Colorize[MorphologicalComponents@im, ColorRules -> {1 -> Red, 2 -> Yellow, 3 -> Blue, 4 -> Green}]


13

Changing the order of lists restore the filling x = {{10.5, 8.5}, {20, 15.3, 11.9, 8.8}, {16.5, 12.5, 9.2, 6.5}}; ListLogPlot[x, Joined -> True, PlotRange -> {{1, 5}, All}, Filling -> {1 -> {{3}, Brown}, 2 -> {{3}, Gray}}]


13

It can be done in several ways, but, I am afraid, none of them with ease similar to setting the colors with an RGBColor command:) 1. Using Show and ParametricPlot with different Mesh* settings Create four different ParametricPlot each with different settings for the Mesh* options and use Show to put them together: ClearAll[meshedParametricPlot] ...


13

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][[1]] & /@ {f2, f3}; The point coordinates for the curve intersections ...


12

You can use the PDF of a HistogramDistribution for the outline. dist = HistogramDistribution[T, 30] p1 = Plot[PDF[dist, t], {t, -4, 4}, PlotStyle -> Black, Exclusions -> None, PlotPoints -> 100]; p2 = Histogram[T, 30, "PDF", ChartElements -> Graphics[{Black, Line[{{0, 0}, {1, 1}}]}]]; Show[p1, p2] The problem here is that it isn't a ...


12

Graphics[{ Yellow, FilledCurve[{BSplineCurve /@ {pts1, pts4, Reverse@pts2, pts3}}], Green, Line[Join[pts1, pts4, Reverse@pts2, pts3]], Red, Point[Join[pts1, pts2, pts3, pts4]] }]


12

Update 2: In version 12.1 you can use the directives PatternFilling or HatchFilling for MeshShading: ParametricPlot[ Evaluate[v f[x] + (1 - v) shiftF[f][x, .2, ar prr]], {x, 0, 1}, {v, 0, 1}, MeshFunctions -> { #4 &}, MeshShading -> {None, HatchFilling[]}, Mesh -> { {{1,Directive[Thick, Opacity[1],Red]},{0, White}}}, AspectRatio ->...


12

Here's an adaptation of m_goldberg's answer that uses a single plot for his example: Plot[ { c2[x], ConditionalExpression[c1[x], x<.7], ConditionalExpression[c1[x], x>.7] }, {x, 0,1}, PlotStyle->{Red, Blue, Blue}, Filling->{2->{Axis, LightBlue}, 1->{{3}, LightBlue}} ]


11

Here is another method that uses the more general gradient background construction I posted as an answer to "How can I set different opacity values for the background of a ListPlot". This answer is rather late, but I thought it's a good example of how else to use the simple option Prolog -> gradientBackground to create a gradient background: ...


11

This is what I've ended up doing. data1 = exPDMIABSA[[1]]; data2 = exPDMIAwater[[1]]; Show[ListLinePlot[{data1, data2}, PlotStyle -> {Directive[Dashed, Black], Black}, Filling -> {2 -> Axis}, FillingStyle -> Gray], RegionPlot[ y < Interpolation[data1, InterpolationOrder -> 1][x] && y > 0, {x, 300, 375}, {y, 0, ...


11

Since the filling in the original DateListPlot is a Polygon, you can post-process it to add a texture. The tricky bit is getting the scaling correct - I rescale the polygon coordinates relative to the PlotRange (so the texture coordinates run from 0 to 1 across the width and height of the plot) and crop the image to the correct aspect ratio: imagefill[plot_,...


11

MeshFunctions are useful here. Plot[{Sin[x]^2, Sin[10 x]^2}, {x, 0, 5}, PlotStyle -> {Red, Blue}, Mesh -> {{0}}, MeshFunctions -> {Sin[#]^2 - Sin[10 #]^2 &}, MeshStyle -> Green]


10

I made an answer by J.M. and Murta into a function: IntegralPlot[f_, {x_, L_, U_}, {l_, u_}, opts : OptionsPattern[]] := Module[{col = ColorData[1, 1]}, Plot[{ConditionalExpression[f, x > l && x < u], f}, {x, L, U}, Prolog -> {{col, Line[{{l, 0}, {l, f /. {x -> l}}}]}, {col, Line[{{u, 0}, {u, f /. {x -> u}}}]}}, ...


10

With axis-constrained locators: DynamicModule[{pts = {{0, 0}, {Pi, 0}}}, LocatorPane[Dynamic[pts, (pts[[1]] = {#[[1, 1]], 0}; pts[[2]] = {#[[2, 1]], 0}) &], Dynamic[ Framed@Show@ {Plot[Sin@x, {x, 0, 2 Pi}], Plot[Sin@x, {x, pts[[1, 1]], pts[[2, 1]]}, Filling -> Axis] } ]]] Edit This is the full code, with the ...


10

Reverse points around y=x axis (flip y-x coordintaes) to get correct filling But now you plot is flipped - so flip again around y=x with GeometricTransformation Here it is: pl = ListLinePlot[(Reverse /@ data[[All, {#, 3}]]) & /@ {1, 2}, Filling -> {1 -> {2}}]; Graphics[GeometricTransformation[pl[[1, 2]], ReflectionTransform[{-1, 1}]], Frame ->...


10

This is my second answer, which is a rather different (and simpler) idea than my first one, namely, add a polygon that shades from a Line in the plot to a vertical axis at x = x0. fillVertical[plot_, x0_: 0.] := plot /. Line[p_] :> {{Opacity[0.2], Polygon[p ~Join~ {{N @ x0, p[[-1, 2]]}, {N @ x0, p[[1, 2]]}}]}, Line[p]} The shading automatically ...


10

Note that your list spec in the Filling suggestion is the other way around. You mean Filling->{1->{2}} With this style you can incorporate the filling style directly there and therefore, what you want can be written down as ranges = {.01, .05, .25, .5, .75, .95, .99}; col =col = RGBColor[.6, .6, 1]; Manipulate[ Plot[Evaluate@ Quantile[ ...


10

Perhaps a "quick" appoach (in addition to looking at hyperlink of @rm-rf): msp[f_, {xmin_, xmax_}, {ymin_, ymax_}, mfun_, mnum_, swatchsize_, opts : OptionsPattern[]] := Module[{pm, swl}, pm = RegionPlot[x < 1, {x, 0, 1}, {y, 0, 1}, MeshFunctions -> mfun, Mesh -> IntegerPart@(mnum/(swatchsize/10)), Frame -> False, PlotRange -> {...


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