I tried using "Asciichart Py" which can draw a beautiful graph on the console with Python.

Screen Shot 2020-09-12 at 2.18.23.png

Introduction

Speaking of graphs, matplotlib is probably the most famous, but AsciiChart draws graphs as ASCII characters directly on the console. There is a convenient library called. At first glance, I couldn't find an article that seems to be introduced in Qiita yet, so I thought it would be helpful as much as possible, so I wrote it.

pip

Install ʻasciichartpy` with the pip command.

$ pip install asciichartpy

Sample code

This is the sample source used in the image at the top. You can configure various things with the parameter cfg, but in this example, I changed the color of series.

import asciichartpy

from math import cos
from math import pi

import random #Postscript 2020/09/14 Thank you for pointing out

if __name__ == '__main__':
    width = 120

    config = {
        'colors': [
            asciichartpy.green,
            asciichartpy.magenta,
            asciichartpy.red
        ]
    }

    print(asciichartpy.plot(
        series=[[random.randint(1, 15) * cos(i * ((pi * 4) / width)) for i in range(width)],
                [random.randint(1, 15) * cos(i * ((pi * 2) / width)) for i in range(width)],
                [random.randint(1, 15) * cos(i * ((pi * 9) / width)) for i in range(width)]],
        cfg=config
        )
    )

end

I hope you find it helpful. Thank you very much.

Recommended Posts

I tried using "Asciichart Py" which can draw a beautiful graph on the console with Python.
I tried using "Streamlit" which can do the Web only with Python
I tried with the top 100 PyPI packages> I tried to graph the packages installed on Python
I tried to draw a route map with Python
I tried using the Python library from Ruby with PyCall
[Visualization] I want to draw a beautiful graph with Plotly
Control the motor with a motor driver using python on Raspberry Pi 3!
I tried to make a todo application using bottle with python
[Python] I tried to make a simple program that works on the command line using argparse.
I tried a functional language with Python
[Python] I tried to visualize the night on the Galactic Railroad with WordCloud!
I tried to draw a system configuration diagram with Diagrams on Docker
[Python, ObsPy] I drew a beach ball on the map with Cartopy + ObsPy.
Every time I draw a graph with python, I check it, so I will summarize only the simplest usage
I tried "smoothing" the image with Python + OpenCV
vprof --I tried using the profiler for Python
I tried "differentiating" the image with Python + OpenCV
[Python] Draw a directed graph with Dash Cytoscape
I tried using mecab with python2.7, ruby2.3, php7
I tried "binarizing" the image with Python + OpenCV
I tried reading a CSV file using Python
I tried using the Datetime module by Python
I tried using a database (sqlite3) with kivy
I tried playing with the calculator on tkinter
I tried using the Python library "pykakasi" that can convert kanji to romaji.
Draw a line / scatter plot on the CSV file (2 columns) with python matplotlib
Draw a graph with PyQtGraph Part 5-Increase the Y-axis
Draw a graph in Julia ... I tried a little analysis
I learned Python with a beautiful girl at Paiza # 02
A story that was convenient when I tried using the python ip address module
[Python] How to draw a line graph with Matplotlib
I learned Python with a beautiful girl at Paiza # 01
I tried to implement Minesweeper on terminal with python
I tried to touch the CSV file with Python
I tried to solve the soma cube with python
When I tried to create a project using Python on Docker with PyCharm, it didn't work, but it worked with Docker Compose.
I tried python on heroku for the first time
Make a breakpoint on the c layer with python
I made a Python3 environment on Ubuntu with direnv.
[Python] I tried to graph the top 10 eyeshadow rankings
I tried to automatically generate a password with Python3
[Python] I tried running a local server using flask
I tried drawing a pseudo fractal figure using Python
I tried to solve the problem with Python Vol.1
I tried using Python (3) instead of a scientific calculator
I tried to complement the knowledge graph using OpenKE
I tried to draw a configuration diagram using Diagrams
I tried hitting the API with echonest's python client
I enjoyed writing with a single stroke on the self-avoiding random walk ~ Using python with reference to Computational Physics I (Asakura Shoten) ~
I tried "Streamlit" which turns the Python code into a web application as it is
[Shell startup] I tried to display the shell on the TV with a cheap Linux board G-cluster
I also tried to imitate the function monad and State monad with a generator in Python
I wrote a doctest in "I tried to simulate the probability of a bingo game with Python"
I tried to find the entropy of the image with python
I replaced the Windows PowerShell cookbook with a python script.
Study math with Python: Draw a sympy (scipy) graph with matplotlib
I tried to simulate how the infection spreads with Python
Why can I use the module by importing with python?
I tried replacing the Windows 10 HDD with a smaller SSD
I made a VGG16 model using TensorFlow (on the way)
Miscellaneous notes that I tried using python for the matter