Questions tagged [seaborn]

1

votes
1

answer
215

Views

Matplotlib x-axis overcrowded label rendering

I'm trying to simply plot a numpy array but I'm having troubles, especially with getting the number of ticks and labels right on the x-axis. I'm dealing with an array named percents that looks like this: percents: -74 0.000041 -61 0.000041 -60 0.000041 -59 0.000041 -57 0.000041 ... 71...
SpicyClubSauce
1

votes
2

answer
1k

Views

Error in Python Code when plotting in Seaborn

I am trying to plot distribution graph in python using seaborn . But I am getting error which I am not able to solve given below. Code: sns.distplot(df['nn']) error: cannot convert float NaN to integer Is there any efficient way to solve this by plotting histogram and the distribution.
Zhoe
1

votes
0

answer
8

Views

Issues with seaborn.catplot

I am a beginner in Python (using Python 3.7 in Spyder 3.3.2 and Anaconda Navigator 1.9.6). I have no problem creating seaborn violin plots, but the moment I try to Facetgrid them I run into issues. I tried using catplot. Here is my violin plot code (it works): # Libraries import seaborn as sns impo...
arm
-3

votes
1

answer
28

Views

Python put add sentence as image in matplotlib

I have a text: "Hello world" and a heat map as a 2d-array. I want to draw the text as a graph in order to put the heatmap on top of it. So, my question is how to convert the string "Hello world" to an image in order to plot it? For example, I want to create this .png:
okuoub
1

votes
1

answer
1.2k

Views

How to plot a FacetGrid scatter plot with multiple data frames?

I have 2 dataframes, 1 has training data and the other has labels. There are 6 features/columns in the training data and 1 column in the labels data frame. I want 6 plots in my facet grid - all of them to be a scatter plot. So feature 1 vs label, feature 2 vs label, feature 3 vs label, feature 4 vs...
BigBoy1337
1

votes
2

answer
528

Views

Share axis and remove unused in matplotlib subplots

I want to plot a series of seaborn heatmaps in a grid. I know the number of subplots (which can be odd or even). The heatmaps will show the mean "occupation ratio" by "day of week" (y axis) and "hour of day" (x axis), e.g. they all share the same x / y domains. Here's my current code: df2 = df[['nam...
Florian Georg
1

votes
1

answer
1k

Views

seaborn: despine plots by default

matplotlib.pyplot.figure() .... seaborn.despine(offset=10) The despine function of seaborn offsets the axis spines from the plot, which looks quite nice. The function needs to be called after the code that plots a figure. However, I would like this to be the default for any plot, at least any seabor...
clstaudt
1

votes
2

answer
1.6k

Views

is seaborn confidence interval computed correctly?

First, I must admit that my statistics knowledge is rusty at best: even when it was shining new, it's not a discipline I particularly liked, which means I had a hard time making sense of it. Nevertheless, I took a look at how the barplot graphs were calculating error bars, and was surprised to find...
anarcat
1

votes
1

answer
632

Views

seaborn how to set both style and font size

I am trying to change both style and font size like this sns.set_style("whitegrid") sns.set(font_scale=1.5) But it seems that both are mutually exclusive. I can use only one of the lines at a time. How to make both changes apparent?
LetzerWille
1

votes
1

answer
1.3k

Views

Change seaborn pair plot figure size

I have the following code sns.pairplot(data=train, x_vars=['x'], y_vars=['y']) plt.show() and I am programming in jupyter notebook if that makes any difference, I want to plot a much larger figure of the plot but I cannot do it. I search the internet and the documentation mention to use the height...
JDOE
1

votes
1

answer
1.2k

Views

Seaborn pairplot hue parameter not working as expected

If "C" was assigned as value for the "hue" parameter, it was expected Seaborn not displayed column "C". Am I wrong? sns.pairplot(df, hue='C') DataFrame:
Daniel Silva
1

votes
2

answer
35

Views

