Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Jitter plot #2750

Closed
Closed
@yoavram

Description

@yoavram

It would be great if we can have either a jitter command or a jitter flag in scatter.
I'm refering to something like ggplot2's geom_jitter.

A basic solution:

def rand_jitter(arr):
    stdev = arr.max()/100.
    return arr + np.random.randn(len(arr)) * stdev

def jitter(x, y, s=20, c='b', marker='o', cmap=None, norm=None, vmin=None, vmax=None, alpha=None, linewidths=None, verts=None, hold=None, **kwargs):
    return scatter(rand_jitter(x), rand_jitter(y), s=20, c='b', marker='o', cmap=None, norm=None, vmin=None, vmax=None, alpha=None, linewidths=None, verts=None, hold=None, **kwargs)

Of course the definition of stdev needs to be better, this will only work for some cases.

The idea is from this SoF post.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions