SkillAgentSearch skills...

Plotannot

A small python library to adjust and annotate axis ticklabels in plots.

Install / Use

/learn @msbentsen/Plotannot
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

plotannot

PyPI Version

Introduction

plotannot is a a python package to automatically highlight and adjust overlapping ticklabels in matplotlib/seaborn plots. It is written with great inspiration and appreciation for the statannot package (webermarcolivier/statannot - now maintained at trevismd/statannotations), as well as the adjustText package (Phlya/adjustText).

I originally created this package for myself, as I wanted to create ComplexHeatmap (R package) style annotations for Python plots - but maybe it is of use to you too?

<img src="examples/before_after.png"/>

Features

  • Add annotation lines for certain row/column labels
  • Shift labels to not overlap
  • Add additional highlights such as color, fontsize, etc. to certain row/column labels

Getting started

Install from PyPI:

pip install plotannot

Or directly from github:

pip install git+git://github.com/msbentsen/plotannot

Requirements for package:

  • Python >= 3.6
  • matplotlib
  • numpy

Simple example

import pandas as pd
import seaborn as sns
import plotannot

#Plot heatmap
table = pd.DataFrame(np.random.random((100,50)))
ax = sns.heatmap(table, xticklabels=True, yticklabels=False)

#Rotate all labels
plotannot.format_ticklabels(ax, axis="xaxis", rotation=45)

#Annotate labels
to_label = range(20,35)
plotannot.annotate_ticks(ax, axis="xaxis", labels=to_label) 

#Color individual labels
plotannot.format_ticklabels(ax, axis="xaxis", labels=[25], color="red")
<img src="examples/simple_example.png"/>

Additional examples are found in the examples notebook.

Documentation and help

Documentation of the main functions are found at: plotannot.readthedocs.io. Examples of how to use these are in the examples notebook here: examples/examples.ipynb.

Issues and PRs are very welcome - please use the repository issues to raise an issue/contribute.

Related Skills

View on GitHub
GitHub Stars52
CategoryDevelopment
Updated1y ago
Forks1

Languages

Python

Security Score

80/100

Audited on Jul 11, 2024

No findings