mirror of
https://github.com/xonsh/xonsh.git
synced 2025-03-04 08:24:40 +01:00
xontrib-mpl makes a copy of the current figure before modifying it
This commit is contained in:
parent
7d30021294
commit
aec0430622
1 changed files with 3 additions and 1 deletions
|
@ -4,6 +4,7 @@ import shutil
|
|||
import numpy as np
|
||||
import matplotlib
|
||||
import matplotlib.pyplot as plt
|
||||
import pickle
|
||||
|
||||
from xonsh.tools import print_color, ON_WINDOWS
|
||||
|
||||
|
@ -56,7 +57,7 @@ def buf_to_color_str(buf):
|
|||
|
||||
|
||||
def show():
|
||||
fig = plt.gcf()
|
||||
fig = pickle.loads(pickle.dumps(plt.gcf()))
|
||||
w, h = shutil.get_terminal_size()
|
||||
if ON_WINDOWS:
|
||||
w -= 1 # @melund reports that win terminals are too thin
|
||||
|
@ -64,3 +65,4 @@ def show():
|
|||
buf = figure_to_rgb_array(fig, w, h)
|
||||
s = buf_to_color_str(buf)
|
||||
print_color(s)
|
||||
plt.close(fig)
|
||||
|
|
Loading…
Add table
Reference in a new issue