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

Titles in X and Y axis #25

Closed
dirmeier opened this issue Sep 26, 2018 · 3 comments
Closed

Titles in X and Y axis #25

dirmeier opened this issue Sep 26, 2018 · 3 comments

Comments

@dirmeier
Copy link
Contributor

Hi, I have a question about Y labels and believe this functionality exists, but I cannot get it right. E.g.: I can put Y axis labels on every subplot something like this:

fig, axes = joyploy(...)
for ax in axes:
    ax.set_ylabel("mylab")

This creates a label for every density plot. Can I somehow add a "global" Y axis label, instead of a Y axis label for every subplot. I suppose I can do that by providing an ax argument to joyploy, but it does not seem to work.

Thanks for your help,
Simon

@leotac
Copy link
Owner

leotac commented Sep 26, 2018

There's no easy way - but to work on the "global" axis, you should consider the last of the axes returned by joyplot(), i.e., axes[-1], whose y axis is not visible by default.
Then you can work on it as you with, after you made it visible again. But you need to manually take care of hiding the ticks, maybe moving the title on the right, and so on.

Quick (and ugly) example:

%matplotlib inline
import joypy
import pandas as pd
from matplotlib import pyplot as plt

iris = pd.read_csv("data/iris.csv")
fig, axes = joypy.joyplot(iris)
ax = axes[-1]
ax.yaxis.set_label_position("right")
ax.set_ylabel("TestLabel")
ax.yaxis.set_visible(True)
ax.yaxis.set_ticks([])

image

@dirmeier
Copy link
Contributor Author

Awesome! That's a great idea, thanks!

@leotac
Copy link
Owner

leotac commented Sep 27, 2018

You're welcome.
To be clear -- the "axes" returned by joyplot, for a plot with 4 density plots like the one in the example above, is a list of 5 axes: the first four are the axis of the small plots, the last axis is the "global" one. I should add comments/docs that specify this better.

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