python:console
문서의 이전 판입니다!
Python Console
컬러 문자 출력
ascii문자로 plotting
-
gnuplot 사용
예제
- ascii_plot.py
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.1470717403.txt.gz · 마지막으로 수정됨: 2024/03/23 02:38 (바깥 편집)