Adjust the min_sep parameter automatically.

Compute a min_sep value depending on the span of the values to
distribute.
master
Damien Goutte-Gattat 3 years ago
parent 7e2b0f8f2f
commit e265b44ffb
  1. 4
      incenp/plotting/scatter.py
  2. 7
      incenp/plotting/util.py

@ -25,7 +25,7 @@ from .util import xdistr, get_stars
def scatterplot_subtrack(ax, data, n_track, n_subtrack, max_subtrack,
color, width=.7, min_sep=.1):
color, width=.7, min_sep=-.05):
"""Plot a single subtrack.
:param ax: The matplotlib axis to draw on
@ -49,7 +49,7 @@ def scatterplot_subtrack(ax, data, n_track, n_subtrack, max_subtrack,
def scatterplot(ax, data, columns, subtrackcolumns=False,
tracks=[None], trackname=0,
subtracks=[None], subtrackname=1,
colors='rgb', width=.7, min_sep=.1, testfunc=None):
colors='rgb', width=.7, min_sep=-.05, testfunc=None):
"""Create a scatterplot from multi-indexed data.
:param ax: The matplotlib axis to draw on

@ -18,7 +18,7 @@
"""Miscellaneous utility functions for plotting tasks."""
def xdistr(values, width, offset=0, even_max=10, center=False, min_sep=1):
def xdistr(values, width, offset=0, even_max=10, center=False, min_sep=-.05):
"""Distribute coordinates around an axis.
Given a list of values, return an array of x coordinates so that
@ -31,7 +31,8 @@ def xdistr(values, width, offset=0, even_max=10, center=False, min_sep=1):
this parameter, they will be put closer together
:param center: Distribute coordinates on both sides of offset
:param min_sep: If two values differ by less than this parameter,
they will be considered to belong on the same rank
they will be considered to belong on the same rank; if negative,
it is interpreted as a fraction of the span of values
:return: An array of x coordinates
"""
@ -39,6 +40,8 @@ def xdistr(values, width, offset=0, even_max=10, center=False, min_sep=1):
spent = {}
xcoords = []
if min_sep < 0:
min_sep = (max(values) - min(values)) * -min_sep
values = [int(i / min_sep) for i in values]
# Get the distribution of values

Loading…
Cancel
Save