0

I have a Pandas DataFrame and I have a particular column that I would like to plot as a boxplot with another column made of values. The dataframe is a made of 49609 observations but the column of interest is made of 79 unique features.

Here is my attempt to do this:

sns.boxplot(x="values", y="column_of_interest",data=df)

But the axes are joined together too closely

1
  • You could try and aggregate those categories down, for example take top 20-30 by some metric of interest, and combine all others into an "other" category before plotting. Commented Mar 10, 2020 at 14:36

2 Answers 2

1

One of the first things you can do is call the following and play around with the height parameters to make the y-axis labels less crowded.

plt.figure(figsize=(<new_width>,<new_height>))

Depending on the characteristics of the values you're working with, it could also be helpful to develop some kind of abbreviated column that allows you to identify those unique values with less text.

Other than that, we would need to know what the axes are supposed to represent and what you're trying to learn from it to know if another visualization might be a better solution for you.

Sign up to request clarification or add additional context in comments.

2 Comments

I am trying to learn the price distribution. I was also thinking about a swarmplot with seaborn
In that case, I'd say that a swarm plot isn't great for this many values. In general, you're not going to find a good way to view this many visualizations in a compact space. That being said, I'd recommend using violinplots. You can read this documentation to find some variables to adjust to make each plot element more compact. From an EDA perspective rather than a python one, are there larger groups that these values can fit into?
0

It would be a lot more helpful if you posted an actual sample of your actual dataframe. Without real data, I suspect that it would probably be something like this.

data = df.groupby(['Values', 'Interest'])

Then.

sns.boxplot([data.y, data.x])

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.