<p dir="auto">so my plot is,</p>
<ol dir="auto">
<li>drawing regular scatterplot</li>
<li>drawing a network overlay using <code class="notranslate">LineCollection</code> with each edge to be blurred using a trick called <code class="notranslate">agg_filter</code>, which is a hidden feature not listed in the documentation of matplotlib.</li>
</ol>
<p dir="auto">the problem is this plot used to be fine before perhaps in version 1.4, but now after upgrade to 1.5.0 there  is a offset of line collection and scatterplot. the plot is now look like this:</p>
<p dir="auto"><a target="_blank" rel="noopener noreferrer nofollow" href="https://cloud.githubusercontent.com/assets/1881213/12855612/5ee4adfa-cc38-11e5-9efa-f1a82fca2a8e.png"><img src="https://cloud.githubusercontent.com/assets/1881213/12855612/5ee4adfa-cc38-11e5-9efa-f1a82fca2a8e.png" alt="tsne_d_delaunay_plot pdf 1 page preview today at 6 43 26 pm" style="max-width: 100%;"></a></p>
<p dir="auto">the 2D coordinate for scatterplot and line collection should be correct otherwise the old version should not draw it correctly.</p>
<p dir="auto">I found there is no explanation in the official documentation of matplotlib of the <code class="notranslate">Collection. set_agg_filter(filter_func)</code> nor did I found the explanation of what is <code class="notranslate">filter_fun</code> is like and how it should be defined.</p>
<p dir="auto">please tell me whether <code class="notranslate">agg_filter</code> is still working in Matplotlib, many thanks.</p>
<hr>
<p dir="auto">so basically I extract the relevant code to present:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="## for drawing the overlay graph

# this line draw the network
pclt = LineCollection(segments = arwPair, linewidths = sizeArr, linestyles = markerArr)

from agg_filter import AggFilterHelper # a helper class wrapping the Gaussian filter

afh = AggFilterHelper(&quot;Blur&quot;)
pclt.set_agg_filter(afh.get_aggFilter()) # this LineCollection api to set filter
pclt.set_rasterized(True)

axx.add_collection(pclt) # add collection to axes object
# go on drawing"><pre class="notranslate"><code class="notranslate">## for drawing the overlay graph

# this line draw the network
pclt = LineCollection(segments = arwPair, linewidths = sizeArr, linestyles = markerArr)

from agg_filter import AggFilterHelper # a helper class wrapping the Gaussian filter

afh = AggFilterHelper("Blur")
pclt.set_agg_filter(afh.get_aggFilter()) # this LineCollection api to set filter
pclt.set_rasterized(True)

axx.add_collection(pclt) # add collection to axes object
# go on drawing
</code></pre></div>
<h1 dir="auto"></h1>
<p dir="auto">the <code class="notranslate">agg_filter</code> code is found in MailList of matplotlib which is never listed in Documentation but mentioned to be implemented but never actually implemented. so I guess it is a hidden feature, perhaps the code is outdated, but I really need to blur these lines in my plot in the new version of Matplotlib.</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="def smooth1d(x, window_len):
    # copied from http://www.scipy.org/Cookbook/SignalSmooth

    s=np.r_[2*x[0]-x[window_len:1:-1],x,2*x[-1]-x[-1:-window_len:-1]]
    w = np.hanning(window_len)
    y=np.convolve(w/w.sum(),s,mode='same')
    return y[window_len-1:-window_len+1]

def smooth2d(A, sigma=3):

    window_len = max(int(sigma), 3)*2+1
    A1 = np.array([smooth1d(x, window_len) for x in np.asarray(A)])
    A2 = np.transpose(A1)
    A3 = np.array([smooth1d(x, window_len) for x in A2])
    A4 = np.transpose(A3)

    return A4


class BaseFilter(object):
    def prepare_image(self, src_image, dpi, pad):
        ny, nx, depth = src_image.shape
        padded_src = np.zeros([pad*2+ny, pad*2+nx, depth], dtype=&quot;d&quot;)
        padded_src[pad:-pad, pad:-pad,:] = src_image[:,:,:]
        return padded_src

    def get_pad(self, dpi):
        return 0

    def __call__(self, im, dpi):
        pad = self.get_pad(dpi)
        padded_src = self.prepare_image(im, dpi, pad)
        tgt_image = self.process_image(padded_src, dpi)
        return tgt_image, -pad, -pad

