Giter Club home page Giter Club logo

Comments (4)

Thylowz avatar Thylowz commented on May 18, 2024 1

Thanks for your explanation.

I already set plot with the subplots_adjust method.
It turns out that I can adjust as I wish by using xlim/ylim appropriately.

I've also adjusted origin and scale to it so I'm pretty satisfied with it, I have way less coordinates issues than previously.
Thank you very much for the cool library and how easy it was to get info.

I guess you can close the issue, since behaviour seems to be pretty much what I wanted!

from netgraph.

paulbrodersen avatar paulbrodersen commented on May 18, 2024

It seems to me that netgraph (or networkx) auto determines a "frame" depending on the number of nodes it has to display.

Netgraph doesn't (or shouldn't) but it is built on matplotlib, and matplotlib by default adjusts the axis extents to the data limits of the objects plotted. As with any other matplotlib figure, you can set the x- and y-limits explicitly:

import matplotlib.pyplot as plt
import networkx as nx
from netgraph import InteractiveGraph

fig, ax = plt.subplots()
G = nx.complete_graph(10)
pos = nx.shell_layout(G)
ref = InteractiveGraph(G, node_layout=pos, ax=ax)
ax.set_xlim(-2, 2)
ax.set_ylim(-2, 2)
plt.show()

Figure_1

Does this solve your issue?

from netgraph.

Thylowz avatar Thylowz commented on May 18, 2024

As always, thank you for your (quick) answer.

I can see that it works, I just have to figure out how to properly set it to the matplotlib limits (there is currently still some margin). I initialized my Figure to figsize=(5, 3) so maybe I have to dig with this. All these features is just some extensive stuff I have added to my work but is not my core knowledge so it's not very intuitive to me.

By the way, setting the axe xlim/ylim impacted my graph "size", everything got way smaller than it was. Any clue why it did?

from netgraph.

paulbrodersen avatar paulbrodersen commented on May 18, 2024

I just have to figure out how to properly set it to the matplotlib limits (there is currently still some margin).

In matplotlib, all axes have a margin by default. You can adjust/remove the margins with:

fig, ax = plt.subplots()
fig.subplots_adjust(left=0, bottom=0, right=1, top=1)

By the way, setting the axe xlim/ylim impacted my graph "size", everything got way smaller than it was. Any clue why it did?

This is the expected behaviour, as in netgraph, all object sizes are given in data coordinates (times a constant factor of 0.01). This is in contrast to networkx, where node sizes and edge widths are in display coordinates.

from netgraph.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.