Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add build system information #63

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 13 additions & 8 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ['pypy-3.8', 3.8, 'pypy-3.9', 3.9, '3.10', 'pypy-3.10', '3.11', '3.12']
python-version: ['pypy-3.9', 3.9, '3.10', 'pypy-3.10', '3.11', '3.12', '3.13']
include:
- os: ubuntu-latest
path: ~/.cache/pip
Expand All @@ -23,14 +23,10 @@ jobs:
- os: windows-latest
path: ~\AppData\Local\pip\Cache
exclude:
- os: macos-latest
python-version: 'pypy-3.8'
- os: macos-latest
python-version: 'pypy-3.9'
- os: macos-latest
python-version: 'pypy-3.10'
- os: windows-latest
python-version: 'pypy-3.8'
- os: windows-latest
python-version: 'pypy-3.9'
- os: windows-latest
Expand All @@ -47,7 +43,7 @@ jobs:
uses: actions/checkout@v4

- name: Set Up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

Expand All @@ -66,12 +62,21 @@ jobs:
version: ${{ startsWith(matrix.python-version, 'pypy') && '1.2.2' || '1.7.0' }}
virtualenvs-create: false

# pendulum has no 3.13 build (yet), hence install build dependencies
- uses: seanmiddleditch/gha-setup-ninja@v5
with:
version: "1.12.1"

- name: Install
run: poetry install
run: |
poetry run pip install maturin cython # pendulum
poetry install

- name: Style
if: ${{ ! startsWith(matrix.python-version, 'pypy-') }}
run: poetry run flake8 tests/ plotille/ examples/
run: |
poetry run ruff format --check .
poetry run ruff check .

- name: Tests
run: poetry run pytest -s -vvv
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/Publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,23 @@ jobs:

steps:
- name: Checkout repo
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Set Up Python 3.7
uses: actions/setup-python@v4
- name: Set Up Python 3.12
uses: actions/setup-python@v5
with:
python-version: 3.7
python-version: 3.12

- name: Install Poetry
uses: snok/install-poetry@v1
with:
version: 1.2.2
version: 1.8.3

- name: Build
run: poetry build -vvv -f sdist

