def ascii_plot(xs, ys, title=None, print_out=False): import subprocess import platform if platform.system().lower() == 'windows': path = 'C:/Program Files/gnuplot/bin/gnuplot.exe' else: path = "/usr/bin/gnuplot" gnuplot = subprocess.Popen([path], stdin=subprocess.PIPE, stdout=subprocess.PIPE, universal_newlines=True) input_string = "set term dumb 90 25\n" input_string += "set key off\n" if not hasattr(ys[0], '__len__'): ys_list = [ys] else: ys_list = ys input_string += "plot " input_string += ', '.join(["'-' using 1:2 title 'Line1' with linespoints" for ys in ys_list]) input_string += '\n' for ys in ys_list: for i, j in zip(xs, ys): input_string += "%f %f\n" % (i, j) input_string += "e\n" output_string, error_msg = gnuplot.communicate(input_string) if title is not None: title = '** {} **\n'.format(title.title()) output_string = title + output_string if print_out: print(output_string) return output_string if __name__ == '__main__': from tqdm import tqdm from time import sleep for freq in tqdm(range(10)): import numpy as np xs = np.linspace(0, 2 * np.pi, 100) ys = np.sin(freq * xs) o = ascii_plot(xs, ys) tqdm.write(o) sleep(1)