Git Product home page Git Product logo

Comments (7)

tammoippen avatar tammoippen commented on May 28, 2024

Hello @FinFighter ,

Thank you for using / trying plotille. The lib was designed to be used in a terminal:

  • color output uses ANSI (and extensions) escape sequences, which are interpreted by a terminal as colors. See this wiki article for details. Also it detects, if the script is run in a tty session - if not, the escape sequences are not printed. Output would look even more ugly :D (see below)
  • in the terminal all (most) characters are printed in a grid of equal size, even if the used font uses characters that are not equal width. In most monospace fonts I tested, the braille characters are still wider than the ASCII characters. The terminal forces the characters into the grid. (BTW: the 'whitespace' within the axis are not ordinary space (ASCII 20) characters, but braille characters with no dot set: \u2800. See _dots.py for details on the handling of each character.)

Since Jupyter notebooks do not have the terminal grid formatting in the output, the braille characters misalign the output with respect to the axis.

Please try the script in the terminal:

import plotille
import numpy as np

X = np.sort(np.random.normal(size=1000))

fig = plotille.Figure()
fig.width = 60
fig.height = 3
fig.height = 30
fig.set_x_limits(min_=-3, max_=3)
fig.set_y_limits(min_=-1, max_=1)
fig.color_mode = 'byte'
fig.plot([-0.5, 1], [-1, 1], lc=25, label='First line')
fig.scatter(X, np.sin(X), lc=100, label='sin')
fig.plot(X, (X+2)**2, lc=200, label='square')

print(fig.show(legend=True))

from plotille.

tammoippen avatar tammoippen commented on May 28, 2024

Script in an ipython session:
Screen Shot 2019-04-01 at 20 24 44

from plotille.

tammoippen avatar tammoippen commented on May 28, 2024

Script in my jupyter notebook. The canvas within the axis is misaligned.

Screen Shot 2019-04-01 at 20 45 45

from plotille.

tammoippen avatar tammoippen commented on May 28, 2024

The output with color escape sequences printed (for fun :D). The character is the ASCII ESC character (\x1b ASCII 27):

   (Y)     ^
         1 |
