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

32 color swatch font size #33

Merged
merged 3 commits into from
Jan 2, 2024
Merged
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
27 changes: 13 additions & 14 deletions .github/workflows/pythonapp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up Python 3.8
uses: actions/setup-python@v2
- uses: actions/checkout@v4
- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: 3.8
python-version: 3.11

- name: Install dependencies
run: |
Expand All @@ -39,21 +39,20 @@ jobs:
os: [ubuntu-latest, windows-latest, macOS-latest]
arch: [auto]
python-version:
- '3.7'
- '3.8'
- '3.9'
- '3.10'
#- 'pypy-3.7' # see https://github.com/pandas-dev/pandas/issues/44253
- '3.11'
- '3.12'
depsize:
- 'minimal'
- 'full'

steps:
- name: Checkout source
uses: actions/checkout@v2
uses: actions/checkout@v4

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

Expand Down Expand Up @@ -87,11 +86,11 @@ jobs:
mv .coverage "../.coverage.${CUSTOM_RUNNER_ID}"
cd ..

- name: Set up Python 3.8 to combine coverage Linux
- name: Set up Python to combine coverage Linux
if: runner.os == 'Linux'
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: 3.8
python-version: 3.11

- name: Combine coverage Linux
if: runner.os == 'Linux'
Expand All @@ -103,7 +102,7 @@ jobs:
find . -name coverage.xml

- name: Codecov Upload
uses: codecov/codecov-action@v2.1.0
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: ./tests/coverage.xml
files: ./tests/coverage.xml
4 changes: 2 additions & 2 deletions .github/workflows/pythonpublish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v1
uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Install dependencies
Expand Down
2 changes: 1 addition & 1 deletion distinctipy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

name = "distinctipy"

__version__ = "1.2.3"
__version__ = "1.3.0"

# Expose these module names and their internals in the top-level API
__external__ = ["distinctipy"]
Expand Down
9 changes: 8 additions & 1 deletion distinctipy/distinctipy.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,7 @@
ax=None,
title=None,
one_row=None,
fontsize=None,
):
"""
Display the colours defined in a list of colors.
Expand All @@ -360,6 +361,9 @@
:param one_row: If True display colours on one row, if False as a grid. If
one_row=None a grid is used when there are more than 8 colours.

:param fontsize: Fontsize of text on colour swatch. If None fontsize will attempt to
be set to an appropriate size based on the number of colours.

:return:
"""
import matplotlib.colors
Expand All @@ -377,6 +381,9 @@
else:
n_grid = math.ceil(np.sqrt(len(colors)))

if fontsize is None:
fontsize = 60 / n_grid

Check warning on line 385 in distinctipy/distinctipy.py

View check run for this annotation

Codecov / codecov/patch

distinctipy/distinctipy.py#L384-L385

Added lines #L384 - L385 were not covered by tests

width = 1
height = 1

Expand Down Expand Up @@ -413,7 +420,7 @@
x + (width / 2),
y + (height / 2),
matplotlib.colors.rgb2hex(color),
fontsize=60 / np.sqrt(len(colors)),
fontsize=fontsize,
ha="center",
color=get_text_color(color, threshold=text_threshold),
)
Expand Down