Take the 2-minute tour ×

I am trying to draw something similar: enter image description here

The main idea is to draw ellipses with different color in some specific range, for example from [-6, 6].

I have understood that plt.contour function can be used. But I do not understand how to generate lines.

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

I personally wouldn't do this with contour as you then need to add information about the elevation which I don't think you want?

matplotlib has Ellipse which is a subclass of Artist. The following example adds a single ellipse to a plot.

import matplotlib as mpl
ellipse = mpl.patches.Ellipse(xy=(0, 0), width=2.0, height=1.0)
fig, ax = plt.subplots()

ax.set_xlim(-2, 2)
ax.set_ylim(-2, 2)

enter image description here

You then need to research how to get the effect you are looking for, I would have a read of the docs in general making things transparent is done through alpha.

share|improve this answer
add comment

Your Answer


