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

It should be possible to sort the plots #40

Closed
EtienneT opened this issue Aug 20, 2019 · 1 comment
Closed

It should be possible to sort the plots #40

EtienneT opened this issue Aug 20, 2019 · 1 comment

Comments

@EtienneT
Copy link

Lets say you do something like this:

fig, axes = joypy.joyplot(df, by="company", column="Score")

This will produce multiple graphs, sorted by the column "company". "company" would be sorted alphabetically by default, but what if I want a custom sort of how the graph are shown?

For example to have something like this:
MXT8U

@leotac
Copy link
Owner

leotac commented Sep 8, 2019

Hi, you can do it in a couple of different ways.

One way is to pass a DataFrameGroupBy object, using sort=False, like this:

grouped = df.groupby("company", sort=False)
fig, axes = joypy.joyplot(grouped, column="Score")

in this case, the order of the original dataframe will be preserved after the grouping. So it's enough to arrange the original dataframe in the order you'd like to obtain after the grouping.

Another way is to avoid using a dataframe and pass a list or a dictionary (see notebook with the examples, "plotting with raw data"). In this case you can collect the values and just pass the structure as it is (the order will be preserved for dicts in python 3.7+, otherwise you can use a list).
As an example:

d = {"C": c, "A": a, "B": b}
fig, ax = joypy.joyplot(d)

exampl

@leotac leotac closed this as completed Sep 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants