ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Tue, 15 Dec 2020 22:50:06 +0100Strategies for plotting graphs with many verticeshttps://ask.sagemath.org/question/53126/strategies-for-plotting-graphs-with-many-vertices/I've found that sage is good at drawing small graphs, but becomes decreasingly useful for visualizing your graph as the number of vertices increases. This is doubly true if you want to label your vertices. Oftentimes I feel like this is due to sage trying to keep the graph image somewhat small, and I would be happy to trade an image with large xy dimensions in exchange for more spread out vertices, which will give the labels room to be legible.
I know that sage will let you manually choose where the vertices go, but often I am drawing graphs to try to visualize things quickly to develop conjectures, and it is more important that I be able to go through lots of examples than it is to have each one perfect.
Does anyone know of a way to get sage to spread the vertices out more aggressively, and generally to get it to plot graphs with ~50 nodes while maintaining legibility? I'm aware there was a question about a similar topic here (apparently I don't have enough karma to post links: /question/9305/strategies-for-drawing-good-graphs-graph-theory/), but seeing as that was 8 years ago, it seems reasonable that there may have been some developments.
Thanks in advance ^_^ Fri, 21 Aug 2020 00:45:51 +0200https://ask.sagemath.org/question/53126/strategies-for-plotting-graphs-with-many-vertices/Comment by tmonteil for <p>I've found that sage is good at drawing small graphs, but becomes decreasingly useful for visualizing your graph as the number of vertices increases. This is doubly true if you want to label your vertices. Oftentimes I feel like this is due to sage trying to keep the graph image somewhat small, and I would be happy to trade an image with large xy dimensions in exchange for more spread out vertices, which will give the labels room to be legible.</p>
<p>I know that sage will let you manually choose where the vertices go, but often I am drawing graphs to try to visualize things quickly to develop conjectures, and it is more important that I be able to go through lots of examples than it is to have each one perfect.</p>
<p>Does anyone know of a way to get sage to spread the vertices out more aggressively, and generally to get it to plot graphs with ~50 nodes while maintaining legibility? I'm aware there was a question about a similar topic here (apparently I don't have enough karma to post links: /question/9305/strategies-for-drawing-good-graphs-graph-theory/), but seeing as that was 8 years ago, it seems reasonable that there may have been some developments.</p>
<p>Thanks in advance ^_^ </p>
https://ask.sagemath.org/question/53126/strategies-for-plotting-graphs-with-many-vertices/?comment=53130#post-id-53130Could you please provide a concrete example of a graph you want to plot (with labels, etc) ?Fri, 21 Aug 2020 16:45:47 +0200https://ask.sagemath.org/question/53126/strategies-for-plotting-graphs-with-many-vertices/?comment=53130#post-id-53130Comment by HallaSurvivor for <p>I've found that sage is good at drawing small graphs, but becomes decreasingly useful for visualizing your graph as the number of vertices increases. This is doubly true if you want to label your vertices. Oftentimes I feel like this is due to sage trying to keep the graph image somewhat small, and I would be happy to trade an image with large xy dimensions in exchange for more spread out vertices, which will give the labels room to be legible.</p>
<p>I know that sage will let you manually choose where the vertices go, but often I am drawing graphs to try to visualize things quickly to develop conjectures, and it is more important that I be able to go through lots of examples than it is to have each one perfect.</p>
<p>Does anyone know of a way to get sage to spread the vertices out more aggressively, and generally to get it to plot graphs with ~50 nodes while maintaining legibility? I'm aware there was a question about a similar topic here (apparently I don't have enough karma to post links: /question/9305/strategies-for-drawing-good-graphs-graph-theory/), but seeing as that was 8 years ago, it seems reasonable that there may have been some developments.</p>
<p>Thanks in advance ^_^ </p>
https://ask.sagemath.org/question/53126/strategies-for-plotting-graphs-with-many-vertices/?comment=53137#post-id-53137[Here](https://pastebin.com/PTuZzjdw) is a pastebin of my exact example right now. you'll see that the graph is illegible (it takes a while to compute, jsyk). For ease of reference, [here](https://ibb.co/T8M1wZ7) is a screenshot.Sat, 22 Aug 2020 03:50:09 +0200https://ask.sagemath.org/question/53126/strategies-for-plotting-graphs-with-many-vertices/?comment=53137#post-id-53137Answer by David Coudert for <p>I've found that sage is good at drawing small graphs, but becomes decreasingly useful for visualizing your graph as the number of vertices increases. This is doubly true if you want to label your vertices. Oftentimes I feel like this is due to sage trying to keep the graph image somewhat small, and I would be happy to trade an image with large xy dimensions in exchange for more spread out vertices, which will give the labels room to be legible.</p>
<p>I know that sage will let you manually choose where the vertices go, but often I am drawing graphs to try to visualize things quickly to develop conjectures, and it is more important that I be able to go through lots of examples than it is to have each one perfect.</p>
<p>Does anyone know of a way to get sage to spread the vertices out more aggressively, and generally to get it to plot graphs with ~50 nodes while maintaining legibility? I'm aware there was a question about a similar topic here (apparently I don't have enough karma to post links: /question/9305/strategies-for-drawing-good-graphs-graph-theory/), but seeing as that was 8 years ago, it seems reasonable that there may have been some developments.</p>
<p>Thanks in advance ^_^ </p>
https://ask.sagemath.org/question/53126/strategies-for-plotting-graphs-with-many-vertices/?answer=53131#post-id-53131Have you tried that:
sage: G = graphs.RandomBlockGraph(20, 4, kmax=6)
sage: G.show(method='js')
The graph is displayed using d3.js in your navigator, and it is now possible to export in SVG.Fri, 21 Aug 2020 16:48:52 +0200https://ask.sagemath.org/question/53126/strategies-for-plotting-graphs-with-many-vertices/?answer=53131#post-id-53131Comment by cybervigilante for <p>Have you tried that:</p>
<pre><code>sage: G = graphs.RandomBlockGraph(20, 4, kmax=6)
sage: G.show(method='js')
</code></pre>
<p>The graph is displayed using d3.js in your navigator, and it is now possible to export in SVG.</p>
https://ask.sagemath.org/question/53126/strategies-for-plotting-graphs-with-many-vertices/?comment=54687#post-id-54687Wow, that was great. I was getting sick of cluttered graphs since I made a random graph generator and nodes past about 15 were almost unreadable. Sagemath documentation is sooo spread out. Or incredibly advanced for what I want to do. I was hoping to find a native method and didn't think of javascript.Tue, 15 Dec 2020 22:50:06 +0100https://ask.sagemath.org/question/53126/strategies-for-plotting-graphs-with-many-vertices/?comment=54687#post-id-54687Comment by HallaSurvivor for <p>Have you tried that:</p>
<pre><code>sage: G = graphs.RandomBlockGraph(20, 4, kmax=6)
sage: G.show(method='js')
</code></pre>
<p>The graph is displayed using d3.js in your navigator, and it is now possible to export in SVG.</p>
https://ask.sagemath.org/question/53126/strategies-for-plotting-graphs-with-many-vertices/?comment=53136#post-id-53136This looks like it could be really useful, but by default it still doesn't look very good. At the risk of seeming naive, are there settings I should be changing that I'm not? [Here](https://ibb.co/WH3Vq51) is how it ends up looking. This was generated with basically the same sage code is an my comment to tmonteil.Sat, 22 Aug 2020 03:47:38 +0200https://ask.sagemath.org/question/53126/strategies-for-plotting-graphs-with-many-vertices/?comment=53136#post-id-53136Comment by David Coudert for <p>Have you tried that:</p>
<pre><code>sage: G = graphs.RandomBlockGraph(20, 4, kmax=6)
sage: G.show(method='js')
</code></pre>
<p>The graph is displayed using d3.js in your navigator, and it is now possible to export in SVG.</p>
https://ask.sagemath.org/question/53126/strategies-for-plotting-graphs-with-many-vertices/?comment=53139#post-id-53139The documentation is [here](https://doc.sagemath.org/html/en/reference//graphs/sage/graphs/graph_plot_js.html).
Try
Gex.show(method='js', vertex_colors=ecol, vertex_size=50, link_distance=500)Sat, 22 Aug 2020 11:55:49 +0200https://ask.sagemath.org/question/53126/strategies-for-plotting-graphs-with-many-vertices/?comment=53139#post-id-53139Comment by HallaSurvivor for <p>Have you tried that:</p>
<pre><code>sage: G = graphs.RandomBlockGraph(20, 4, kmax=6)
sage: G.show(method='js')
</code></pre>
<p>The graph is displayed using d3.js in your navigator, and it is now possible to export in SVG.</p>
https://ask.sagemath.org/question/53126/strategies-for-plotting-graphs-with-many-vertices/?comment=53140#post-id-53140Fantastic! Thanks for the docs ^_^ This is exactly what I wantedSun, 23 Aug 2020 06:46:26 +0200https://ask.sagemath.org/question/53126/strategies-for-plotting-graphs-with-many-vertices/?comment=53140#post-id-53140