Avoid pandas change plot colors when using **kwds

I´m working on some EDA with python using pandas to make the plots. The default forman for the plots looks like this: But if I made some more complex filtering, like this: s = (coupon_list[[ 'USABLE_DATE_MON', 'USABLE_DATE_TUE', 'USABLE_DATE_WED', 'USABLE_DATE_THU', 'USABLE_DATE_FRI', 'USABLE_DATE_...
1

votes
1

answer
5k

Views

Matplotlib / Seaborn barplot--strings in x axis

Maybe I am too used to R's wonderful ggplot-idiom when doing faceted charts (it takes numeric and string variables without protest) but the ideal way outside ggplot has certainly eluded me for some time getting to know the matplotlib world. I am typically faceting a lot of bar charts by several dime...
ako
1

votes
2

answer
139

Views

How to print values/scale on the y-axis of a bar plot

This is what I have done so far. My problen, however, is that I can't print the values/scale on the y-axis of a bar plot? Any ideas? What other stylings whould I add? import seaborn as sb from matplotlib import pyplot %matplotlib inline sb.axes_style("white") sb.set_style("ticks") sb.set_context("ta...
user706838
1

votes
1

answer
1.9k

Views

coefficient plot in python

I am trying to find a nice way to plot the linear model coefficient in python and I got the following: import statsmodels.formula.api as sm import seaborn as sns import matplotlib as mpl import matplotlib.pyplot as plt f = 'change ~ close_r + close_f + close_f1 + close_f2 + gender + age + country_of...
amaatouq
1

votes
1

answer
1.3k

Views

How to make a centered bubble chart in python/matplot lib

I'm trying to make a centered bubble chart in matplotlib / python similar to this. Some people have called it a "bottom aligned bubble chart", So far, I've basically found a way to do a concentric circle scatter plot. %matplotlib inline import matplotlib.pyplot as plt s = [ 50000.,10478.2, 4733.4,3...
OttoS
1

votes
1

answer
2.7k

Views

Changing seaborn style in subplots

I'm trying to change the styles of two plots that are in the same figure: import numpy as np from numpy.random import randn import matplotlib as mpl import matplotlib.pyplot as plt import seaborn as sns fig, (ax1, ax2) = plt.subplots(nrows=1, ncols=2, figsize=(15,6)) data = randn(7500); sns.set_styl...
theQman
1

votes
1

answer
632

Views

Row based chart plot (Seaborn or Matplotlib)

Given that my data is a pandas dataframe and looks like this: Ref +1 +2 +3 +4 +5 +6 +7 2013-05-28 1 -0.44 0.03 0.06 -0.31 0.13 0.56 0.81 2013-07-05 2 0.84 1.03 0.96 0.90 1.09 0.59 1.15 2013-08-21 3 0.09 0.25 0.06 0.09 -0.09 -0.16 0.56 2014-10-15 4 0...
hernanavella
1

votes
2

answer
3.9k

Views

Seaborn: how to set bar borders' line width or color?

I am trying to draw a barplot with bars with no borders. By default bars has thin black borders. In the devlopment version (0.6) of Seaborn, I could pass kwargs (linewidth, edgecolor) to pyplot.bar() via seaborn.barplot(), but in the current version (0.5.1) this feature seems not yet available. Look...
deeenes
1

votes
1

answer
866

Views

Plotting Pandas: Grouped line chart

I have a pandas dataframe in the following format: groups value 1 0 0 0 0 0 0 0.1 1 0.4 1 0.5 0 0.5 1 0.8 0 0.8 1 0.9 1 1 1 1 1 1 1 1 0 1 0 1 I want a sorted line plot that has the value in the y-axis, a...
Klaster
1

votes
3

answer
15k

Views

Bar chart in seaborn

I am working with seaborn, and trying to make my bar chart look better. import numpy as np import matplotlib.pyplot as plt import seaborn as sns x = ['One', 'Two', 'Three', 'Four', 'Five'] y = [2, 3, 0, 4.5, 4] y2 = [0, 0, -5, 0, 0] sns.axes_style('white') sns.set_style('white') b = sns.barplot(x,y,...
AK9309
1

votes
1

answer
2.7k

Views

How to change color of certain squares in a seaborn heatmap?

I'm trying to create a heatmap in seaborn (python) with certain squares colored with a different color, (these squares contain insignificant data - in my case it will be squares with values less than 1.3, which is -log of p-values >0.05). I couldn't find such function. Masking these squares also did...
Ilona
1

votes
2

answer
1.6k

Views

how to change assignment of colors to labels from palette in python Seaborn?

how can you change the order of colors used by seaborn? example: import seaborn as sns import pandas data = pandas.DataFrame({"x": [1,2,3], "y": [1,1,1], "color": ["a", "b", "c"]}) sns.pointplot(x="x", y="y", hue="color", data=data) how can the assignment of colors from the default palette, in "hue"...
lgd
1

votes
1

answer
257

Views

inconsistent plot between matplotlib and seaborn in Python

i am trying to add errorbars using plt.errorbar to a pointplot in seaborn: import matplotlib import matplotlib.pylab as plt import seaborn as sns import pandas sns.set_style("white") data = pandas.DataFrame({"x": [0.158, 0.209, 0.31, 0.4, 0.519], "y": [0.13, 0.109, 0.129, 0.250, 1.10], "s": [0.01]*5...
lgd
1

votes
2

answer
1.8k

Views

Plotting categorical data into a single bar plot of relative frequency with python/pandas/seaborn

I have a bunch of categorical data from a survey and I would like to plot it in the same way as shown here. Effectively it is a bar shaped pie chart. The data is in a pandas data frame, and here is a toy example of what I've tried to do: import pandas as pd import seaborn as sns import matplotlib.py...
alexabate
1

votes
3

answer
8.6k

Views

Python: Plotting percentage in seaborn bar plot

For a dataframe import pandas as pd df=pd.DataFrame({'group':list("AADABCBCCCD"),'Values':[1,0,1,0,1,0,0,1,0,1,0]}) I am trying to plot a barplot showing percentage of times A, B, C, D takes zero (or one). I have a round about way which works but I am thinking there has to be more straight forward...
PagMax
1

votes
1

answer
343

Views

How to align y labels in a Seaborn PairGrid

Taken from the documentation: >>> import matplotlib.pyplot as plt >>> import seaborn as sns; sns.set() >>> iris = sns.load_dataset("iris") >>> g = sns.PairGrid(iris) >>> g = g.map(plt.scatter) How can I align y labels? What I tried: for ax in g.axes.flat: ax.yaxis.labelpad = 20 However, that only sh...
Xiphias
1

votes
1

answer
65

Views

Seaborn Heatmap without lines between cells

I´m trying to create a heatmap with seaborn with a transparent colormap since an image should be displayed in the background. The heatmap creation works fine so far, however some lines between the cells are still visible even though the linewidth of the heatmap is set to 0.0. The code for the creat...
Maximilian Speicher
1

votes
1

answer
33

Views

Seaborn swarmplot of grouped dataframe

When I have a dataframe likes this here: import pandas as pd import seaborn as sns import random random.seed(0) df = pd.DataFrame({"Data":[random.random() for i in range(100)], "Cluster":[random.randint(0,10) for i in range(100)]}) I can easily plot the clusters with seaborn as boxplots: sns.boxplot...
F. Jehn
2

votes
0

answer
97

Views

Add seaborn.palplot axes to existing figure for visualisation of different color palettes

Adding seaborn figures to subplots is usually done by passing 'ax' when creating the figure. For instance: sns.kdeplot(x, y, cmap=cmap, shade=True, cut=5, ax=ax) This method, however, doesn't apply to seaborn.palplot, which visualizes seaborn color palettes. My goal is to create a figure of differen...
David de L.
3

votes
2

answer
12.9k

Views

Seaborn pairplot and NaN values

I'm trying to understand why this fails, even though the documentation says: dropna : boolean, optional Drop missing values from the data before plotting. from matplotlib import pyplot as plt import numpy as np import pandas as pd import seaborn as sns sns.__version__ # '0.7.dev' # generate an examp...
Diziet Asahi
11

votes
1

answer
8.5k

Views

Set Max value for color bar on seaborn heatmap

I need to set the max value on the seaborn heatmap cbar to 2. I've tried: cbar_kws = { 'ticks' : [0, 2] } sns.heatmap(tiles, robust=True, fmt="f", cmap= 'RdBu_r', cbar_kws = cbar_kws) But this doesn't work and the documentation isn't very clear. How would I do this properly?
Michael Berry
3

votes
1

answer
1.9k

Views

pandas and seaborn - heatmap with no colors

I've been working with seaborn and its heatmap function. I would like to build a matrix with annotated values from pandas dataframe df: C,L,N a,x,10 a,y,2 a,z,4 b,x,1 b,y,22 b,z,11 c,x,3 c,y,1 c,z,0 So far it worked fine with: # Read DataBase df = pd.read_csv('myfile.csv') # Save Users/City/Language...
Fabio Lamanna
1

votes
2

answer
1.4k

Views

Weighted bins in a distribution hist plot

I'm looking for a way to plot a distribution histogram, with the y-axis representing the total number of items for each bin (and not just the count). Example on the charts below: On the left, there are 55 agencies who sold between 20-30 houses On the right, the agencies having sold between 20-30 hou...
Jivan
1

votes
1

answer
4.3k

Views

Horizontal barplot in Seaborn using dataframe

I am struggling with barplots in seaborn and I am not sure what I am doing wrong. The data is very simple: name totalCount Name1 2000 Name2 40000 Name3 50000 sns.barplot(x='name',y='totalCount',data=df) produces a bar plot that has mean(totalCount) instead of the actual count. sns.count...
Anastasia
1

votes
1

answer
1.5k

Views

Plot dotted line in seaborn factorplot

import seaborn as sns sns.set(style="ticks") exercise = sns.load_dataset("exercise") g = sns.factorplot(x="time", y="pulse", hue="kind", data=exercise) In the plot above, is there a way to plot one of the line types as a dotted line, e.g. plot the 'rest' line as dotted.
user308827
-1

votes
0

answer
18

Views

How to plot percentage of whole in pandas?

I have a dataframe that looks like the following: I want to plot in bars the percentage of the people who sidestepped (Sidestepped == 1). ObstacleInterspace are just 4 categories: 0.0, 0.50, 0.75, 1.70 Sex is just 'm' or 'f' So if at ObstacleInterspace 0.0, all female sidestepped (1), this would b...
ZelelB
0

votes
0

answer
9

Views

Calculating % in Pivot table - python

PS;- I tried fitting the outputs below here but didn't show nicely and it doesn't allow me to embed images hence he link . Problem - I am trying to calculate % win for a team against other team in game of cricket using python pivot table . I need to divide count of wins / count of matches . I got co...
kkoc3
2

votes
1

answer
1.1k

Views

How to use a weighted mean estimator in seaborn factor plot (incl bootstrapping)?

I have a dataframe where each of the rows has a certain weight which needs to be accounted for in the mean computations. I love seaborn factorplots and their bootstrapped 95% confidence intervals but haven't been able to get seaborn to accept a new weighted mean estimator. Here is an example of what...
Tim
1

votes
1

answer
48

Views

How to make Pareto Chart in python?

Pareto is very popular diagarm in Excel and Tableu. In excel we can easily draw a Pareto diagram but I found no easy way to draw the diagram in Python. I have a pandas dataframe like this: import numpy as np import pandas as pd import seaborn as sns import matplotlib.pyplot as plt df = pd.DataFrame(...
astro123

View additional questions