joypy icon indicating copy to clipboard operation
joypy copied to clipboard

Passing `ax` ignores axis and uses entire plot

Open macks22 opened this issue 8 years ago • 2 comments

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

macks22 avatar Jan 12 '18 12:01 macks22

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.

leotac avatar Mar 30 '18 11:03 leotac

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)

mkkubins avatar Jul 26 '21 11:07 mkkubins