Hot answers tagged

19 votes

How to include labels in sns heatmap

I got your problem like this way: You want to show labels on the x and y-axis on the seaborn heatmap. So for that, sns.heatmap() function has two parameters which ...
16 votes
Accepted

How to remove outliers using box-plot?

Seaborn uses inter-quartile range to detect the outliers. What you need to do is to reproduce the same function in the column you want to drop the outliers. It's quite easy to do in Pandas. If we ...
  • 3,770
15 votes
Accepted

seaborn heatmap not displaying correctly

Current version of matplotlib broke heatmaps. Downgrade the package to 3.1.0 pip install matplotlib==3.1.0 matplotlib/seaborn: first and last row cut in half of ...
  • 166
13 votes
Accepted

Meaning of 'hue" in seaborn barplot

In seaborn, the hue parameter determines which column in the data frame should be used for colour encoding. Using the official document for ...
  • 1,128
11 votes

How to deal with TypeError: ufunc 'isnan' not supported for the input types

There may be column of type object in your dataFrame. Remove it or convert it into float,int etc. if possible From Documentation of Seaborn: data : rectangular dataset 2D dataset that can be ...
  • 111
9 votes
Accepted

What is the difference between regplot and lmplot in seaborn?

regplot() performs a simple linear regression model fit and plot. lmplot() combines regplot() and FacetGrid. The FacetGrid class helps in visualizing the distribution of one variable as well as the ...
9 votes

How to remove outliers using box-plot?

If you need to remove outliers and you need it to work with grouped data, without extra complications, just add showfliers argument as False in the function call. ...
  • 243
8 votes
Accepted

Can we remove features that have zero-correlation with the target/label?

Can I drop these features to improve the accuracy of my classification problem? If you are using a simple linear classifier, such as logistic regression then yes. That is because your plots are ...
  • 27.6k
7 votes

How to include labels in sns heatmap

Here's how we can add simple X-Y labels in sns heatmap: s = sns.heatmap(cm_train, annot=True, fmt='d', cmap='Blues') s.set(xlabel='X-Axis', ylabel='Y-Axis') OR <...
  • 71
7 votes
Accepted

Stacked time series plot in python

You can simply use df.plot.area() Found here after a quick google search.
  • 1,872
7 votes

seaborn heatmap not displaying correctly

I had the same problem, solved by moving y axis: ax.set_ylim([0,2])
6 votes

Seaborn Violin plot error No loop for unfunc add

I had tried the suggestion from @foxthatruns's answer to no avail. I found that changing my numeric column to float64 solved the problem (reference). ...
  • 181
6 votes
Accepted

Plot Two Categorical Variables

Well, there are a few ways to do the job. Here are some I thought of: Scatterplots with noise: Normally, if you try to use a scatter plot to plot two categorical features, you would just get a few ...
  • 188
5 votes
Accepted

How to show percentage (text) next to the horizontal bars in matplotlib?

Here is a working example to add a text to the right of horizontal bars: ...
  • 8,667
5 votes
Accepted

Checking for skewness in data

IIUC you can use [DataFrame.hist()] method: ...
4 votes

Can we remove features that have zero-correlation with the target/label?

These uncorrelated features might be important for target in connection with other non-target features. So, it might be not a good idea to remove them, especially if your model is a complex one. It ...
4 votes
Accepted

Why do seaborn.dist and pyplot.hist generate two different looking histograms on the same data?

The first returns a probability density of the distributions. As you can see, they integrate to 1, i.e. they cover the same area (because they are probabilities, not the raw data). The second returns ...
  • 5,697
3 votes

How can I change the transparency of a histogram plot in Seaborn using Pairgrid?

With a pandas dataframe, the following should do it without seaborn: train_df.groupby('Embarked')['Fare'].plot.hist(alpha=0.5) If you have to use seaborn you can ...
  • 6,035
3 votes

Can we remove features that have zero-correlation with the target/label?

If I understand you well, you are asking if you can remove features having zero-correlation either : With other features With the label you want to predict Those are two different cases : 1. We ...
  • 56
3 votes

Unable to generate error bars with seaborn

I found this question when trying to find a way to add my own precalculated, custom error bars (standard deviations) to a Seaborn barplot with grouped values. I finally managed to find a workaround... ...
3 votes

Unable to generate error bars with seaborn

Try this: g = sns.barplot(y="algorithm", x="avg_weightedcost", hue="group", xerr=df[std_weight]*1, capsize=.2, data=df) Hope it helps
3 votes
Accepted

Making Inference from a Correlation Heatmap

Assuming you're using df.corr(), the results from a heatmap are Pearson correlation coefficients which can be thought of as "the explainability between two arrays." ...
3 votes
Accepted

Seaborn subplots massive whitespace

You can move the title closer to the first figure. Just add the following two lines at the end of the code fig.tight_layout() fig.subplots_adjust(top=0.95)
  • 3,770
3 votes
Accepted

Best way to visualize huge amount of data

I have three suggestions that may help. Reduce the point size Make the points highly transparent Downsample the points Since you do not provide any sample data, I will use some random data to ...
  • 293
3 votes
Accepted

Seaborn distplot and KDE data confusion

The difference is caused by the fact that seaborn.distplot and matplotlib.pyplot.hist use different defaults for the number of ...
  • 6,134
2 votes

What is the concept of error bars in barplots in seaborn library?

It appears that even if you don't enter ci argument, it's set to 95 by default in barplot ...
  • 301
2 votes

Meaning of 'hue" in seaborn barplot

This is a good question but it seems none of the answers really answered the question. Simply, in the HSL color system, hue is one of the properties of color which decides what kind of color it looks ...
  • 121
2 votes

How to extract numerical data from a matplotlib scatter plot in python?

You could also show the values for each point by using matplotlibs annotate command: ...
  • 532
2 votes
Accepted

How to barplot output of pandas.describe() from multiple datasets

You need to get used to so called wide and long table format, from there you should get the trick rapidly. By then, I would use unstack in order to have three columns and do something like this: <...
  • 36
2 votes

How do I change the marker edge color of a seaborn relplot?

The issue was with the parameter I was using. The parameter "edgecolors" is incorrect. The correct parameter is the non-plural "edgecolor". So the correct call to relplot is: ...

Only top scored, non community-wiki answers of a minimum length are eligible