class GaussianFilter(BaseFilter):
    &quot;simple gauss filter&quot;
    # Only this one I test and used in the application
    def __init__(self, sigma):
        self.sigma = sigma

    def get_pad(self, dpi):
        return int(self.sigma*3/72.*dpi)


    def process_image(self, padded_src, dpi):
        tgt_image = np.zeros_like(padded_src)
        # original 
        # aa = smooth2d(padded_src[:,:,-1]*self.alpha, self.sigma/72.*dpi)
        # tgt_image[:,:,-1] = aa
        # tgt_image[:,:,:-1] = self.color

        # My Try: hell yeah it works
        for i in range(4):
            aa = smooth2d(padded_src[:,:,i], self.sigma/72.*dpi)
            tgt_image[:,:,i] = aa

        return tgt_image"><pre class="notranslate"><code class="notranslate">def smooth1d(x, window_len):
    # copied from http://www.scipy.org/Cookbook/SignalSmooth

    s=np.r_[2*x[0]-x[window_len:1:-1],x,2*x[-1]-x[-1:-window_len:-1]]
    w = np.hanning(window_len)
    y=np.convolve(w/w.sum(),s,mode='same')
    return y[window_len-1:-window_len+1]

def smooth2d(A, sigma=3):

    window_len = max(int(sigma), 3)*2+1
    A1 = np.array([smooth1d(x, window_len) for x in np.asarray(A)])
    A2 = np.transpose(A1)
    A3 = np.array([smooth1d(x, window_len) for x in A2])
    A4 = np.transpose(A3)

    return A4


class BaseFilter(object):
    def prepare_image(self, src_image, dpi, pad):
        ny, nx, depth = src_image.shape
        padded_src = np.zeros([pad*2+ny, pad*2+nx, depth], dtype="d")
        padded_src[pad:-pad, pad:-pad,:] = src_image[:,:,:]
        return padded_src

    def get_pad(self, dpi):
        return 0

    def __call__(self, im, dpi):
        pad = self.get_pad(dpi)
        padded_src = self.prepare_image(im, dpi, pad)
        tgt_image = self.process_image(padded_src, dpi)
        return tgt_image, -pad, -pad

class GaussianFilter(BaseFilter):
    "simple gauss filter"
    # Only this one I test and used in the application
    def __init__(self, sigma):
        self.sigma = sigma

    def get_pad(self, dpi):
        return int(self.sigma*3/72.*dpi)


    def process_image(self, padded_src, dpi):
        tgt_image = np.zeros_like(padded_src)
        # original 
        # aa = smooth2d(padded_src[:,:,-1]*self.alpha, self.sigma/72.*dpi)
        # tgt_image[:,:,-1] = aa
        # tgt_image[:,:,:-1] = self.color

        # My Try: hell yeah it works
        for i in range(4):
            aa = smooth2d(padded_src[:,:,i], self.sigma/72.*dpi)
            tgt_image[:,:,i] = aa

        return tgt_image
</code></pre></div>
<p dir="auto">Hi,</p>
<p dir="auto">I use the Gaussian Filter example from the <a href="http://matplotlib.org/1.5.1/examples/pylab_examples/demo_agg_filter.html" rel="nofollow">demo_agg_filter.py </a> to place a gaussian drop shadow under continents using basemap. Since I switched to matplotlib 1.5, the shadows are misplaced.</p>
<p dir="auto">The same effect can be seen on the example that is currently online, therefore I do not present my code here.</p>
<p dir="auto"><a target="_blank" rel="noopener noreferrer nofollow" href="https://cloud.githubusercontent.com/assets/10025761/12755658/a353b14e-c9d0-11e5-9fec-397437f46fcd.png"><img src="https://cloud.githubusercontent.com/assets/10025761/12755658/a353b14e-c9d0-11e5-9fec-397437f46fcd.png" alt="demo_agg_filter" style="max-width: 100%;"></a></p>
<p dir="auto">Any suggestions on a quick &amp; dirty solution would be very welcome.<br>
Thank you</p>