Set points outside plot to upper limit
<p>Maybe this question exists already, but I could not find it. </p>

<p>I am making a scatter plot in Python. For illustrative purposes, I don't want to set my axes range such that all points are included - there may be some really high or really low values, and all I care about in those points is that they exist - that is, they need to be in the plot, but not on their actual value - rather, somewhere on the top of the canvas.</p>

<p>I know that in IDL there is a nice short syntax for this: in <code>plot(x,y&lt;value)</code> any value in y greater than <code>value</code> will simply be put at <code>y=value</code>.</p>

<p>I am looking for something similar in Python. Can somebody help me out?</p>

<p>There is no equivalent syntactic sugar in matplotlib. You will have to preprocess your data, e.g.: </p>

<pre><code>import numpy as np
import matplotlib.pyplot as plt

ymin, ymax = 0, 0.9
x, y = np.random.rand(2,1000)
y[y&gt;ymax] = ymax
fig, ax = plt.subplots(1,1)
ax.plot(x, y, 'o', ms=10)
ax.set_ylim(ymin, ymax)
plt.show()
</code></pre>

python matplotlib plot limits