Skip to main content
added 1 character in body
Source Link
Karsten7
  • 27.6k
  • 5
  • 74
  • 135

An alternative is to use RegionFunction.

Just to revisit this question, I've found that Karsen 7.'s solution is not always working for me (at least on version 9). Suppose we want to show both a Histogram and a SmoothHistogram. So we try:

Show[Histogram[data, Automatic, "PDF"], SmoothHistogram[data, Filling -> Bottom]]

And we get the problem as expected.

1

Now we try the PlotRangePadding trick:

Show[Histogram[data, Automatic, "PDF"], SmoothHistogram[data, Filling -> Bottom],
 PlotRange -> {{0, 10}, Automatic}, PlotRangePadding -> 0]

and it doesn't help:

2

However, using a RegionFunction on the SmoothHistogram:

Show[Histogram[data, Automatic, "PDF"], SmoothHistogram[data, Filling -> Bottom,
  RegionFunction -> Function[{x, y}, 0 <= x <= 10]]10]]]

3

An alternative is to use RegionFunction.

Just to revisit this question, I've found that Karsen 7.'s solution is not always working for me (at least on version 9). Suppose we want to show both a Histogram and a SmoothHistogram. So we try:

Show[Histogram[data, Automatic, "PDF"], SmoothHistogram[data, Filling -> Bottom]]

And we get the problem as expected.

1

Now we try the PlotRangePadding trick:

Show[Histogram[data, Automatic, "PDF"], SmoothHistogram[data, Filling -> Bottom],
 PlotRange -> {{0, 10}, Automatic}, PlotRangePadding -> 0]

and it doesn't help:

2

However, using a RegionFunction on the SmoothHistogram:

Show[Histogram[data, Automatic, "PDF"], SmoothHistogram[data, Filling -> Bottom,
  RegionFunction -> Function[{x, y}, 0 <= x <= 10]]

3

An alternative is to use RegionFunction.

Just to revisit this question, I've found that Karsen 7.'s solution is not always working for me (at least on version 9). Suppose we want to show both a Histogram and a SmoothHistogram. So we try:

Show[Histogram[data, Automatic, "PDF"], SmoothHistogram[data, Filling -> Bottom]]

And we get the problem as expected.

1

Now we try the PlotRangePadding trick:

Show[Histogram[data, Automatic, "PDF"], SmoothHistogram[data, Filling -> Bottom],
 PlotRange -> {{0, 10}, Automatic}, PlotRangePadding -> 0]

and it doesn't help:

2

However, using a RegionFunction on the SmoothHistogram:

Show[Histogram[data, Automatic, "PDF"], SmoothHistogram[data, Filling -> Bottom,
  RegionFunction -> Function[{x, y}, 0 <= x <= 10]]]

3

Source Link
wxffles
  • 14.3k
  • 1
  • 43
  • 75

An alternative is to use RegionFunction.

Just to revisit this question, I've found that Karsen 7.'s solution is not always working for me (at least on version 9). Suppose we want to show both a Histogram and a SmoothHistogram. So we try:

Show[Histogram[data, Automatic, "PDF"], SmoothHistogram[data, Filling -> Bottom]]

And we get the problem as expected.

1

Now we try the PlotRangePadding trick:

Show[Histogram[data, Automatic, "PDF"], SmoothHistogram[data, Filling -> Bottom],
 PlotRange -> {{0, 10}, Automatic}, PlotRangePadding -> 0]

and it doesn't help:

2

However, using a RegionFunction on the SmoothHistogram:

Show[Histogram[data, Automatic, "PDF"], SmoothHistogram[data, Filling -> Bottom,
  RegionFunction -> Function[{x, y}, 0 <= x <= 10]]

3