0

I am trying to visualize some data and have built a scatter plot with this code -

sns.regplot(y="Calls", x="clientid", data=Drop)

This is the output -

enter image description here

I don't want it to consider the x-axis. I just want to see how the data lie w.r.t y-axis. Is there a way to do that?

10
  • You are performing a fit with regplot. If there is no x data, no fit can be produced. Can you explain more in detail what you are trying to achieve? Commented Jan 23, 2019 at 1:21
  • @ImportanceOfBeingErnest I want to find groups in data. As you can see, 0-5 looks like 1 group. 5-12 looks like another group. 13-20 also look like they can form a group. Commented Jan 23, 2019 at 1:24
  • I don't feel that answers my question. What is the reason to use a regplot here? What do you want to fit if only a single variable is present? Commented Jan 23, 2019 at 1:32
  • @ImportanceOfBeingErnest I don't want to fit anything. I just want a scatter plot of the y-axis. Commented Jan 23, 2019 at 1:33
  • 1
    Maybe you want plt.scatter(y="Calls", x=numpy.ones(len(Drop)), data=Drop)? Commented Jan 23, 2019 at 2:25

1 Answer 1

2

As @iayork suggested, you can see the distribution of your points with a striplot or a swarmplot (you could also combine them with a violinplot). If you need to move the points closer to the y-axis, you can simply adjust the size of the figure so that the width is small compared to the height (here i'm doing 2 subplots on a 4x5 in figure, which means that each plot is roughly 2x5 in).

fig, (ax1,ax2) = plt.subplots(1,2, figsize=(4,5))
sns.stripplot(d, orient='vert', ax=ax1)
sns.swarmplot(d, orient='vert', ax=ax2)
plt.tight_layout()

enter image description here

However, I'm going to suggest that maybe you want to use distplot instead. This function is specifically created to show the distribution of you data. Here i'm plotting the KDE of the data, as well as the "rugplot", which shows the position of the points along the y-axis:

fig = plt.figure()
sns.distplot(d, kde=True, vertical=True, rug=True, hist=False, kde_kws=dict(shade=True), rug_kws=dict(lw=2, color='orange'))

enter image description here

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

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.