{"action":"created","comment":{"url":"https://api.github.com/repos/matlab2tikz/matlab2tikz/pulls/comments/41698997","id":41698997,"diff_hunk":"@@ -743,89 +750,200 @@ function movePointsCloser(meta, handle)\n   xNew = x + bsxfun(@times ,minAlpha, (xRef-x));\n end\n % =========================================================================\n-function minAlpha = updateAlpha(X1, X2, X3, X4, minAlpha)\n-  % Checks whether the segments X1--X2 and X3--X4 intersect. \n-  lambda = crossLines(X1, X2, X3, X4);\n-  \n-  % Check if lambda is in bounds and lambda1 large enough\n-  id_Alpha           = 0.0 < lambda(:,2) & lambda(:,2) < 1.0 ...\n-                     & abs(minAlpha) > abs(lambda(:,1));\n+function [xData, yData] = getVisualData(meta, handle)\n+    % Extract the data from the current line handle.\n+    xData = get(handle, 'XData');\n+    yData = get(handle, 'YData');\n \n-  % Update alpha when applicable\n-  minAlpha(id_Alpha) = lambda(id_Alpha,1);\n+    % Get info about log scaling\n+    isXlog = strcmp(get(meta.gca, 'XScale'), 'log');\n+    if isXlog\n+        xData = log10(xData);\n+    end\n+    isYlog = strcmp(get(meta.gca, 'YScale'), 'log');\n+    if isYlog\n+        yData = log10(yData);\n+    end\n+\n+    % Turn the data into a row vector\n+    xData = xData(:);\n+    yData = yData(:);\n end\n % =========================================================================\n-function out = isInBox(data, xLim, yLim)\n+function [xLim, yLim] = getVisualLimits(meta)\n+    % Get the axis limits\n+    xLim = get(meta.gca, 'XLim');\n+    yLim = get(meta.gca, 'YLim');\n \n-  out = data(:,1) > xLim(1) & data(:,1) < xLim(2) ...\n-      & data(:,2) > yLim(1) & data(:,2) < yLim(2);\n+    % Check for logarithmic scales\n+    isXlog = strcmp(get(meta.gca, 'XScale'), 'log');\n+    if isXlog\n+        xLim  = log10(xLim);\n+    end\n+    isYlog = strcmp(get(meta.gca, 'YScale'), 'log');\n+\tif isYlog\n+        yLim  = log10(yLim);\n+\tend\n end\n % =========================================================================\n-function lambda = crossLines(X1, X2, X3, X4)\n-  % Checks whether the segments X1--X2 and X3--X4 intersect.\n-  % See https://en.wikipedia.org/wiki/Line-line_intersection for reference.\n-  % Given four points X_k=(x_k,y_k), k\\in{1,2,3,4}, and the two lines \n-  % defined by those,\n-  %\n-  %  L1(lambda) = X1 + lambda (X2 - X1)\n-  %  L2(lambda) = X3 + lambda (X4 - X3)\n-  %\n-  % returns the lambda for which they intersect (and Inf if they are parallel).\n-  % Technically, one needs to solve the 2x2 equation system\n-  %\n-  %   x1 + lambda1 (x2-x1)  =  x3 + lambda2 (x4-x3)\n-  %   y1 + lambda1 (y2-y1)  =  y3 + lambda2 (y4-y3)\n-  %\n-  % for lambda1 and lambda2.\n+function replaceData(handle, id_replace, dataReplace)\n+  % Replaces data at id_replace with dataReplace","path":"src/cleanfigure.m","position":837,"original_position":837,"commit_id":"158a43632e98bd5fd2dd5167b258533a06281edd","original_commit_id":"158a43632e98bd5fd2dd5167b258533a06281edd","user":{"login":"miscco","id":3017120,"avatar_url":"https://avatars.githubusercontent.com/u/3017120?v=3","gravatar_id":"","url":"https://api.github.com/users/miscco","html_url":"https://github.com/miscco","followers_url":"https://api.github.com/users/miscco/followers","following_url":"https://api.github.com/users/miscco/following{/other_user}","gists_url":"https://api.github.com/users/miscco/gists{/gist_id}","starred_url":"https://api.github.com/users/miscco/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/miscco/subscriptions","organizations_url":"https://api.github.com/users/miscco/orgs","repos_url":"https://api.github.com/users/miscco/repos","events_url":"https://api.github.com/users/miscco/events{/privacy}","received_events_url":"https://api.github.com/users/miscco/received_events","type":"User","site_admin":false},"body":"As a matter of fact, we only ever replace data points by NaNs. So one might change this to\r\nreplaceData(handle, id_replace), or even more oscure\r\nreplaceDataWithNaN(handle, id_replace)\r\n\r\nThe current function is more flexible and can potentially be used sometimes later when the need arises.","created_at":"2015-10-10T16:53:20Z","updated_at":"2015-10-10T16:53:20Z","html_url":"https://github.com/matlab2tikz/matlab2tikz/pull/787#discussion_r41698997","pull_request_url":"https://api.github.com/repos/matlab2tikz/matlab2tikz/pulls/787","_links":{"self":{"href":"https://api.github.com/repos/matlab2tikz/matlab2tikz/pulls/comments/41698997"},"html":{"href":"https://github.com/matlab2tikz/matlab2tikz/pull/787#discussion_r41698997"},"pull_request":{"href":"https://api.github.com/repos/matlab2tikz/matlab2tikz/pulls/787"}}},"pull_request":{"url":"https://api.github.com/repos/matlab2tikz/matlab2tikz/pulls/787","id":47266778,"html_url":"https://github.com/matlab2tikz/matlab2tikz/pull/787","diff_url":"https://github.com/matlab2tikz/matlab2tikz/pull/787.diff","patch_url":"https://github.com/matlab2tikz/matlab2tikz/pull/787.patch","issue_url":"https://api.github.com/repos/matlab2tikz/matlab2tikz/issues/787","number":787,"state":"open","locked":false,"title":"Cleanfigure restructure","user":{"login":"miscco","id":3017120,"avatar_url":"https://avatars.githubusercontent.com/u/3017120?v=3","gravatar_id":"","url":"https://api.github.com/users/miscco","html_url":"https://github.com/miscco","followers_url":"https://api.github.com/users/miscco/followers","following_url":"https://api.github.com/users/miscco/following{/other_user}","gists_url":"https://api.github.com/users/miscco/gists{/gist_id}","starred_url":"https://api.github.com/users/miscco/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/miscco/subscriptions","organizations_url":"https://api.github.com/users/miscco/orgs","repos_url":"https://api.github.com/users/miscco/repos","events_url":"https://api.github.com/users/miscco/events{/privacy}","received_events_url":"https://api.github.com/users/miscco/received_events","type":"User","site_admin":false},"body":"So when I was writing the 3D projection part in #779, I realized, that I had to do a lot of restructuring. \r\n\r\nTo keep it \"cleaner\" I decided to pull it out and make a new PR. So there are some new functions:\r\n\r\n```matlab\r\n[xData, yData] = getVisualData(meta, handle)\r\n[xLim, yLim] = getVisualLimits(meta)\r\n\r\nreplaceData(handle, id_replace, dataReplace)\r\ninsertData(handle, id_insert, dataInsert)\r\nremoveData(meta, handle, id_remove)\r\n\r\nremoveNaNs(meta, handle)\r\n```\r\n\r\nI believe their names are rather self explanatory. To get them working i had to restructure our simplification functions slightly. In the end I decided, that every function should generate lists of indices e.g. id_replace for all the data that should be replaced and removed and so on.\r\n\r\nThis unifies the data handling and should help us to maintain the stuff easier.\r\n\r\nI have also renamed some of the output when it was a mask rather out","created_at":"2015-10-09T12:40:04Z","updated_at":"2015-10-10T16:53:20Z","closed_at":null,"merged_at":null,"merge_commit_sha":"d22dc723f2c4fc45d69c500278ea5c157dd7d586","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/matlab2tikz/matlab2tikz/pulls/787/commits","review_comments_url":"https://api.github.com/repos/matlab2tikz/matlab2tikz/pulls/787/comments","review_comment_url":"https://api.github.com/repos/matlab2tikz/matlab2tikz/pulls/comments{/number}","comments_url":"https://api.github.com/repos/matlab2tikz/matlab2tikz/issues/787/comments","statuses_url":"https://api.github.com/repos/matlab2tikz/matlab2tikz/statuses/158a43632e98bd5fd2dd5167b258533a06281edd","head":{"label":"miscco:Cleanfigure_Restructure","ref":"Cleanfigure_Restructure","sha":"158a43632e98bd5fd2dd5167b258533a06281edd","user":{"login":"miscco","id":3017120,"avatar_url":"https://avatars.githubusercontent.com/u/3017120?v=3","gravatar_id":"","url":"https://api.github.com/users/miscco","html_url":"https://github.com/miscco","followers_url":"https://api.github.com/users/miscco/followers","following_url":"https://api.github.com/users/miscco/following{/other_user}","gists_url":"https://api.github.com/users/miscco/gists{/gist_id}","starred_url":"https://api.github.com/users/miscco/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/miscco/subscriptions","organizations_url":"https://api.github.com/users/miscco/orgs","repos_url":"https://api.github.com/users/miscco/repos","events_url":"https://api.github.com/users/miscco/events{/privacy}","received_events_url":"https://api.github.com/users/miscco/received_events","type":"User","site_admin":false},"repo":{"id":41079586,"name":"matlab2tikz","full_name":"miscco/matlab2tikz","owner":{"login":"miscco","id":3017120,"avatar_url":"https://avatars.githubusercontent.com/u/3017120?v=3","gravatar_id":"","url":"https://api.github.com/users/miscco","html_url":"https://github.com/miscco","followers_url":"https://api.github.com/users/miscco/followers","following_url":"https://api.github.com/users/miscco/following{/other_user}","gists_url":"https://api.github.com/users/miscco/gists{/gist_id}","starred_url":"https://api.github.com/users/miscco/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/miscco/subscriptions","organizations_url":"https://api.github.com/users/miscco/orgs","repos_url":"https://api.github.com/users/miscco/repos","events_url":"https://api.github.com/users/miscco/events{/privacy}","received_events_url":"https://api.github.com/users/miscco/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/miscco/matlab2tikz","description":"This program converts MATLAB®/Octave figures to TikZ/pgfplots figures for smooth integration into LaTeX.","fork":true,"url":"https://api.github.com/repos/miscco/matlab2tikz","forks_url":"https://api.github.com/repos/miscco/matlab2tikz/forks","keys_url":"https://api.github.com/repos/miscco/matlab2tikz/keys{/key_id}","collaborators_url":"https://api.github.com/repos/miscco/matlab2tikz/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/miscco/matlab2tikz/teams","hooks_url":"https://api.github.com/repos/miscco/matlab2tikz/hooks","issue_events_url":"https://api.github.com/repos/miscco/matlab2tikz/issues/events{/number}","events_url":"https://api.github.com/repos/miscco/matlab2tikz/events","assignees_url":"https://api.github.com/repos/miscco/matlab2tikz/assignees{/user}","branches_url":"https://api.github.com/repos/miscco/matlab2tikz/branches{/branch}","tags_url":"https://api.github.com/repos/miscco/matlab2tikz/tags","blobs_url":"https://api.github.com/repos/miscco/matlab2tikz/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/miscco/matlab2tikz/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/miscco/matlab2tikz/git/refs{/sha}","trees_url":"https://api.github.com/repos/miscco/matlab2tikz/git/trees{/sha}","statuses_url":"https://api.github.com/repos/miscco/matlab2tikz/statuses/{sha}","languages_url":"https://api.github.com/repos/miscco/matlab2tikz/languages","stargazers_url":"https://api.github.com/repos/miscco/matlab2tikz/stargazers","contributors_url":"https://api.github.com/repos/miscco/matlab2tikz/contributors","subscribers_url":"https://api.github.com/repos/miscco/matlab2tikz/subscribers","subscription_url":"https://api.github.com/repos/miscco/matlab2tikz/subscription","commits_url":"https://api.github.com/repos/miscco/matlab2tikz/commits{/sha}","git_commits_url":"https://api.github.com/repos/miscco/matlab2tikz/git/commits{/sha}","comments_url":"https://api.github.com/repos/miscco/matlab2tikz/comments{/number}","issue_comment_url":"https://api.github.com/repos/miscco/matlab2tikz/issues/comments{/number}","contents_url":"https://api.github.com/repos/miscco/matlab2tikz/contents/{+path}","compare_url":"https://api.github.com/repos/miscco/matlab2tikz/compare/{base}...{head}","merges_url":"https://api.github.com/repos/miscco/matlab2tikz/merges","archive_url":"https://api.github.com/repos/miscco/matlab2tikz/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/miscco/matlab2tikz/downloads","issues_url":"https://api.github.com/repos/miscco/matlab2tikz/issues{/number}","pulls_url":"https://api.github.com/repos/miscco/matlab2tikz/pulls{/number}","milestones_url":"https://api.github.com/repos/miscco/matlab2tikz/milestones{/number}","notifications_url":"https://api.github.com/repos/miscco/matlab2tikz/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/miscco/matlab2tikz/labels{/name}","releases_url":"https://api.github.com/repos/miscco/matlab2tikz/releases{/id}","created_at":"2015-08-20T06:33:40Z","updated_at":"2015-08-20T06:33:41Z","pushed_at":"2015-10-09T18:22:23Z","git_url":"git://github.com/miscco/matlab2tikz.git","ssh_url":"git@github.com:miscco/matlab2tikz.git","clone_url":"https://github.com/miscco/matlab2tikz.git","svn_url":"https://github.com/miscco/matlab2tikz","homepage":"http://www.mathworks.com/matlabcentral/fileexchange/22022-matlab2tikz","size":7208,"stargazers_count":0,"watchers_count":0,"language":"Matlab","has_issues":false,"has_downloads":false,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"matlab2tikz:develop","ref":"develop","sha":"356c64656d34a78f1dfb91dc994c7680bd35accb","user":{"login":"matlab2tikz","id":10036397,"avatar_url":"https://avatars.githubusercontent.com/u/10036397?v=3","gravatar_id":"","url":"https://api.github.com/users/matlab2tikz","html_url":"https://github.com/matlab2tikz","followers_url":"https://api.github.com/users/matlab2tikz/followers","following_url":"https://api.github.com/users/matlab2tikz/following{/other_user}","gists_url":"https://api.github.com/users/matlab2tikz/gists{/gist_id}","starred_url":"https://api.github.com/users/matlab2tikz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/matlab2tikz/subscriptions","organizations_url":"https://api.github.com/users/matlab2tikz/orgs","repos_url":"https://api.github.com/users/matlab2tikz/repos","events_url":"https://api.github.com/users/matlab2tikz/events{/privacy}","received_events_url":"https://api.github.com/users/matlab2tikz/received_events","type":"Organization","site_admin":false},"repo":{"id":579842,"name":"matlab2tikz","full_name":"matlab2tikz/matlab2tikz","owner":{"login":"matlab2tikz","id":10036397,"avatar_url":"https://avatars.githubusercontent.com/u/10036397?v=3","gravatar_id":"","url":"https://api.github.com/users/matlab2tikz","html_url":"https://github.com/matlab2tikz","followers_url":"https://api.github.com/users/matlab2tikz/followers","following_url":"https://api.github.com/users/matlab2tikz/following{/other_user}","gists_url":"https://api.github.com/users/matlab2tikz/gists{/gist_id}","starred_url":"https://api.github.com/users/matlab2tikz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/matlab2tikz/subscriptions","organizations_url":"https://api.github.com/users/matlab2tikz/orgs","repos_url":"https://api.github.com/users/matlab2tikz/repos","events_url":"https://api.github.com/users/matlab2tikz/events{/privacy}","received_events_url":"https://api.github.com/users/matlab2tikz/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/matlab2tikz/matlab2tikz","description":"This program converts MATLAB®/Octave figures to TikZ/pgfplots figures for smooth integration into LaTeX.","fork":false,"url":"https://api.github.com/repos/matlab2tikz/matlab2tikz","forks_url":"https://api.github.com/repos/matlab2tikz/matlab2tikz/forks","keys_url":"https://api.github.com/repos/matlab2tikz/matlab2tikz/keys{/key_id}","collaborators_url":"https://api.github.com/repos/matlab2tikz/matlab2tikz/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/matlab2tikz/matlab2tikz/teams","hooks_url":"https://api.github.com/repos/matlab2tikz/matlab2tikz/hooks","issue_events_url":"https://api.github.com/repos/matlab2tikz/matlab2tikz/issues/events{/number}","events_url":"https://api.github.com/repos/matlab2tikz/matlab2tikz/events","assignees_url":"https://api.github.com/repos/matlab2tikz/matlab2tikz/assignees{/user}","branches_url":"https://api.github.com/repos/matlab2tikz/matlab2tikz/branches{/branch}","tags_url":"https://api.github.com/repos/matlab2tikz/matlab2tikz/tags","blobs_url":"https://api.github.com/repos/matlab2tikz/matlab2tikz/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/matlab2tikz/matlab2tikz/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/matlab2tikz/matlab2tikz/git/refs{/sha}","trees_url":"https://api.github.com/repos/matlab2tikz/matlab2tikz/git/trees{/sha}","statuses_url":"https://api.github.com/repos/matlab2tikz/matlab2tikz/statuses/{sha}","languages_url":"https://api.github.com/repos/matlab2tikz/matlab2tikz/languages","stargazers_url":"https://api.github.com/repos/matlab2tikz/matlab2tikz/stargazers","contributors_url":"https://api.github.com/repos/matlab2tikz/matlab2tikz/contributors","subscribers_url":"https://api.github.com/repos/matlab2tikz/matlab2tikz/subscribers","subscription_url":"https://api.github.com/repos/matlab2tikz/matlab2tikz/subscription","commits_url":"https://api.github.com/repos/matlab2tikz/matlab2tikz/commits{/sha}","git_commits_url":"https://api.github.com/repos/matlab2tikz/matlab2tikz/git/commits{/sha}","comments_url":"https://api.github.com/repos/matlab2tikz/matlab2tikz/comments{/number}","issue_comment_url":"https://api.github.com/repos/matlab2tikz/matlab2tikz/issues/comments{/number}","contents_url":"https://api.github.com/repos/matlab2tikz/matlab2tikz/contents/{+path}","compare_url":"https://api.github.com/repos/matlab2tikz/matlab2tikz/compare/{base}...{head}","merges_url":"https://api.github.com/repos/matlab2tikz/matlab2tikz/merges","archive_url":"https://api.github.com/repos/matlab2tikz/matlab2tikz/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/matlab2tikz/matlab2tikz/downloads","issues_url":"https://api.github.com/repos/matlab2tikz/matlab2tikz/issues{/number}","pulls_url":"https://api.github.com/repos/matlab2tikz/matlab2tikz/pulls{/number}","milestones_url":"https://api.github.com/repos/matlab2tikz/matlab2tikz/milestones{/number}","notifications_url":"https://api.github.com/repos/matlab2tikz/matlab2tikz/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/matlab2tikz/matlab2tikz/labels{/name}","releases_url":"https://api.github.com/repos/matlab2tikz/matlab2tikz/releases{/id}","created_at":"2010-03-25T22:52:27Z","updated_at":"2015-10-08T20:00:59Z","pushed_at":"2015-10-10T14:02:07Z","git_url":"git://github.com/matlab2tikz/matlab2tikz.git","ssh_url":"git@github.com:matlab2tikz/matlab2tikz.git","clone_url":"https://github.com/matlab2tikz/matlab2tikz.git","svn_url":"https://github.com/matlab2tikz/matlab2tikz","homepage":"http://www.mathworks.com/matlabcentral/fileexchange/22022-matlab2tikz","size":10528,"stargazers_count":309,"watchers_count":309,"language":"Matlab","has_issues":true,"has_downloads":false,"has_wiki":true,"has_pages":false,"forks_count":90,"mirror_url":null,"open_issues_count":107,"forks":90,"open_issues":107,"watchers":309,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/matlab2tikz/matlab2tikz/pulls/787"},"html":{"href":"https://github.com/matlab2tikz/matlab2tikz/pull/787"},"issue":{"href":"https://api.github.com/repos/matlab2tikz/matlab2tikz/issues/787"},"comments":{"href":"https://api.github.com/repos/matlab2tikz/matlab2tikz/issues/787/comments"},"review_comments":{"href":"https://api.github.com/repos/matlab2tikz/matlab2tikz/pulls/787/comments"},"review_comment":{"href":"https://api.github.com/repos/matlab2tikz/matlab2tikz/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/matlab2tikz/matlab2tikz/pulls/787/commits"},"statuses":{"href":"https://api.github.com/repos/matlab2tikz/matlab2tikz/statuses/158a43632e98bd5fd2dd5167b258533a06281edd"}}}}