- name: Archive artifacts
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
path: dist/*.tar.gz

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
Expand Down
7 changes: 6 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
.PHONY: style tests install

fmt:
poetry run ruff format .
poetry run ruff check --fix .

style:
poetry run flake8 tests/ plotille/ examples/
poetry run ruff format --check .
poetry run ruff check .

tests:
poetry run pytest -s -vvv
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@

[![CI](https://github.com/tammoippen/plotille/actions/workflows/CI.yml/badge.svg)](https://github.com/tammoippen/plotille/actions/workflows/CI.yml)
[![codecov](https://codecov.io/gh/tammoippen/plotille/branch/master/graph/badge.svg?token=OGWI832JNM)](https://codecov.io/gh/tammoippen/plotille)
[![Tested CPython Versions](https://img.shields.io/badge/cpython-3.8%2C%203.9%2C%203.10%2C%203.11%2C%203.12-brightgreen.svg)](https://img.shields.io/badge/cpython-3.8%2C%203.9%2C%203.10%2C%203.11%2C%203.12-brightgreen.svg)
[![Tested PyPy Versions](https://img.shields.io/badge/pypy-3.8%2C%203.9-brightgreen.svg)](https://img.shields.io/badge/pypy-3.8%2C%203.9%2C%203.10-brightgreen.svg)
[![Tested CPython Versions](https://img.shields.io/badge/cpython-3.9%2C%203.10%2C%203.11%2C%203.12%2C%203.13-brightgreen.svg)](https://img.shields.io/badge/cpython-3.9%2C%203.10%2C%203.11%2C%203.12%2C%203.13-brightgreen.svg)
[![Tested PyPy Versions](https://img.shields.io/badge/pypy-3.9%2C%203.10-brightgreen.svg)](https://img.shields.io/badge/pypy-3.9%2C%203.10%2C%203.10-brightgreen.svg)
[![PyPi version](https://img.shields.io/pypi/v/plotille.svg)](https://pypi.python.org/pypi/plotille)
[![Downloads](https://pepy.tech/badge/plotille/month)](https://pepy.tech/project/plotille)
[![PyPi license](https://img.shields.io/pypi/l/plotille.svg)](https://pypi.python.org/pypi/plotille)
[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)

Plots, scatter plots, histograms and heatmaps in the terminal using braille dots, and foreground and background colors - with no dependancies. Make complex figures using the Figure class or make fast and simple plots using graphing function - similar to a very small sibling to matplotlib. Or use the canvas to plot dots, lines and images yourself.

Expand Down
77 changes: 49 additions & 28 deletions examples/color_example.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import, division, print_function, unicode_literals

# The MIT License

# Copyright (c) 2017 - 2024 Tammo Ippen, [email protected]
Expand Down Expand Up @@ -29,35 +26,59 @@


def main():
print(color('Do not print colors, if `no_color` is set to True', fg='red', no_color=True))
print(color('You can set a foreground', fg='red'))
print(color('and a background.', bg='red'))
print(color('Or both.', fg='black', bg='cyan'))

print(color('Asside from 4-bit / name colors', fg='green', mode='names'))
print(color('you can also set 8-bit colors / 256-color lookup tables', fg=126, bg=87, mode='byte'))
print(color('or go with full 24-bit rgb colors', fg=(50, 50, 50), bg=(166, 237, 240), mode='rgb'))

no_color = os.environ.get('NO_COLOR')
os.environ['NO_COLOR'] = '1'
print(color('The Environmnet variable `NO_COLOR` will always strip colors.', fg='red'))
print(
color(
"Do not print colors, if `no_color` is set to True", fg="red", no_color=True
)
)
print(color("You can set a foreground", fg="red"))
print(color("and a background.", bg="red"))
print(color("Or both.", fg="black", bg="cyan"))

print(color("Asside from 4-bit / name colors", fg="green", mode="names"))
print(
color(
"you can also set 8-bit colors / 256-color lookup tables",
fg=126,
bg=87,
mode="byte",
)
)
print(
color(
"or go with full 24-bit rgb colors",
fg=(50, 50, 50),
bg=(166, 237, 240),
mode="rgb",
)
)

no_color = os.environ.get("NO_COLOR")
os.environ["NO_COLOR"] = "1"
print(
color("The Environmnet variable `NO_COLOR` will always strip colors.", fg="red")
)
if no_color:
os.environ['NO_COLOR'] = no_color
os.environ["NO_COLOR"] = no_color
else:
os.environ.pop('NO_COLOR')

force_color = os.environ.get('FORCE_COLOR')
os.environ['FORCE_COLOR'] = '1'
print(color('The Environmnet variable `FORCE_COLOR` allows to toggle colors,', fg='blue'))
os.environ['FORCE_COLOR'] = '0'
print(color('setting it to 0, none or false, strips color codes', fg='magenta'))
os.environ['FORCE_COLOR'] = '1'
print(color('everything else forces color codes', fg='green'))
os.environ.pop("NO_COLOR")

force_color = os.environ.get("FORCE_COLOR")
os.environ["FORCE_COLOR"] = "1"
print(
color(
"The Environmnet variable `FORCE_COLOR` allows to toggle colors,", fg="blue"
)
)
os.environ["FORCE_COLOR"] = "0"
print(color("setting it to 0, none or false, strips color codes", fg="magenta"))
os.environ["FORCE_COLOR"] = "1"
print(color("everything else forces color codes", fg="green"))
if force_color:
os.environ['FORCE_COLOR'] = force_color
os.environ["FORCE_COLOR"] = force_color
else:
os.environ.pop('FORCE_COLOR')
os.environ.pop("FORCE_COLOR")


if __name__ == '__main__':
if __name__ == "__main__":
main()
11 changes: 4 additions & 7 deletions examples/custom_ticks_example.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import, division, print_function, unicode_literals

# The MIT License

# Copyright (c) 2017 - 2024 Tammo Ippen, [email protected]
Expand Down Expand Up @@ -51,12 +48,12 @@ def mean_y_value(Y, min_, max_):


def str_tick(min_, max_):
return '{:.3f}'.format(min_ + (max_ - min_) / 2)
return "{:.3f}".format(min_ + (max_ - min_) / 2)


def main():
Y = [0, 10, 20, 20, 21, 25, 30, 32, 40, 44, 50] + [51.3] * 10 # noqa: N806
X = list(range(len(Y))) # noqa: N806
Y = [0, 10, 20, 20, 21, 25, 30, 32, 40, 44, 50] + [51.3] * 10
X = list(range(len(Y)))

fig = plt.Figure()
fig.plot(X, Y)
Expand All @@ -82,5 +79,5 @@ def main():
print(fig.show())


if __name__ == '__main__':
if __name__ == "__main__":
main()
25 changes: 14 additions & 11 deletions examples/ellipse_example.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import, division, print_function, unicode_literals

# The MIT License

# Copyright (c) 2017 - 2024 Tammo Ippen, [email protected]
Expand Down Expand Up @@ -35,36 +32,42 @@ def main():
fig.width = 50
fig.height = 20

X1, Y1 = plt_data.ellipse(x_center=0, y_center=0, x_amplitude=0.5, y_amplitude=0.5, n=20) # noqa: N806
X1, Y1 = plt_data.ellipse(
x_center=0, y_center=0, x_amplitude=0.5, y_amplitude=0.5, n=20
)
fig.plot(X1, Y1)

print(fig.show(legend=True))

# first set
X2, Y2 = plt_data.ellipse(x_center=0, y_center=0) # noqa: N806
X2, Y2 = plt_data.ellipse(x_center=0, y_center=0)
fig.plot(X2, Y2)

X3, Y3 = plt_data.ellipse(x_center=0, y_center=0, x_amplitude=0.5, y_amplitude=0.5, n=20) # noqa: N806
fig.plot(X3, Y3, label='Ellipse 2')
X3, Y3 = plt_data.ellipse(
x_center=0, y_center=0, x_amplitude=0.5, y_amplitude=0.5, n=20
)
fig.plot(X3, Y3, label="Ellipse 2")

print(fig.show(legend=True))

# second set, offset
fig.clear()
X2, Y2 = plt_data.ellipse(x_center=0, y_center=0) # noqa: N806
X2, Y2 = plt_data.ellipse(x_center=0, y_center=0)
fig.plot(X2, Y2)
fig.set_x_limits(min_=-10, max_=10)
fig.set_y_limits(min_=-10, max_=10)

for xx in [-4, 0, 4]:
for yy in [-4, 0, 4]:
X, Y = plt_data.ellipse(x_center=xx, y_center=yy, x_amplitude=1, y_amplitude=1, n=20) # noqa: N806
fig.plot(X, Y, label=('{},{}'.format(xx, yy)))
X, Y = plt_data.ellipse(
x_center=xx, y_center=yy, x_amplitude=1, y_amplitude=1, n=20
)
fig.plot(X, Y, label=("{},{}".format(xx, yy)))

fig.scatter([4], [4])

print(fig.show(legend=True))


if __name__ == '__main__':
if __name__ == "__main__":
main()
9 changes: 3 additions & 6 deletions examples/histograms_example.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import, division, print_function, unicode_literals

# The MIT License

# Copyright (c) 2017 - 2024 Tammo Ippen, [email protected]
Expand Down Expand Up @@ -33,12 +30,12 @@


def main():
print('Histogram left to right')
print("Histogram left to right")
print(plotille.hist(np.random.normal(size=10000)))

print('Histogram rotated')
print("Histogram rotated")
print(plotille.histogram(np.random.normal(size=10000)))


if __name__ == '__main__':
if __name__ == "__main__":
main()
11 changes: 4 additions & 7 deletions examples/house_example.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import, division, print_function, unicode_literals

# The MIT License

# Copyright (c) 2017 - 2024 Tammo Ippen, [email protected]
Expand All @@ -25,21 +22,21 @@

from plotille import Canvas


# The underlying canvas-implementation can be used on its own.


def main():
c = Canvas(width=40, height=20)
c.rect(0.1, 0.1, 0.6, 0.6)
c.line(0.1, 0.1, 0.6, 0.6)
c.line(0.1, 0.6, 0.6, 0.1)
c.line(0.1, 0.6, 0.35, 0.8)
c.line(0.35, 0.8, 0.6, 0.6)
c.text(0.3, 0.5, 'hi', color='red')
c.point(0.35, 0.35, color='blue')
c.text(0.3, 0.5, "hi", color="red")
c.point(0.35, 0.35, color="blue")
c.fill_char(0.35, 0.1)
print(c.plot())


if __name__ == '__main__':
if __name__ == "__main__":
main()
Loading
Loading