Questions tagged [seaborn]

1

votes
1

answer
870

Views

Set custom seaborn color palette using hex codes, and name the colors

My company has a formal color palette so I need to use these colors in my seaborn charts. I would therefore like to set the default seaborn color palette, and give these colors easy-to-use names such as 'p' for purple and 'g' for green. Here is what I have so far for code: # Required libraries impo...
Sean_Calgary
0

votes
1

answer
14

Views

Seaborn and mplcursors

I have some data that I want to plot on a scatter chart, and display the associated label for each point. The data looks like xlist=[1,2,3,4] ylist=[2,3,4,5] labels=['a', 'b', 'c', 'd'] I can plot using Seaborn and tried to use mplcursor, but the displayed labels are the x and y instead of labels....
daydayup
0

votes
0

answer
20

Views

How to plot this type of graph (errorbar)?

I have a dataframe: import pandas as pd import numpy as np df = pd.read_csv(r'https://exploratory.io/data/kanaugust/2016-California-Election-Data-oTv4Hgd1UT/2016%20California%20Election%20Data.csv') df['cluster'] = [3, 3, 1, 2, 1, 1, 3, 1, 1, 2, 1, 3, 2, 1, 1, 1, 2, 1, 3, 1, 3, 1, 3, 2, 1, 2, 3, 3,...
user3225309
1

votes
2

answer
785

Views

Plotting a Pandas series in Matplotlib/seaborn

I am trying an alternate way to visualize a pandas series using matplotlib/seaborn. But I am not able to do it. Is there any way? I have no problem visualizing it using the df.plot() method of pandas. df2.groupby('Company').Company.count() Data looks like this: 100 a 101 b 102 c 103 d 10...
vv4
1

votes
3

answer
41

Views

How to set the range of x-axis for a seaborn pointplot?

I created a pointplot() and I cannot change x-axis limit. Although my data only contains 9 months, I want to show all 12 on my axis. fig,ax = plt.subplots(figsize=(12,4)) sns.pointplot(data=tr_df, x='Month', y='numOfTrips', hue='Year', ax=ax, palette='nipy_spectral') # sns.plt.xlim(0, 12) # Attribu...
Bn.F76
1

votes
2

answer
545

Views

Make seaborn swarmplot width the same as the violin

I am trying to plot a swarplot on top of a violin plot. Is there any way to make the swarm width to be shortened just like the width option from violin plot? Would it be easier to use a matplotlib.scatter to do it instead of seaborn.swarmplot? import seaborn as sns data = pd.read_csv('allparticles....
João Mamede
1

votes
1

answer
1.4k

Views

seaborn modify y axis (log scale) to show more values

I have plotted a boxplot using seaborn, the y axis is uses a log scale (time in miliseconds). I would like to make the y axis more clear by including more values on the axis. How could I achieve that? The code used and the graph generated are below. ax2 = sns.boxplot(x='xVals', y='Time', data=df2, w...
RegUser
1

votes
0

answer
788

Views

Seaborn: Label Outliers on a Box Plot

I have a snippet of python to create a box plot as follows (works great): merged = group.merge(t, left_on=t['user_lower'], right_on=group['user'], how='left') g = sns.boxplot(x='Company', y='Total_Activities',data=merged, orient='v' ) g.set_xticklabels(g.get_xticklabels(),rotation=90) plt.show(g) I'...
user3425900
0

votes
0

answer
8

Views

Creating a tall rectangular heat map while ensuring cells are square shaped

I am trying to create a heat map of a dataframe with a shape (8192, 8). A sample of the dataframe is shown below: df2 Out[58]: Bit0 Bit1 Bit2 Bit3 Bit4 Bit5 Bit6 Bit7 0 1.0 1.0 1.0 1.0 0.0 1.0 1.0 1.0 1 1.0 1.0 1.0 1.0 1.0 0.0 1.0 1.0 2 0.0 1.0...
1

votes
2

answer
190

Views

Python seaborn legends cut off

The figure resulting from the Python code below unfortunately cuts off part of the legends. How can I avoid this? Did I miss a parameter in the sns call or is this due to how I've set up my PyCharm IDE? import pandas as pd import seaborn as sns import matplotlib.pyplot as plt df = pd.read_csv('gm_20...
apitsch
1

votes
0

answer
432

Views

Issue saving plots and text together to a word doc in python

Am fairly new to the python world. Am trying to save/print the output of my SARIMAX model to a word document, and it seems, I cannot save or print the plots/figures in the word doc. Some of the text lines do get printed in the word doc, but not the plots. Can you please advise where I am going wrong...
asimo
1

votes
0

answer
282

Views

Plot Pandas Dataframe with Seaborn

I have a pandas dataframe with a datetime index and column of scores. Pandas Dataframe Index Score 2016-09-01 5 2016-09-15 6 . 2017-01-05 3 . 2017-12-24 2 How can I with seaborn: (1) box plot the scores grouped by month such that the x-axis is continu...
Michael Lam
1

votes
0

answer
1.4k

Views

What can I do to set color palette in seaborn heatmap? [duplicate]

This question already has an answer here: Map value to specific colour in seaborn heatmap 1 answer Seaborn HeatMap - How to set colour grading throughout multiple different datasets 1 answer Instead of default option of cmap, I want to use my own specific colors for the heatmap like: sns.heatmap(d...
Leonard
1

votes
0

answer
287

Views

Right margin seaborn joint plot disappears when adding regression line

Using the tips I got from this question, I'm able to put a regression line on top of a seaborn jointplot. The following snippet creates the plot below: Code 1 import numpy as np import pandas as pd import seaborn as sns sns.set(style='white') # Generate a random correlated bivariate dataset rs = np....
vestland
1

votes
1

answer
249

Views

Python scatterplot design - select specific values of a variable for the x axis based on another columns values

I am relatively new to python and am currently trying to generate a scatterplot based off of some data using pandas & seaborn. The data I'm using ('ErrorMedianScatter') is as follows (apologies for the link, I have yet to get permissions to embed images!): Image of data Each participant has two dat...
MDhar94
1

votes
0

answer
332

Views

Plotting linear regression with Date/Week on x axis using Seaborn

Data my company uses some weird date notation, which has this format: [2 digits week number][2 digit working hours]. Both groups use leading zeros. So the data could like: 0801, 0802, 0901, 0902, 0903, 1001, 1002, 1003 For each of this 'dates' there is a scoring. This is just regular floating number...
Kalaschnik
1

votes
0

answer
616

Views

How do I use colourmaps with variable alpha in a Seaborn kdeplot without seeing the contour lines?

Python version: 3.6.4 (Anaconda on Windows) Seaborn: 0.8.1 Matplotlib: 2.1.2 I'm trying to create a 2D Kernel Density plot using Seaborn but I want each step in the colourmap to have a different alpha value. I had a look at this question to create a matplotlib colourmap with alpha values: Add alpha...
Tim B
1

votes
1

answer
828

Views

How can I add the number of observations to a Seaborn barplot?

I want to add the number of observations to Seaborn barplots. I created a barplot with four bars that represent percentages on the y axis. I want to add a label on each bar showing the number of observations. In my code, the first block creates the barplot. I created the second two blocks of code...
MarkInSF
1

votes
0

answer
358

Views

Changing color scale/gradient vertically in bar like plot using seaborn

I wanted to have vertical gradient for each bar of the seaborn barplot/countplot , #to reproduce above plot import numpy as np import matplotlib.pyplot as plt import seaborn as sns sns.set(style='whitegrid', color_codes=True) np.random.seed(sum(map(ord, 'categorical'))) titanic = sns.load_dataset('t...
vikas_hada
1

votes
0

answer
52

Views

How to insert an object thats not sns as one of the subplots?

I'm working with a Pandas Dataframe in python and want to look at the properties of each column. For each variable, I want to print the distplot, the boxplot, and lastly the description of that variable as a Series. I can perfectly separate my plot in 3 subplots and show the first two plots. Howev...
Carlos Fabbri
1

votes
1

answer
754

Views

distplot() got an unexpected keyword argument 'figsize' [duplicate]

This question already has an answer here: How do I change the figure size for a seaborn plot? 8 answers I am trying to change the figure size of the histogram I am constructing. I'm getting the error: distplot() got an unexpected keyword argument 'figsize' The code I am trying to run is this: sns.d...
1

votes
1

answer
33

Views

Discrepancy between Seaborn plotted mean and calculated mean. (Python/Pandas)

Hello there wonderful people of StackOverflow! I have been getting to grips with Python and was starting to feel pretty confident that I knew what I was doing until this doozy came up: I am plotting and comparing two subselections of a dataframe where 'Type' = 'area' and ''. Seaborn plots a boxplot...
Evin Scully
1

votes
0

answer
77

Views

Python - Incomplete Legend on Subplots

I'm trying to add some legends to two subplots while analysing my target variable. Once I manually add the legends I can only see the first letter on each of the charts. fig, ax = plt.subplots(nrows=1, ncols=2, figsize=(20,10)) # Normal distplot for SalePrice normal = sns.distplot(target, ax=ax[0])...
pablora
1

votes
0

answer
34

Views

Multiple network graph in single plot?

I am trying to plot 2 network graphs in the same plot. I have use the following code: plt.figure(figsize=(20, 20)) df = pd.DataFrame({ 'from':['A','A','A','A'], 'to':['D', 'A', 'E','C']}) G=nx.from_pandas_dataframe(df, 'from', 'to') nx.draw(G, with_labels=True) df1 = pd.DataFrame({ 'from':['S','S','...
user517696
1

votes
1

answer
108

Views

Changing width of heatmap in Seaborn to compensate for font size reduction

I have a sentence like say Hey I am feeling pretty boring today and the day is dull too I pass it through the openai sentiment code which gives me some neuron weights which can be equal or little greater then number of words. Neuron weights are [ 0.01258736, 0.03544582, 0.08490616, 0.09010842,...
1

votes
0

answer
117

Views

Plotting a Seaborn cumulative histogram with pre-binned data

I am using Seaborn to plot cumulative histograms. One of my data sources provides data pre-binned, and I'd like to plot the data in the same style to match the other histograms. The sample data is like this: Value Percentile TotalCount 1/(1-Percentile) 0 939.0 0.000000 1 1.00...
Noah Watkins
1

votes
0

answer
68

Views

How to modify inner style of violin plot in Seaborn Python

I'm plotting violin plot using seaborn. but the color of mini box inside of each violin is arbitrary; black to gray. I want to change the color of inner mini box as well as the line color of whisker. Could you help me out? Thank you in advance!
Ki YoonHee
1

votes
1

answer
43

Views

Inconsistent behavior yticklabels subplot in factorplot using seaborn

When I run the code from the Seaborn API: import seaborn as sns sns.set(style='ticks') exercise = sns.load_dataset('exercise') g = sns.factorplot(x='time', y='pulse', hue='kind', col='diet',data=exercise) I get the following image: However, the image attached to the example in the API looks like t...
Archie
1

votes
0

answer
513

Views

seaborn joyplot does not fill all the way to the top

I'm using seaborn in Python 3.5. Taking the example joy plot from the gallery, modified slightly to save the figure: import numpy as np import pandas as pd import seaborn as sns import matplotlib.pyplot as plt sns.set(style='white', rc={'axes.facecolor': (0, 0, 0, 0)}) # Create the data rs = np.rand...
sammosummo
1

votes
0

answer
398

Views

Using Seaborn split violin plots and palettes

I'm creating a set of grouped violin plots with the following: fig = plt.figure(1) ax1 = fig.add_subplot(3,1,1) sns.violinplot(x='x', y='y1', data=df_y1_all, split=True, inner=None, hue='hues_param', palette={'left':'r','right':'b'}) ax1.legend() ax2 = fig.add_subplot(3,1,2) sns.violinplot(x='x', y=...
Richard Hall
1

votes
0

answer
42

Views

Split Violin with 2 different X Value Scales

For a split violin in Seaborn, is it possible to reference a different X scale for each of the 2 sides of the violin? If so, how is it accomplished?
tommylicious
1

votes
1

answer
957

Views

How to normalize a seaborn countplot with multiple categorical variables

I have created a seaborn countplot for multiple categorical variables of a dataframe but instead of count I want to have percentages? What is the best option to use? Barplots? Can I use a query like the below one to get the barplots at once? for i, col in enumerate(df_categorical.columns): plt.figur...
Ast
-3

votes
0

answer
33

Views

Problems with making a heatmap work in Python

I'm trying to make a heatmap out of a DataFrame. The DataFrame looks like: https://imgur.com/a/K0Davwi I created with data and gathered from the internet. The dataframe's datatypes are: Apr/16/2019 object Apr/17/2019 object Apr/18/2019 object Apr/19/2019 object Apr/20/2019 object Apr/...
Dylaloo
1

votes
1

answer
540

Views

can sns.countplot() show numbers atop the plotted bars?

I'm using MNIST data set and used sns.countplot() to plot the train images, which gave Is there a way to add the values of the bars somewhere? atop each one? inside/ below? Currently I'm seeing the actual values using print and that interferes with the sns.countplot() as the plots are always output...
CIsForCookies
1

votes
0

answer
57

Views

Matplotlib Graph Alignment

I'm trying to graph points vs. penalties in a particular roller derby game. There are 41 jams in the game, but not every jam accrued points or penalties. I want to create a barplot of penalties per team and overlay a scatterplot of points scored per team. The X axis would be the jams, and since t...
Lindsay Gypin
1

votes
0

answer
49

Views

Create boxplots specifying particular range of values from each column seaborn

Bit of a tricky one to explain. I am trying to create two subplots consisting of a histogram and a boxplot, using data from the same dataframe (df), which has two columns (different lengths) 'price_cml15' and 'price_nw15'. When making these graphs I want to select only a subset of the data from each...
1

votes
1

answer
276

Views

How to use scientific notation in Pairplot (seaborn)

Is there a way to force scientific notation using Seaborn's Pairplot? I'm hoping for some consistency between plots (examples below). I've found suggestions for other seaborn plots, but have not successfully implemented anything with Pairplot. https://seaborn.pydata.org/generated/seaborn.pairplot.ht...
allib
1

votes
1

answer
172

Views

Variable spacing of discrete categories in seaborn swarmplot

Is there any way to use non-uniform spacing on a discrete axis in seaborn's swarmplots? Here's an example: import pandas as pd import numpy as np import seaborn as sns data = pd.DataFrame({ 'x':np.concatenate([np.repeat('A',450), np.repeat('B',5), np.repeat('C',5), np.repeat('D',450)]), 'y':np.rando...
Quantum7
1

votes
0

answer
289

Views

Get fitting parameters from seaborn regplot?

seaborn.regplot() fits a linear model to 2D data. It would be very convenient to get the parameters for the linear model returned from the function. However, it only returns an axis object. Is there a way to extract the data from the axis object? Is there a seaborn function that I could call in orde...
Sören
1

votes
0

answer
647

Views

User Warning: The following kwargs were not used by contour: 'label', 'color'

Im trying to create a comparison plot using Seaborn's PairGrid function on my dataset. My data set has 6 columns that I am trying to plot using the scatter() function in my .map_upper segment of the PairGrid function I'm applying to the entire dataframe. Here is a quick peak at my dataframe object;...
cloudenjr

View additional questions