0.93333333 | ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀�[38;5;200m⢠�[0m�[38;5;200m⠇�[0m⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇⠀⠀⠀⠀⠀⠀⠀⠀�[38;5;25m⢠�[0m�[38;5;25m⠃�[0m⠀�[38;5;100m⡠�[0m�[38;5;100m⠞�[0m�[38;5;100m⠉�[0m⠀⠀�[38;5;100m⠉�[0m�[38;5;100m⠑�[0m�[38;5;100m⢄�[0m⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
0.86666667 | ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀�[38;5;200m⢸�[0m⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇⠀⠀⠀⠀⠀⠀⠀⠀�[38;5;25m⡎�[0m�[38;5;100m⢠�[0m�[38;5;100m⠞�[0m�[38;5;100m⠁�[0m⠀⠀⠀⠀⠀⠀⠀�[38;5;100m⠲�[0m�[38;5;100m⡀�[0m⠀⠀⠀⠀⠀⠀⠀⠀
0.80000000 | ⠀�[38;5;200m⢇�[0m⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀�[38;5;200m⡇�[0m⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇⠀⠀⠀⠀⠀⠀⠀�[38;5;25m⢠�[0m�[38;5;100m⣳�[0m�[38;5;100m⠋�[0m⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀�[38;5;100m⠐�[0m�[38;5;100m⡀�[0m⠀⠀⠀⠀⠀⠀⠀
0.73333333 | ⠀�[38;5;200m⢸�[0m⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀�[38;5;200m⢠�[0m�[38;5;200m⠃�[0m⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇⠀⠀⠀⠀⠀⠀⠀�[38;5;100m⣾�[0m�[38;5;100m⠃�[0m⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀�[38;5;100m⠘�[0m�[38;5;100m⠂�[0m⠀⠀⠀⠀⠀⠀
0.66666667 | ⠀�[38;5;200m⠈�[0m�[38;5;200m⡆�[0m⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀�[38;5;200m⡸�[0m⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇⠀⠀⠀⠀⠀⠀�[38;5;100m⣰�[0m�[38;5;100m⠃�[0m⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀�[38;5;100m⠄�[0m⠀⠀⠀⠀⠀
0.60000000 | ⠀⠀�[38;5;200m⢇�[0m⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀�[38;5;200m⡇�[0m⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇⠀⠀⠀⠀⠀�[38;5;100m⢠�[0m�[38;5;100m⡏�[0m⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀�[38;5;100m⠨�[0m�[38;5;100m⠄�[0m⠀⠀⠀⠀
0.53333333 | ⠀⠀�[38;5;200m⢸�[0m⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀�[38;5;200m⡸�[0m⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇⠀⠀⠀⠀�[38;5;100m⢠�[0m�[38;5;100m⢯�[0m�[38;5;25m⠃�[0m⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀�[38;5;100m⠸�[0m⠀⠀⠀⠀
0.46666667 | ⠀⠀⠀�[38;5;200m⡇�[0m⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀�[38;5;200m⡇�[0m⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇⠀⠀⠀⠀�[38;5;100m⡞�[0m�[38;5;25m⡎�[0m⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
0.40000000 | ⠀⠀⠀�[38;5;200m⢸�[0m⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀�[38;5;200m⡸�[0m⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇⠀⠀⠀�[38;5;100m⡼�[0m�[38;5;25m⢠�[0m�[38;5;25m⠃�[0m⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
0.33333333 | ⠀⠀⠀⠀�[38;5;200m⡇�[0m⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀�[38;5;200m⡇�[0m⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇⠀⠀�[38;5;100m⢰�[0m�[38;5;100m⠃�[0m�[38;5;25m⡎�[0m⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀�[38;5;100m⠄�[0m⠀
0.26666667 | ⠀⠀⠀⠀�[38;5;200m⠸�[0m�[38;5;200m⡀�[0m⠀⠀⠀⠀⠀⠀⠀⠀⠀�[38;5;200m⡸�[0m⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇⠀�[38;5;100m⢀�[0m�[38;5;100m⡏�[0m�[38;5;25m⢠�[0m�[38;5;25m⠃�[0m⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀�[38;5;100m⠁�[0m⠀
0.20000000 | ⠀⠀⠀⠀⠀�[38;5;200m⢇�[0m⠀⠀⠀⠀⠀⠀⠀⠀�[38;5;200m⢠�[0m�[38;5;200m⠃�[0m⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇⠀�[38;5;100m⡼�[0m⠀�[38;5;25m⡎�[0m⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀�[38;5;100m⠂�[0m
0.13333333 | ⠀⠀⠀⠀⠀�[38;5;200m⠈�[0m�[38;5;200m⢆�[0m⠀⠀⠀⠀⠀⠀�[38;5;200m⢀�[0m�[38;5;200m⠏�[0m⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇�[38;5;100m⢰�[0m�[38;5;100m⠁�[0m�[38;5;25m⢠�[0m�[38;5;25m⠃�[0m⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
0.06666667 | ⠀⠀⠀⠀⠀⠀�[38;5;200m⠈�[0m�[38;5;200m⢆�[0m⠀⠀⠀⠀�[38;5;200m⢠�[0m�[38;5;200m⠊�[0m⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀�[38;5;100m⣇�[0m�[38;5;100m⠇�[0m⠀�[38;5;25m⡎�[0m⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
         0 | ⣀⣀⣀⣀⣀⣀⣀⣀�[38;5;200m⣳�[0m�[38;5;200m⣄�[0m�[38;5;200m⣀�[0m�[38;5;200m⣰�[0m�[38;5;200m⣃�[0m⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀�[38;5;100m⣟�[0m⣀�[38;5;25m⣠�[0m�[38;5;25m⣃�[0m⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀
-0.0666667 | ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀�[38;5;100m⢰�[0m�[38;5;100m⡇�[0m⠀�[38;5;25m⡎�[0m⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
-0.1333333 | ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀�[38;5;100m⢀�[0m�[38;5;100m⠇�[0m⡇�[38;5;25m⢠�[0m�[38;5;25m⠃�[0m⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
-0.2000000 | ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀�[38;5;100m⡜�[0m⠀⡇�[38;5;25m⡎�[0m⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
-0.2666667 | ⠀�[38;5;100m⠁�[0m⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀�[38;5;100m⢸�[0m�[38;5;100m⠁�[0m⠀�[38;5;25m⣧�[0m�[38;5;25m⠃�[0m⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
-0.3333333 | ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀�[38;5;100m⢠�[0m�[38;5;100m⠇�[0m⠀⠀�[38;5;25m⡏�[0m⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
-0.4000000 | ⠀⠀�[38;5;100m⠠�[0m⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀�[38;5;100m⡞�[0m⠀⠀�[38;5;25m⢠�[0m�[38;5;25m⡇�[0m⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
-0.4666667 | ⠀⠀⠀�[38;5;100m⠂�[0m⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀�[38;5;100m⡼�[0m⠀⠀⠀�[38;5;25m⡎�[0m⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
-0.5333333 | ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀�[38;5;100m⢰�[0m�[38;5;100m⠃�[0m⠀⠀�[38;5;25m⢠�[0m�[38;5;25m⠃�[0m⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
-0.6000000 | ⠀⠀⠀⠀�[38;5;100m⠘�[0m⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀�[38;5;100m⢀�[0m�[38;5;100m⠏�[0m⠀⠀⠀�[38;5;25m⡎�[0m⠀⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
-0.6666667 | ⠀⠀⠀⠀⠀�[38;5;100m⠠�[0m⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀�[38;5;100m⢀�[0m�[38;5;100m⡎�[0m⠀⠀⠀�[38;5;25m⢠�[0m�[38;5;25m⠃�[0m⠀⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
-0.7333333 | ⠀⠀⠀⠀⠀⠀�[38;5;100m⠰�[0m�[38;5;100m⡀�[0m⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀�[38;5;100m⢀�[0m�[38;5;100m⡞�[0m⠀⠀⠀⠀�[38;5;25m⡎�[0m⠀⠀⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
-0.8000000 | ⠀⠀⠀⠀⠀⠀⠀�[38;5;100m⠑�[0m�[38;5;100m⡀�[0m⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀�[38;5;100m⢀�[0m�[38;5;100m⡞�[0m⠀⠀⠀⠀�[38;5;25m⢠�[0m�[38;5;25m⠃�[0m⠀⠀⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
-0.8666667 | ⠀⠀⠀⠀⠀⠀⠀⠀�[38;5;100m⠱�[0m⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀�[38;5;100m⢠�[0m�[38;5;100m⠞�[0m⠀⠀⠀⠀⠀�[38;5;25m⡎�[0m⠀⠀⠀⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
-0.9333333 | ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀�[38;5;100m⠆�[0m�[38;5;100m⡀�[0m⠀⠀⠀⠀⠀⠀�[38;5;100m⡴�[0m�[38;5;100m⠋�[0m⠀⠀⠀⠀⠀�[38;5;25m⢠�[0m�[38;5;25m⠃�[0m⠀⠀⠀⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
        -1 | ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀�[38;5;100m⠐�[0m�[38;5;100m⠦�[0m�[38;5;100m⣀�[0m�[38;5;100m⣀�[0m�[38;5;100m⣠�[0m�[38;5;100m⠴�[0m�[38;5;100m⠊�[0m⠀⠀⠀⠀⠀⠀⠀�[38;5;25m⡎�[0m⠀⠀⠀⠀⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
-----------|-|---------|---------|---------|---------|---------|---------|-> (X)
           | -3        -2        -1        0         1         2         3        

Legend:
-------
�[38;5;25m⠤⠤ First line�[0m
�[38;5;100m⠤⠤ sin�[0m
�[38;5;200m⠤⠤ square�[0m

from plotille.

tammoippen avatar tammoippen commented on May 28, 2024

If you want to plot in jupyter notebook, better use matplotlib. The magic commands do provide for a much better experience there.

from plotille.

FinFighter avatar FinFighter commented on May 28, 2024

I appreciate the reply and clarification. I now understand it is an issue with where the characters are being printed, not a problem with the library itself. My intended use case was to print the charts to a text file for more informative algorithm performance reports. After running the provided code in the bash console I get the expected output. I'll modify my program to use the console instead of Jupiter Notebook. Thank you!

image

from plotille.

tammoippen avatar tammoippen commented on May 28, 2024

Great that it works for you! Have fun. Best, Tammo

from plotille.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.