Matplotlib lines do not join smoothly, Python
Question: I am using matplotlib to draw the outline of a cylindrical body, however the
lines do not want to join up smoothly, as seen in the range x[40,60].

![enter image description here](http://i.stack.imgur.com/MWsP3.png)

It is really subtle in this image I know, but it is unfortunately not
acceptable for my purposes. I hope it is visible for you to see.

Using more data points does not seem to make a difference.

Is there a way to get curved lines to join up more smoothly in matplotlib?

Original code:

    
    
    import numpy as np
    import matplotlib.pylab as plt
    
    length = 100.
    a = 40
    b = 20
    n = 2.
    alpha = np.radians(25.)
    d = 18.
    
    x_nose = np.linspace(0,a,1000)
    r_nose = (0.5*d*(1 - ((x_nose-a)/a)**2)**(1/n))
    
    x_mid = np.linspace(x_nose[-1],a+b,2)
    r_mid = np.array([r_nose[-1],r_nose[-1]])
    
    x_tail = np.linspace(x_mid[-1],length,1000)
    l_tail = length-a-b
    r_tail = (0.5*d - ((3*d)/(2*l_tail**2) - np.tan(alpha)/l_tail)*(x_tail-a-b)**2 + (d/l_tail**3 - np.tan(alpha)/l_tail**2)*(x_tail-a-b)**3)
    
    fig = plt.figure()
    plt.plot(x_nose,r_nose,'k',linewidth=2,antialiased=True)
    plt.plot(x_mid,r_mid,'k',linewidth=2,antialiased=True)
    plt.plot(x_tail,r_tail,'k',linewidth=2,antialiased=True)
    plt.axis('equal')
    plt.show()
    

You can see the effect more easily when zoomed in:

![enter image description here](http://i.stack.imgur.com/YYuxO.png)


Answer: I'm not sure why this is happening, but you may be able to mitigate by
constructing a single `x` and `r` array with the full line to draw.

    
    
    x = np.append(x_nose, x_mid)
    x = np.append(x, x_tail )
    r = np.append(r_nose, r_mid)
    r = np.append(r, r_tail )
    
    plt.plot(x,r,'k',linewidth=2,antialiased=True)
    

This obviously prevents you altering line styles of individual elements, but
it looks like you don't want to do that. This works for me:

![Plot showing the effect of appending the x and r
arrays](http://i.stack.imgur.com/udb4c.png)

