The effect of magnetic fields on convection at the surfaces of cool st
ars can be explored by comparing the results of detailed numerical exp
eriments with high-resolution solar observations. We have investigated
non-linear three-dimensional magnetoconvection in a fully compressibl
e perfect gas. In this paper we study the effect of an imposed magneti
c field on the pattern of convection in a deep stratified layer. When
the field is strong enough to dominate the motion we find steady conve
ction with rising plumes on a deformed hexagonal lattice, and a magnet
ic network at the upper boundary. This gives way to spatially modulate
d oscillations for weaker fields. As the field strength is further red
uced the oscillations become more violent and irregular, and their hor
izontal scale increases. Magnetic flux moves rapidly along the network
that encloses the ephemeral plumes; when the imposed field is relativ
ely weak, intense fields appear at junctions in the network, where the
magnetic pressure is comparable to the gas pressure and an order of m
agnitude greater than the dynamic pressure. This behaviour is related
to convection in sunspots and plages and to the structure of intergran
ular magnetic fields on the Sun.