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

Passing ax ignores axis and uses entire plot #15

Open
macks22 opened this issue Jan 12, 2018 · 2 comments
Open

Passing ax ignores axis and uses entire plot #15

macks22 opened this issue Jan 12, 2018 · 2 comments

Comments

@macks22
Copy link

macks22 commented Jan 12, 2018

When I do the following:

from sklearn import datasets
from joypy import joyplot

iris = datasets.load_iris()
iris_df = pd.DataFrame(iris.data, columns=iris.feature_names)
fig, axes = plt.subplots(ncols=2, figsize=(12, 4))
joyplot(iris_df, ax=axes[0])
joyplot(iris_df, ax=axes[1])

I expect to get two of the same plot, side by side. Instead, I get one plot that takes up the entire figure. So it appears joyplot is ignoring the Axis being passed in.

Versions:

python==3.6.1
joypy==0.1.7
scipy==1.0.0
numpy==1.13.3
matplotlib=2.1.1
@leotac
Copy link
Owner

leotac commented Mar 30, 2018

Yeah, passing an axis is only half-working at the moment, I didn't fully implement it.

You can get something working by passing a list of axis with the same length of the data you want to plot -- in this example, I'm passing two dataframes with 3 columns each, and for each function call, I'm passing the 3 axes where the plot will be drawn.

f, axes = plt.subplots(3,2)
first_column = [axes[i][0] for i in range(3)]
second_column = [axes[i][1] for i in range(3)]

joypy.joyplot(df[["Monday","Tuesday","Wednesday"]], ax=first_column)
joypy.joyplot(df[["Thursday", "Friday", "Saturday"]], ax=second_column)

This does work, in a way; however, the ticks on the x axis will be off, like this:

download

Indeed the x ticks are those of the second plot, that are applied to the whole fig.
At some point I implemented a workaround to get things working, if I find the time I'll push it.

@mkkubins
Copy link

mkkubins commented Jul 26, 2021

Hi!
I am trying to do subplots and I have question if there is possibility to get rid of this strange x axis becasue I dont know how to turn it off or how to replace this somethow to work.
image

font=12
f, axes = plt.subplots(19,4,figsize=(15, 6))
first_column = np.array([axes[i][0] for i in range(19)])
second_column = np.array([axes[i][1] for i in range(19)])
third_column = np.array([axes[i][2] for i in range(19)])
fourth_column = np.array([axes[i][3] for i in range(19)])

joyplot(sub_list[0], ax=first_column,color=colors[stim[0]],overlap=1,xlim=None)
plt.figtext(0.09,0.92,stim[0],fontweight='bold',fontsize=font) 
joyplot(sub_list[1], ax=second_column,color=colors[stim[1]],overlap=1,ylabels=False)
plt.figtext(0.35,0.92,stim[1],fontweight='bold',fontsize=font) 
joyplot(sub_list[2], ax=third_column,color=colors[stim[2]],overlap=1,ylabels=False)
plt.figtext(0.59,0.92,stim[2],fontweight='bold',fontsize=font)
joyplot(sub_list[3], ax=fourth_column,color=colors[stim[3]],overlap=1,ylabels=False)
plt.figtext(0.82,0.92,stim[3],fontweight='bold',fontsize=font)
plt.xticks(ticks=None)

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

3 participants