# Superimpose circles on a contourf plot

Dear all
I am new to matplotlib and python. Up until now i was able to achieve what i
wanted, but now i run into a weird problem. If i superimpose markers onto a
countourf plot they change their size when i zoom into and area off the
plot.
The information i use to plot the positions of the circles is gathered from
ASE (Atomic Simulation Environment ).

I will first try to outline my code without suppling a MWE as this would be
hard to do at the moment:

···

__________________________
.....
from matplotlib import pyplot
from matplotlib.patches import Circle
from ase import Atom
from ase.atoms import Atoms
import pylab

#xarray,yarray are the x and y coordinates ,DATA contains a density at this
point
niso=1#min max value
ncontours=512# number off contours
###ploting starts here

myplot =
pylab.contourf(xarray,yarray,DATA,ncontours,antialiased=False,cmap=my_cmap,vmin=-niso,vmax=niso)

for atom in atoms
color = my_colors_DCLN[atom.number]
struc = pylab.plot(atom.x, atom.y, color='black', linestyle='solid',
facecolor=color,edgecolor='k', linewidth=0.4)#alpha=10)

#ax.axis('equal')
#ax.set_xticks([])
#ax.set_yticks([])
#ax.axis('off')

density_plot
pylab.axis('image')
plt.Figure()

plt.draw()

pylab.show()
_______________________

If i use the normal markers from matplotlib everything works correct. My
DATA that i plot with contourf has the same dimensions as the atoms object.
So i only need to have the xy coordinates of this object.
I can plot the atoms object fine if i do it like this:

____________
import numpy as np
from matplotlib import pyplot
from ase.lattice.surface import fcc111
from ase import Atom
from ase.data.colors import jmol_colors
from matplotlib.patches import Circle
fig, ax = pyplot.subplots()

for atom in atoms:
color = my_colors[atom.number]
circle = Circle((atom.x, atom.y), (radius), facecolor=color,edgecolor='k',
linewidth=0.4)

# Enforce the circles are round (equal x and y scales) and turn off
# tickmarks.
ax.axis('equal')
ax.set_xticks([])
ax.set_yticks([])
ax.axis('off')

fig.savefig('out.png',dpi=300)

pyplot.draw()

pyplot.show()
_____________________

But i do not know what "fig, ax = pyplot.subplots()" does and how i could
incoporate this code in a way that i can supperimpose it to my contourf
plot. The Contourf plot is the important information and i just want to show
the positions of certian atoms ( circles) ontop of this plot.

fabian

--
View this message in context: http://matplotlib.1069221.n5.nabble.com/Superimpose-circles-on-a-contourf-plot-tp48053.html
Sent from the matplotlib - users mailing list archive at Nabble.com.

Fabian,

The `Circle` artist is sized in data-space so it _should_ changes sizes as
you zoom.

If you just want to show markers sized in _screen_ space use `scatter`

sc = ax.scatter([a.x for a in atoms], [a.y for a in atoms],

should do the trick.

Tom

···

On Sat, Aug 5, 2017 at 12:36 PM SilverSurfer <ineedemail at gmx.de> wrote:

Dear all
I am new to matplotlib and python. Up until now i was able to achieve what
i
wanted, but now i run into a weird problem. If i superimpose markers onto a
countourf plot they change their size when i zoom into and area off the
plot.
The information i use to plot the positions of the circles is gathered from
ASE (Atomic Simulation Environment ).

I will first try to outline my code without suppling a MWE as this would be
hard to do at the moment:
__________________________
.....
from matplotlib import pyplot
from matplotlib.patches import Circle
from ase import Atom
from ase.atoms import Atoms
import pylab

#xarray,yarray are the x and y coordinates ,DATA contains a density at this
point
niso=1#min max value
ncontours=512# number off contours
###ploting starts here

myplot =

pylab.contourf(xarray,yarray,DATA,ncontours,antialiased=False,cmap=my_cmap,vmin=-niso,vmax=niso)

for atom in atoms
color = my_colors_DCLN[atom.number]
struc = pylab.plot(atom.x, atom.y, color='black',
linestyle='solid',
facecolor=color,edgecolor='k', linewidth=0.4)#alpha=10)

#ax.axis('equal')
#ax.set_xticks()
#ax.set_yticks()
#ax.axis('off')

density_plot
pylab.axis('image')
plt.Figure()

plt.draw()

pylab.show()
_______________________

If i use the normal markers from matplotlib everything works correct. My
DATA that i plot with contourf has the same dimensions as the atoms
object.
So i only need to have the xy coordinates of this object.
I can plot the atoms object fine if i do it like this:

____________
import numpy as np
from matplotlib import pyplot
from ase.lattice.surface import fcc111
from ase import Atom
from ase.data.colors import jmol_colors
from matplotlib.patches import Circle
fig, ax = pyplot.subplots()

for atom in atoms:
color = my_colors[atom.number]
facecolor=color,edgecolor='k',
linewidth=0.4)

# Enforce the circles are round (equal x and y scales) and turn off
# tickmarks.
ax.axis('equal')
ax.set_xticks()
ax.set_yticks()
ax.axis('off')

fig.savefig('out.png',dpi=300)

pyplot.draw()

pyplot.show()
_____________________

But i do not know what "fig, ax = pyplot.subplots()" does and how i could
incoporate this code in a way that i can supperimpose it to my contourf
plot. The Contourf plot is the important information and i just want to
show
the positions of certian atoms ( circles) ontop of this plot.

fabian

--
View this message in context:
http://matplotlib.1069221.n5.nabble.com/Superimpose-circles-on-a-contourf-plot-tp48053.html
Sent from the matplotlib - users mailing list archive at Nabble.com.
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users at python.org
Matplotlib-users Info Page

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/matplotlib-users/attachments/20170805/d116587c/attachment-0001.html&gt;