{"action":"created","issue":{"url":"https://api.github.com/repos/matplotlib/matplotlib/issues/5969","repository_url":"https://api.github.com/repos/matplotlib/matplotlib","labels_url":"https://api.github.com/repos/matplotlib/matplotlib/issues/5969/labels{/name}","comments_url":"https://api.github.com/repos/matplotlib/matplotlib/issues/5969/comments","events_url":"https://api.github.com/repos/matplotlib/matplotlib/issues/5969/events","html_url":"https://github.com/matplotlib/matplotlib/issues/5969","id":131724063,"number":5969,"title":"urgent bug after 1.5.0: offset of LineCollection when apply agg_filter","user":{"login":"Hualin","id":1881213,"avatar_url":"https://avatars.githubusercontent.com/u/1881213?v=3","gravatar_id":"","url":"https://api.github.com/users/Hualin","html_url":"https://github.com/Hualin","followers_url":"https://api.github.com/users/Hualin/followers","following_url":"https://api.github.com/users/Hualin/following{/other_user}","gists_url":"https://api.github.com/users/Hualin/gists{/gist_id}","starred_url":"https://api.github.com/users/Hualin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Hualin/subscriptions","organizations_url":"https://api.github.com/users/Hualin/orgs","repos_url":"https://api.github.com/users/Hualin/repos","events_url":"https://api.github.com/users/Hualin/events{/privacy}","received_events_url":"https://api.github.com/users/Hualin/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/matplotlib/matplotlib/milestones/22","html_url":"https://github.com/matplotlib/matplotlib/milestones/1.5.2%20(Critical%20bug%20fix%20release)","labels_url":"https://api.github.com/repos/matplotlib/matplotlib/milestones/22/labels","id":1495785,"number":22,"title":"1.5.2 (Critical bug fix release)","description":"Speculative milestone is case we need to do a 1.5.2 release. ","creator":{"login":"tacaswell","id":199813,"avatar_url":"https://avatars.githubusercontent.com/u/199813?v=3","gravatar_id":"","url":"https://api.github.com/users/tacaswell","html_url":"https://github.com/tacaswell","followers_url":"https://api.github.com/users/tacaswell/followers","following_url":"https://api.github.com/users/tacaswell/following{/other_user}","gists_url":"https://api.github.com/users/tacaswell/gists{/gist_id}","starred_url":"https://api.github.com/users/tacaswell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tacaswell/subscriptions","organizations_url":"https://api.github.com/users/tacaswell/orgs","repos_url":"https://api.github.com/users/tacaswell/repos","events_url":"https://api.github.com/users/tacaswell/events{/privacy}","received_events_url":"https://api.github.com/users/tacaswell/received_events","type":"User","site_admin":false},"open_issues":19,"closed_issues":30,"state":"open","created_at":"2016-01-10T22:41:29Z","updated_at":"2016-02-05T19:49:41Z","due_on":null,"closed_at":null},"comments":4,"created_at":"2016-02-05T18:51:18Z","updated_at":"2016-02-05T20:03:54Z","closed_at":null,"body":"so my plot is,\r\n\r\n1. drawing regular scatterplot\r\n2. drawing a network overlay using `LineCollection` with each edge to be blurred using a trick called `agg_filter`, which is a hidden feature not listed in the documentation of matplotlib.\r\n\r\nthe 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:\r\n\r\n![tsne_d_delaunay_plot pdf 1 page preview today at 6 43 26 pm](https://cloud.githubusercontent.com/assets/1881213/12855612/5ee4adfa-cc38-11e5-9efa-f1a82fca2a8e.png)\r\n\r\nthe 2D coordinate for scatterplot and line collection should be correct otherwise the old version should not draw it correctly. \r\n\r\nI found there is no explanation in the official documentation of matplotlib of the `Collection. set_agg_filter(filter_func)` nor did I found the explanation of what is `filter_fun` is like and how it should be defined.\r\n\r\nplease tell me whether `agg_filter` is still working in Matplotlib, many thanks.\r\n\r\n---\r\nso basically I extract the relevant code to present:\r\n```\r\n## for drawing the overlay graph\r\n\r\n# this line draw the network\r\npclt = LineCollection(segments = arwPair, linewidths = sizeArr, linestyles = markerArr)\r\n\r\nfrom agg_filter import AggFilterHelper # a helper class wrapping the Gaussian filter\r\n\r\nafh = AggFilterHelper(\"Blur\")\r\npclt.set_agg_filter(afh.get_aggFilter()) # this LineCollection api to set filter\r\npclt.set_rasterized(True)\r\n\r\naxx.add_collection(pclt) # add collection to axes object\r\n# go on drawing\r\n```\r\n===\r\nthe `agg_filter` 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.\r\n\r\n```\r\ndef smooth1d(x, window_len):\r\n\t# copied from http://www.scipy.org/Cookbook/SignalSmooth\r\n\r\n\ts=np.r_[2*x[0]-x[window_len:1:-1],x,2*x[-1]-x[-1:-window_len:-1]]\r\n\tw = np.hanning(window_len)\r\n\ty=np.convolve(w/w.sum(),s,mode='same')\r\n\treturn y[window_len-1:-window_len+1]\r\n\r\ndef smooth2d(A, sigma=3):\r\n\r\n\twindow_len = max(int(sigma), 3)*2+1\r\n\tA1 = np.array([smooth1d(x, window_len) for x in np.asarray(A)])\r\n\tA2 = np.transpose(A1)\r\n\tA3 = np.array([smooth1d(x, window_len) for x in A2])\r\n\tA4 = np.transpose(A3)\r\n\r\n\treturn A4\r\n\r\n\r\nclass BaseFilter(object):\r\n\tdef prepare_image(self, src_image, dpi, pad):\r\n\t\tny, nx, depth = src_image.shape\r\n\t\tpadded_src = np.zeros([pad*2+ny, pad*2+nx, depth], dtype=\"d\")\r\n\t\tpadded_src[pad:-pad, pad:-pad,:] = src_image[:,:,:]\r\n\t\treturn padded_src\r\n\r\n\tdef get_pad(self, dpi):\r\n\t\treturn 0\r\n\r\n\tdef __call__(self, im, dpi):\r\n\t\tpad = self.get_pad(dpi)\r\n\t\tpadded_src = self.prepare_image(im, dpi, pad)\r\n\t\ttgt_image = self.process_image(padded_src, dpi)\r\n\t\treturn tgt_image, -pad, -pad\r\n\r\nclass GaussianFilter(BaseFilter):\r\n\t\"simple gauss filter\"\r\n\t# Only this one I test and used in the application\r\n\tdef __init__(self, sigma):\r\n\t\tself.sigma = sigma\r\n\r\n\tdef get_pad(self, dpi):\r\n\t\treturn int(self.sigma*3/72.*dpi)\r\n\r\n\r\n\tdef process_image(self, padded_src, dpi):\r\n\t\ttgt_image = np.zeros_like(padded_src)\r\n\t\t# original \r\n\t\t# aa = smooth2d(padded_src[:,:,-1]*self.alpha, self.sigma/72.*dpi)\r\n\t\t# tgt_image[:,:,-1] = aa\r\n\t\t# tgt_image[:,:,:-1] = self.color\r\n\r\n\t\t# My Try: hell yeah it works\r\n\t\tfor i in range(4):\r\n\t\t\taa = smooth2d(padded_src[:,:,i], self.sigma/72.*dpi)\r\n\t\t\ttgt_image[:,:,i] = aa\r\n\r\n\t\treturn tgt_image\r\n```\r\n\r\n\r\n\r\n\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/matplotlib/matplotlib/issues/comments/180535909","html_url":"https://github.com/matplotlib/matplotlib/issues/5969#issuecomment-180535909","issue_url":"https://api.github.com/repos/matplotlib/matplotlib/issues/5969","id":180535909,"user":{"login":"tacaswell","id":199813,"avatar_url":"https://avatars.githubusercontent.com/u/199813?v=3","gravatar_id":"","url":"https://api.github.com/users/tacaswell","html_url":"https://github.com/tacaswell","followers_url":"https://api.github.com/users/tacaswell/followers","following_url":"https://api.github.com/users/tacaswell/following{/other_user}","gists_url":"https://api.github.com/users/tacaswell/gists{/gist_id}","starred_url":"https://api.github.com/users/tacaswell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tacaswell/subscriptions","organizations_url":"https://api.github.com/users/tacaswell/orgs","repos_url":"https://api.github.com/users/tacaswell/repos","events_url":"https://api.github.com/users/tacaswell/events{/privacy}","received_events_url":"https://api.github.com/users/tacaswell/received_events","type":"User","site_admin":false},"created_at":"2016-02-05T20:03:54Z","updated_at":"2016-02-05T20:03:54Z","body":"We can not fix bugs we do not know about.  Can you check if using #5718 fixes it for you?"}}