Suppose I have an equation plotted as shown:
Plot[(HarmonicNumber[K] - HarmonicNumber[K - r]) (HarmonicNumber[K] -
HarmonicNumber[-1 + r]) /. K -> 10, {r, 0, 11}, Filling -> 0.4]
But what I really want is to have the two (triangular?) filling FLIPPED inside at $x \approx2$ and $x \approx9$. The direction of filling of the upper (semi-circular) part is not important. Preferably it can be Top/outside.
Can anybody help with this flipping?
Thanks
Answer
Another way, copying once more from @J.M.'s answer here: How can I fill under a function in a plot just to right of a specified vertical line?
Using @b.gatessucks definition of f
:
f[r_, k_] = (HarmonicNumber[k] - HarmonicNumber[k - r]) (HarmonicNumber[k] -
HarmonicNumber[-1 + r])
we can do:
With[{ff = f[r, 10]},
Plot[{ConditionalExpression[ff, ff < 0.4],
ConditionalExpression[ff, ff >= 0.4]}, {r, 0, 11},
Filling -> {1 -> Axis, 2 -> Top}, PlotStyle -> ColorData[1, 1],
FillingStyle -> LightRed]]
based on the ideas linked above (using ConditionalExpression
), getting the same result as in @b.gatessucks' answer.
The advantage of this approach is that you can easily modify the fillings (and other options) for the individual parts (but if you use a complicated function, I suspect it could turn slow (due to the added conditions)
Comments
Post a Comment