Skip to content

Commit

Permalink
Network graph example (#58)
Browse files Browse the repository at this point in the history
  • Loading branch information
tammoippen committed May 6, 2024
1 parent 4a47f55 commit 6e13ed9
Show file tree
Hide file tree
Showing 35 changed files with 590 additions and 503 deletions.
14 changes: 9 additions & 5 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: [3.7, 'pypy-3.8', 3.8, 'pypy-3.9', 3.9, '3.10', '3.11']
python-version: ['pypy-3.8', 3.8, 'pypy-3.9', 3.9, '3.10', 'pypy-3.10', '3.11', '3.12']
include:
- os: ubuntu-latest
path: ~/.cache/pip
Expand All @@ -27,10 +27,14 @@ jobs:
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
python-version: 'pypy-3.10'
defaults:
run:
shell: bash
Expand All @@ -40,7 +44,7 @@ jobs:
PYTHONIOENCODING: UTF-8
steps:
- name: Checkout repo
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Set Up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
Expand All @@ -49,7 +53,7 @@ jobs:

- name: Cache Install
id: restore-cache
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: |
${{ matrix.path }}
Expand All @@ -59,7 +63,7 @@ jobs:
- name: Install Poetry
uses: snok/install-poetry@v1
with:
version: 1.2.2
version: ${{ startsWith(matrix.python-version, 'pypy') && '1.2.2' || '1.7.0' }}
virtualenvs-create: false

- name: Install
Expand All @@ -72,7 +76,7 @@ jobs:
- name: Tests
run: poetry run pytest -s -vvv

- uses: codecov/codecov-action@v3
- uses: codecov/codecov-action@v4
with:
flags: unittests
name: coverage-${{ matrix.os }}-${{ matrix.python-version }}
Expand Down
2 changes: 1 addition & 1 deletion LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License

Copyright (c) 2017 - 2022 Tammo Ippen, tammo.ippen@posteo.de
Copyright (c) 2017 - 2024 Tammo Ippen, tammo.ippen@posteo.de

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

[![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.7%2C%203.8%2C%203.9%2C%203.10%2C%203.11-brightgreen.svg)](https://img.shields.io/badge/cpython-3.7%2C%203.8%2C%203.9%2C%203.10%2C%203.11-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-brightgreen.svg)
[![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)
[![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)
Expand Down
2 changes: 1 addition & 1 deletion examples/color_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

# The MIT License

# Copyright (c) 2017 - 2022 Tammo Ippen, tammo.ippen@posteo.de
# Copyright (c) 2017 - 2024 Tammo Ippen, tammo.ippen@posteo.de

# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion examples/custom_ticks_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

# The MIT License

# Copyright (c) 2017 - 2022 Tammo Ippen, tammo.ippen@posteo.de
# Copyright (c) 2017 - 2024 Tammo Ippen, tammo.ippen@posteo.de

# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion examples/ellipse_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

# The MIT License

# Copyright (c) 2017 - 2022 Tammo Ippen, tammo.ippen@posteo.de
# Copyright (c) 2017 - 2024 Tammo Ippen, tammo.ippen@posteo.de

# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion examples/histograms_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

# The MIT License

# Copyright (c) 2017 - 2022 Tammo Ippen, tammo.ippen@posteo.de
# Copyright (c) 2017 - 2024 Tammo Ippen, tammo.ippen@posteo.de

# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion examples/house_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

# The MIT License

# Copyright (c) 2017 - 2022 Tammo Ippen, tammo.ippen@posteo.de
# Copyright (c) 2017 - 2024 Tammo Ippen, tammo.ippen@posteo.de

# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion examples/images_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

# The MIT License

# Copyright (c) 2017 - 2022 Tammo Ippen, tammo.ippen@posteo.de
# Copyright (c) 2017 - 2024 Tammo Ippen, tammo.ippen@posteo.de

# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the 'Software'), to deal
Expand Down
2 changes: 1 addition & 1 deletion examples/logo_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

# The MIT License

# Copyright (c) 2017 - 2022 Tammo Ippen, tammo.ippen@posteo.de
# Copyright (c) 2017 - 2024 Tammo Ippen, tammo.ippen@posteo.de

# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the 'Software'), to deal
Expand Down
2 changes: 1 addition & 1 deletion examples/markers_and_labels_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

# The MIT License

# Copyright (c) 2017 - 2022 Tammo Ippen, tammo.ippen@posteo.de
# Copyright (c) 2017 - 2024 Tammo Ippen, tammo.ippen@posteo.de

# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
Expand Down
61 changes: 61 additions & 0 deletions examples/network.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import, division, print_function, unicode_literals

# The MIT License

# Copyright (c) 2017 - 2024 Tammo Ippen, tammo.ippen@posteo.de

# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:

# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.

# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.

import random

import plotille


def main():
nodes = [(0, 0), (9, 0), (0, 9), (9, 9)]
for _ in range(10):
nodes.append((random.randint(0, 9), random.randint(0, 9)))

edges = []
for _ in range(5):
from_ = random.randint(0, len(nodes) - 1)
to_ = random.randint(0, len(nodes) - 1)
if from_ == to_:
to_ = (from_ + 1) % len(nodes)
edges.append((from_, to_))

canvas = plotille.Canvas(width=50, height=20, xmax=10, ymax=10)

for node in nodes:
canvas.point(x=node[0], y=node[1], marker='x')

for edge in edges:
from_node = nodes[edge[0]]
to_node = nodes[edge[1]]
canvas.line(
x0=from_node[0], y0=from_node[1],
x1=to_node[0], y1=to_node[1],
)

print(canvas.plot())


if __name__ == '__main__':
main()
2 changes: 1 addition & 1 deletion examples/olympic_rings_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

# The MIT License

# Copyright (c) 2017 - 2022 Tammo Ippen, tammo.ippen@posteo.de
# Copyright (c) 2017 - 2024 Tammo Ippen, tammo.ippen@posteo.de

# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion examples/performance_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

# The MIT License

# Copyright (c) 2017 - 2022 Tammo Ippen, tammo.ippen@posteo.de
# Copyright (c) 2017 - 2024 Tammo Ippen, tammo.ippen@posteo.de

# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion examples/plot_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

# The MIT License

# Copyright (c) 2017 - 2022 Tammo Ippen, tammo.ippen@posteo.de
# Copyright (c) 2017 - 2024 Tammo Ippen, tammo.ippen@posteo.de

# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion examples/scatter_cats_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

# The MIT License

# Copyright (c) 2017 - 2022 Tammo Ippen, tammo.ippen@posteo.de
# Copyright (c) 2017 - 2024 Tammo Ippen, tammo.ippen@posteo.de

# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion examples/scatter_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

# The MIT License

# Copyright (c) 2017 - 2022 Tammo Ippen, tammo.ippen@posteo.de
# Copyright (c) 2017 - 2024 Tammo Ippen, tammo.ippen@posteo.de

# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion examples/side_by_side_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

# The MIT License

# Copyright (c) 2017 - 2022 Tammo Ippen, tammo.ippen@posteo.de
# Copyright (c) 2017 - 2024 Tammo Ippen, tammo.ippen@posteo.de

# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion examples/span_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

# The MIT License

# Copyright (c) 2017 - 2022 Tammo Ippen, tammo.ippen@posteo.de
# Copyright (c) 2017 - 2024 Tammo Ippen, tammo.ippen@posteo.de

# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion examples/wetterdienst_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

# The MIT License

# Copyright (c) 2017 - 2022 Tammo Ippen, tammo.ippen@posteo.de
# Copyright (c) 2017 - 2024 Tammo Ippen, tammo.ippen@posteo.de

# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion plotille/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

# The MIT License

# Copyright (c) 2017 - 2022 Tammo Ippen, tammo.ippen@posteo.de
# Copyright (c) 2017 - 2024 Tammo Ippen, tammo.ippen@posteo.de

# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion plotille/_canvas.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

# The MIT License

# Copyright (c) 2017 - 2022 Tammo Ippen, tammo.ippen@posteo.de
# Copyright (c) 2017 - 2024 Tammo Ippen, tammo.ippen@posteo.de

# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion plotille/_cmaps.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

# The MIT License

# Copyright (c) 2017 - 2022 Tammo Ippen, tammo.ippen@posteo.de
# Copyright (c) 2017 - 2024 Tammo Ippen, tammo.ippen@posteo.de

# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion plotille/_cmaps_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

# The MIT License

# Copyright (c) 2017 - 2022 Tammo Ippen, tammo.ippen@posteo.de
# Copyright (c) 2017 - 2024 Tammo Ippen, tammo.ippen@posteo.de

# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion plotille/_colors.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

# The MIT License

# Copyright (c) 2017 - 2022 Tammo Ippen, tammo.ippen@posteo.de
# Copyright (c) 2017 - 2024 Tammo Ippen, tammo.ippen@posteo.de

# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion plotille/_dots.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

# The MIT License

# Copyright (c) 2017 - 2022 Tammo Ippen, tammo.ippen@posteo.de
# Copyright (c) 2017 - 2024 Tammo Ippen, tammo.ippen@posteo.de

# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion plotille/_figure.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

# The MIT License

# Copyright (c) 2017 - 2022 Tammo Ippen, tammo.ippen@posteo.de
# Copyright (c) 2017 - 2024 Tammo Ippen, tammo.ippen@posteo.de

# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion plotille/_figure_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

# The MIT License

# Copyright (c) 2017 - 2022 Tammo Ippen, tammo.ippen@posteo.de
# Copyright (c) 2017 - 2024 Tammo Ippen, tammo.ippen@posteo.de

# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion plotille/_graphs.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

# The MIT License

# Copyright (c) 2017 - 2022 Tammo Ippen, tammo.ippen@posteo.de
# Copyright (c) 2017 - 2024 Tammo Ippen, tammo.ippen@posteo.de

# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion plotille/_input_formatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

# The MIT License

# Copyright (c) 2017 - 2022 Tammo Ippen, tammo.ippen@posteo.de
# Copyright (c) 2017 - 2024 Tammo Ippen, tammo.ippen@posteo.de

# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion plotille/_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

# The MIT License

# Copyright (c) 2017 - 2022 Tammo Ippen, tammo.ippen@posteo.de
# Copyright (c) 2017 - 2024 Tammo Ippen, tammo.ippen@posteo.de

# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion plotille/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

# The MIT License

# Copyright (c) 2017 - 2022 Tammo Ippen, tammo.ippen@posteo.de
# Copyright (c) 2017 - 2024 Tammo Ippen, tammo.ippen@posteo.de

# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
Expand Down
Loading

0 comments on commit 6e13ed9

Please sign in to comment.