matplotlibtkinternetgraph

How to match the size of InteractiveGraph with tkinter window?


I'm working on some code using python netgraph. I've got it to work with tkinter, so the window is visible inside tkinter, but I wanted it to match the size of the tkinter window. 

I've tried scaling and modifying the figure and axis, but they still don't really match. I want the black border to match the size of the tkinter window.

fig, ax = plt.subplots()
ax.patch.set_edgecolor('black')
ax.patch.set_linewidth(1)
ax.autoscale_view(True, True, True)
fig.set_size_inches(16, 9)
plot_instance = InteractiveGraph(
    g, node_size=5, node_color=node_color,
    node_labels=True, node_label_offset=0.1, node_label_fontdict=dict(size=20),
    edge_color=edge_color, edge_width=1, ax=ax, scale=(2, 2))

Tkinter window with InteractiveGraph inside


Solution

  • Those are just the figure borders of the matplotlib window. You can remove them with figure.subplots_adjust:

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