Does anyone know a way to bring a scatter plot to the foreground in matplotlib? I have to display the scatter plotting on top of the contour, but by default it is plotted underneath...
Thanks in advance!
Does anyone know a way to bring a scatter plot to the foreground in matplotlib? I have to display the scatter plotting on top of the contour, but by default it is plotted underneath...
Thanks in advance!
You can manually choose in which order the different plots are to be displayed with the
zorder
parameter of e.g. thescatter
method.To demonstrate, see the code below, where the scatter plot in the left subplot has
zorder=1
and in the right subplot it haszorder=-1
. The object with the highestzorder
is placed on top. This means that the scatter will be placed on top of the contour in the first subplot, while it is placed underneath in the second subplot.