seaborn

The most elegant way to modify messy and overlapping date labels below x axis? (Seaborn, barplot)

送分小仙女□ 提交于 2019-12-24 23:29:55
问题 df (Pandas DataFrame) has two columns: Date (as datetime64) and Amount (as float). I plot the values from Amount column against time, using barplot: sns.barplot(x="Date", y="Amount", data=df) plt.show() However, the date labels are a terrible mess (see picture). What would be an elegant way of dealing with this in Pandas? I'm considering removing month and year from the label, or rotating the labels 90 degrees. How would these be done, or is there a better option? Thank you. 回答1: I would do

Issue in Error bars in Seaborn barplot - Python

左心房为你撑大大i 提交于 2019-12-24 22:25:31
问题 (Have already looked at similar questions but they don't answer this query) I have a dataframe df1 with below structure {'token': {0: '180816_031', 1: '180816_031', 2: '180816_031', 3: '180816_031', 4: '180816_031', 5: '180816_031', 6: '180816_031', 7: '180816_031', 8: '180816_031', 9: '180816_031'}, 'variable': {0: 'Unnamed: 0', 1: 'adj_active_polymerase', 2: 'adj_functional_sequencing_pores', 3: 'adj_high_quality_reads', 4: 'adj_single_pores', 5: 'cell_mask_bilayers_sum', 6: 'num_align_high

Seaborn pairplot error when dataset has NaN values

◇◆丶佛笑我妖孽 提交于 2019-12-24 21:28:23
问题 I have a pandas DataFrame with multiple columns filled with numbers and rows which have the 1st columns categorical data. Obviously, I have NaN values (and zeros) in multiple rows (but not the entire blank row, of course) in different columns, after all, this is Engineering and real data. rows have valuable data in other columns which are not nan. and the columns have valuable data in other rows, which are also not nan Problem is that sns.pairplot does not ignore NaN values for correlation

How can I add a vertical line to a seaborn dist plot where it picks?

China☆狼群 提交于 2019-12-24 21:23:36
问题 How can I add a vertical line at the x-location in which y is on its maximum in a seaborn dist plot? import seaborn as sns, numpy as np sns.set(); np.random.seed(0) x = np.random.randn(5000) ax = sns.distplot(x, kde = False) PS_ In the example above, we know that it's probably going to pick at 0 . I am interested to know how I can find this value in general, for any given distribution of x. 回答1: This is one way to get a more accurate point. First get the smooth distribution function, use it

How can I adjust the spacing between labels in a factorplot in Seaborn

天大地大妈咪最大 提交于 2019-12-24 16:07:28
问题 I've been thoroughly enjoying the amazing combination of Pandas and Seaborn for my data analysis and plotting needs. It's been enough to prevent me from going down the path of learning R just for dataframes and ggplot ;P. I'm having a small issue with the factorplot in seaborn and the way that it places labels on the x-axis. Below is the example that's causing me trouble: Basically, I want to "fix" the x-axis labels so that the final column ">=35" isn't so "squished" (i.e. overlapping the

Bivariate CDF/CCDF Distribution Python

橙三吉。 提交于 2019-12-24 14:46:30
问题 I am trying to plot a bivariate ccdf of the dataset that has x and y values both. Univariate I can plot very well, below is the input and the code is for univeriate dataset. Input: These are only first 20 rows of the data points. Input has 1000s of rows and of which col[1] and col[3] needs to be plotted as they posses a user and keyword frequency relationship. tweetcricscore 34 #afgvssco 51 tweetcricscore 23 #afgvszim 46 tweetcricscore 24 #banvsire 12 tweetcricscore 456 #banvsned 46

Aesthetics of barplot bars and error bars in seaborn

喜欢而已 提交于 2019-12-24 14:40:32
问题 I'm using the seaborn library to visualize data and I want to change some things about the output graphs for publication. I want the error bars to be more narrow, with caps, and I'd like the border around all of the bars to be black. I imagine that there is some way to change the plot using pyplot (or perhaps the rc dictionary in sns.set_context), but I can't figure out how to do this. colors = ["black", "grey", "white"] g = sns.barplot("TYPEMOD", "SCORE", ci=68, data=final_data, palette=sns

How to normalize a seaborn countplot with multiple categorical variables

眉间皱痕 提交于 2019-12-24 12:31:13
问题 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.figure(i) sns.countplot(x=col,hue='Response',data=df_categorical) this query gives me the countplot for all variables at once Thanks! Data looks like this: State Response Coverage Education Effective To

heatmap based on ratios in Python's seaborn

梦想的初衷 提交于 2019-12-24 09:16:20
问题 I have data in Cartesian coordinates. To each Cartesian coordinate there is also binary variable. I wan to make a heatmap, where in each polygon (hexagon/rectangle,etc.) the color strength is the ratio of number of occurrences where the boolean is True out of the total occurrences in that polygon. The data can for example look like this: df = pd.DataFrame([[1,2,False],[-1,5,True], [51,52,False]]) I know that seaborn can generate heatmaps via seaborn.heatmap, but the color strength is based by

Seaborn.countplot : order categories by count, also by category?

假如想象 提交于 2019-12-24 09:01:43
问题 So I understand how to sort in regards to a barchart (ie here). What I can not find though is how to sort the bar charts by one of the subcategories. For example, given the following dataframe, I can get the bar plots. But what I would like to do, is have it sorted from greatest to least, by Type of Classic ). import pandas as pd test_df = pd.DataFrame([ ['Jake', 38, 'MW', 'Classic'], ['John', 38,'NW', 'Classic'], ['Sam', 34, 'SE', 'Classic'], ['Sam', 22, 'E' ,'Classic'], ['Joe', 43, 'ESE2',