Comments (7)
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.
from plotille.
Script in my jupyter notebook. The canvas within the axis is misaligned.
from plotille.
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.
If you want to plot in jupyter notebook, better use matplotlib
. The magic commands do provide for a much better experience there.
from plotille.
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!
from plotille.
Great that it works for you! Have fun. Best, Tammo
from plotille.
Related Issues (20)
- Not getting the graph as required HOT 8
- Some ideas for optimization. HOT 4
- weird spike at zero HOT 4
- install failed: AttributeError: module 'enum' has no attribute 'IntFlag' HOT 1
- Accept `datetime.date` as X input HOT 6
- Draw vertical or horizontal lines on plots HOT 4
- [feature request] Provide a CLI HOT 3
- Make y-values exakt or approximate values of the data inputs HOT 5
- Histogram breaks when all values are the same HOT 1
- Index out of bounds for hist() on negative values HOT 3
- Two plots side-by-side HOT 4
- has someone ever integrated this on a curses-like interface ? HOT 4
- hex colors not showing up when parsing terminal results HOT 3
- `Figure.axvline(x) coordinates are wrong` HOT 2
- Windows 10 terminal does not display brailles HOT 2
- Log scale for plot() HOT 2
- [Feature request] support arrow HOT 2
- [Feature Request] Treemaps HOT 1
- Feature request: Network graph HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from plotille.