I want to plot a spiral with varying width. When I plot the figure, however, there are peculiar dots that appear above and below the line (where the red arrows are pointing in the image below). They seem to be occurring between points, where the line should just be straight. They do not occur in any obvious pattern either.
I have run the following code, but I can't figure out what is causing these weird distortions. Any ideas?
import numpy as np
import matplotlib as mpl
import matplotlib.pyplot as plt
mpl.use('Agg')
plt.ioff()
MY_DPI = 300
BKGD_COLOUR = 'w'
FILL_COLOUR= 'k'
a = 0
b = 0.5
maxRadius = 100
maxTheta = (maxRadius - a) / b
t = np.arange(0, maxTheta, 0.1)
r = a + b *t
fig = plt.figure(figsize=(10,10), dpi=MY_DPI)
ax = fig.add_axes([0,0,1,1], polar=True)
ax.set_rlim(0, maxRadius)
ax.axis('off')
r_bot = np.array(r) - np.random.uniform(0.1, 0.5, len(r))
r_top = np.array(r) + np.random.uniform(0.1, 0.5, len(r))
ax.fill_between(t, r_bot, r_top, color=FILL_COLOUR, lw=0)
plt.savefig('spiraliser.jpg', facecolor=BKGD_COLOUR, bbox_inches='tight', dpi=MY_DPI)
plt.close()
Changing color=FILL_COLOUR
to facecolor=FILL_COLOUR
seems to have solved this issue. Apparently facecolor
does not set the colour of the edge.