kilojoules
kilojoules

Reputation: 10083

pylab.scatter creates colorbar with weird white lines

When I run this on OSX Yosemite the colorbar generted has weird white lines (see image below). Is there any way I can generate a colorbar without these ugly lines?

import pylab
import numpy
x = numpy.random.random(50)
y = numpy.random.random(50)
s = pylab.scatter(x,y,c=y)
pylab.colorbar(s)
pylab.savefig('/Users/kilojoules/plot.pdf')

full graph

see the lines?

Upvotes: 1

Views: 286

Answers (1)

hitzg
hitzg

Reputation: 12701

This is a known issue (not of matplotlib, but many pdf viewers) which is also described in the documentation of the colorbar function (along with a work-around):

# create the colorbar
cbar = pylab.colorbar(s)

# set the color of the lines
cbar.solids.set_edgecolor("face")

This should fix it.

For further reading: the relevant issue on github

Upvotes: 2

Related Questions