Skip to content
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

Issue with subplots in tmux #46

Closed
brijow opened this issue Jul 9, 2021 · 2 comments
Closed

Issue with subplots in tmux #46

brijow opened this issue Jul 9, 2021 · 2 comments

Comments

@brijow
Copy link

brijow commented Jul 9, 2021

In the README, the sample test subplots work fine in my usual terminal, but do not work in a tmux window.

However, when I plot a single subplot at a time, they do work.

This script is what I am referring to (from the README). Running the whole thing shows nothing. Calling plt.show() before drawing on the second subplot will correctly display first subplot. If I then draw second subplot and call plt.show() again, now the second shows but first disappears. When running the full script, neither show up, (in TMUX only seeing this issue).

import numpy as np
import matplotlib.pyplot as plt
import networkx as nx

plt.rcParams["font.size"] = 10

plt.figure(figsize=(8,3))

ax = plt.subplot(121)
x = np.arange(0,10,0.001)
ax.plot(x, np.sin(np.sinc(x)), 'r', lw=2)
ax.set_title('Nice wiggle')

ax = plt.subplot(122)
plt.tick_params(axis='both', left='off', top='off', right='off', bottom='off', labelleft='off', labeltop='off', labelright='off', labelbottom='off')
G = nx.random_geometric_graph(200, 0.125)
pos=nx.spring_layout(G)
nx.draw_networkx_edges(G, pos, alpha=0.2)
nx.draw_networkx_nodes(G, pos, node_color='r', node_size=12)
ax.set_title('Random graph')

plt.show()
@brijow
Copy link
Author

brijow commented Jul 9, 2021

Just to follow up here with a similar issue since I believe it is related:

In tmux if you change panes or resize or scroll, the plots disappear. However recalling plt.show() brings them back in that case (assuming they successfully were drawn the first time).

@daleroberts
Copy link
Owner

This has to do with TMUX window behaviour. Don't blame them though, drawing images in the terminal doesn't really fall within classic terminal behaviour so it's really hard to plan for it when you are doing a complicated window layout. Unfortunately, I don't think I can fix this with my code.

@brijow brijow closed this as completed Jul 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants