New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
graph vertices cut off #9211
Comments
comment:1
Here is a good example showing the problem (still):
|
Attachment: trac-9211-graph-vertices-cut.patch.gz |
comment:2
This patch depends on the matplotlib spkg at #9221. I don't know if the patch is very elegant. I'll trust the reviewer's comments on that. The problem is that it lets the scatter plot vertices extend beyond the frame (relying on the user adjusting the axes_pad option to extend the frame). |
Author: Jason Grout |
Work Issues: depends on #9221 |
comment:4
The patch doesn't work for multiple-edge graphs (they are drawn completely differently than graphs without multiple edges). In fact, we probably ought to draw all graphs using CircleCollection objects rather than scatter_plot or Circles. |
comment:5
Here's how to draw circles like the ones in scatter plot (where the size doesn't change as you make the figure smaller or bigger: use a CircleCollection argument and use different transforms to specify location and size coordinates. See http://sourceforge.net/mailarchive/forum.php?thread_name=AANLkTim6ZnGiOV1RTRBz0uBMF5y67xyrDp%2BkVSCBtkrB%40mail.gmail.com&forum_name=matplotlib-users |
comment:6
See also http://groups.google.com/group/networkx-discuss/browse_thread/thread/b95fda9813fae67d for code/ideas for rewriting the graph drawing. |
comment:7
I think this patch might take just a little to clean up. Most of the patch is just adding comments to explain the code or reformatting long lines. The big key is the clip=False arguments and the code to add things to the bbox_extra_artists. I think the patch might just need some doctests and testing. The other comments I put in above can be moved to another ticket that does a bigger revamp of graph drawing. |
Changed work issues from depends on #9221 to none |
( Fix cut off vertices in graphs ) Apply to devel/sage/ |
Attachment: trac-9211-fix_cut_vertices_in_graphs.patch.gz Attachment: trac-9211-add_padding_to_graphs.patch.gz ( Add additional padding to graphs ) Apply to devel/sage |
Output with only the earlier patch (modified for 4.7.2) |
Attachment: with-earlier-patch-modified-for-4.7.2.png Output with patch for additional padding |
comment:11
Attachment: with-additional-padding.png Added two patches. The first one is essentially the patch by jason redone to work with 4.7.2_alpha3. The second patch adds extra padding to all graphs. The two pngs attached are the output of
The file attachment: with-additional-padding.png is the result of both the patches being applied. Graphs currently look really bad without either of the two patches. The second patch is not a panacea for all cut off graph plots since it doesn't fix all cases. But my hope is that it fixes most commonly used cases. |
comment:12
I'm curious why you need the extra padding patch. Are vertices still cut off using just the first patch? |
comment:13
Replying to @jasongrout:
Yes. Check the plot after the first patch against the the plot after first+second patch |
comment:16
Replying to @jasongrout:
Excellent! Thanks. This does fix the problem for digraphs. Much better than adding random paddings. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
comment:19
Okay, did you run long tests on Sage? The new version of my first patch seems okay to me, so if you positively review the patches, I think we are good to go, assuming that you've run long tests and there are no doctest errors. |
comment:20
Replying to @jasongrout:
I started the long test (make ptestlong) over an hour ago. I guess there's 3 more hours to go :) |
comment:21
A couple of doctests failed. Only in the directory plot/ (and in the files changed by this patch + base.pyx). Will investigate more once I am physically near that machine where the doctest was run. |
comment:22
Just FYI, base.pyx often fails on Mac if you don't have libjpeg or libtiff in the right place - see #7344 and #7345. If the errors look like
you can ignore them, they would be unrelated. |
This comment has been minimized.
This comment has been minimized.
comment:23
I am running it on x86_64 Linux. The errors were because of the additional 'clip' option introduced in the patches. Attaching a fix for the doctests. |
comment:24
I wonder why you are concatenating lines in the doctest output - our docstrings are theoretically supposed to be 72 (or 79) characters wide, if I'm not mistaken, which is why they the current test results are broken into multiple lines. The doctester doesn't care about purely whitespace differences between the expected and received output. |
comment:25
Replying to @kini:
Simply copied the output from "Expected output". Will attached a space-ified fix. :) |
comment:26
I wonder if you are aware of |
Attachment: trac_9211-fix_doctests.patch.gz Fix doctests for 3d plots (re-uploaded) |
comment:27
Uploaded new patch. Didn't know about Forget about the adding padding patch. Jason did the real fix. :) |
comment:28
Previous failures were:
New doctest on
So positive review from my side. |
Reviewer: Punarbasu Purkayastha |
comment:30
Your changes were a little more than just fixing whitespace, so let someone look at it to review your last patch. Sorry---you're right about those doctests. I shouldn't have been so sloppy as to not fix those doctests before indicating it needed to be reviewed. |
comment:31
Yep, I confirm that normal tests in graphs/ and plot/ pass. Positive review for the fix doctests patch. Good job! |
Merged: sage-4.8.alpha1 |
Though #7299 helped, graph vertices are still cut off.
We can turn off clipping of the matplotlib scatterplot and add some bbox_extra_artists to the savefig which takes those artists into account when calculating the bounding box (when bbox_inches='tight').
First apply attachment: trac-9211-fix_cut_vertices_in_graphs.patch and then apply attachment: trac_9211_digraph_clipping.patch to
$SAGE_ROOT/devel/sage
. Finally apply attachment: trac_9211-fix_doctests.patch to$SAGE_ROOT/devel/sage
.CC: @rbeezer @kcrisman @kini
Component: graph theory
Author: Jason Grout
Reviewer: Punarbasu Purkayastha
Merged: sage-4.8.alpha1
Issue created by migration from https://trac.sagemath.org/ticket/9211
The text was updated successfully, but these errors were encountered: