Take the 2-minute tour ×

In this example of a marker from my scatter plot I have set the color to green, and edge color to black, and hatch to "|". For the hatch pattern to show up at all I must set the edgecolor, however when I do, I get a very thick border around the marker. Two questions:

1) How can I to set the size of this border (preferably to 0)?

2) How can I increase the thickness of the hatch lines?


share|improve this question

1 Answer 1

up vote 7 down vote accepted
  1. You just need to set the linewidth to control the marker border thickness.
  2. You can increase the density of hatching, by repeating symbols (in the example below, the '|' is repeated in the R/H pane; note that to obtain NW->SE diagonal lines the symbol must be escaped so needs twice as many characters to really double it -- '\\\\' is density 2 while '||||' is density 4). However, I don't think the thickness of individual lines within hatching is controllable.

See the code example below to produce scatter plots such as these: example hatching control

import matplotlib.pyplot as plt
# generate some data
x = [1,2,3,4,5,8]
y= [i**2 for i in x]
y2= [60-i**2+3*i for i in x]

# plot markers with thick borders
plt.scatter(x,y, s=500, marker='s', edgecolor='black', linewidth='3', facecolor='green', hatch='|')
# compare with no borders, and denser hatch.
plt.scatter(x,y, s=500, marker='s', edgecolor='black', linewidth='0', facecolor='green', hatch='||||')


matplotlib documentation on collections and scatter.

share|improve this answer
You are correct about not being able to change the width of the hatch lines, it is hard coded to 1 (at least in the aggbackend) –  tcaswell Jan 15 '13 at 5:14
and adding the ability to tune the size of the hatches looks like a huge undertaking..... –  tcaswell Jan 15 '13 at 5:40

Your Answer


