fork download
  1. import numpy as np
  2. import matplotlib.pyplot as plt
  3.  
  4. def plot_array(array, save=False, filename='test.svg'):
  5. fig, ax = plt.subplots(figsize=(16, 16))
  6. ax.imshow(array, interpolation='none', cmap='binary', aspect='auto')
  7. if save:
  8. fig.savefig(filename)
  9. else:
  10. plt.show()
  11.  
  12. a = np.random.randint(2, size=(60000, 70))
  13. # a = read_array('test.txt')
  14. plot_array(a)
  15. plot_array(a.T)
  16.  
Runtime error #stdin #stdout #stderr 0.51s 273728KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
Traceback (most recent call last):
  File "./prog.py", line 14, in <module>
    plot_array(a)
  File "./prog.py", line 5, in plot_array
    fig, ax = plt.subplots(figsize=(16, 16))
  File "/usr/lib/python3/dist-packages/matplotlib/pyplot.py", line 1203, in subplots
    fig = figure(**fig_kw)
  File "/usr/lib/python3/dist-packages/matplotlib/pyplot.py", line 535, in figure
    **kwargs)
  File "/usr/lib/python3/dist-packages/matplotlib/backends/backend_tkagg.py", line 81, in new_figure_manager
    return new_figure_manager_given_figure(num, figure)
  File "/usr/lib/python3/dist-packages/matplotlib/backends/backend_tkagg.py", line 89, in new_figure_manager_given_figure
    window = Tk.Tk()
  File "/usr/lib/python3.5/tkinter/__init__.py", line 1880, in __init__
    self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use)
_tkinter.TclError: no display name and no $DISPLAY environment variable