사용자 도구

사이트 도구


python:console

문서의 이전 판입니다!


Python Console

def ascii_plot(xs, ys):
    import subprocess
    gnuplot = subprocess.Popen(["/usr/bin/gnuplot"], stdin=subprocess.PIPE, stdout=subprocess.PIPE)
    input_string = "set term dumb 79 25\n"
    input_string += "plot '-' using 1:2 title 'Line1' with linespoints \n"
    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)
    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)
python/console.1470716518.txt.gz · 마지막으로 수정됨: 2024/03/23 02:38 (바깥 편집)