seaborn

Is there a way to apply hue ONLY to lower part of PairGrid in seaborn

|▌冷眼眸甩不掉的悲伤 提交于 2020-01-25 08:44:25
问题 I was wondering if it was possible to apply hue to only the lower part of a seaborn PairGrid . For example, say I have the following figure: For what I need to present I'd like to keep the density plots on the diagonal, the overall scatter plots on the upper (with printed correlation coefficients above them which I know how to do), but on the lower I want to split the points up by hue just to show my audience what happens if we do subset the data. I thought about just finding out the

Seaborn boxplot quartile calculation

陌路散爱 提交于 2020-01-25 08:29:05
问题 i am using seaborn version 0.7.1 for python. I am trying to create a boxplot for the below numpy array arr = np.array([2, 4, 5, 5, 8, 8, 9]) from my understanding the Quartiles Q1 and Q3 should be 4 and 8 but from the boxplot generated the Q1 is approximately 4.5. What am i missing ? i am using the follwing command to generate the chart sns.boxplot(arr) 回答1: It would of course depend on the definition of a quartile. Wikipedia mentions 3 methods to calculate the quartile, method1: Take median

Position of text automatically changes on graph

若如初见. 提交于 2020-01-25 07:59:04
问题 I have a function that generates graph based on values in a dataframe. The code looks like: def generate_graph(data, title): df1 = data['User'].value_counts(sort=False).to_frame() plt.figure(figsize=(24, 12)) graph = sns.barplot(x=df1.index,y=df1.User) graph.set_ylabel('ABC ',fontsize=25) i = 0 for p in graph.patches: height = p.get_height() graph.text(p.get_x()+p.get_width()/2., height - 0.1, df1['User'][i], ha="center", fontsize=15) Now, I call this function for multiple dataframes:

Why is there unnecessary whitespace while plotting figures with pandas, matplotlib and seaborn? [duplicate]

走远了吗. 提交于 2020-01-25 06:41:04
问题 This question already has an answer here : How can I change the x axis in matplotlib so there is no white space? (1 answer) Closed 7 days ago . Whenever I plot figures using matplotlib or seaborn, there is always some whitespace remaining at the sides of the plot and the top and bottom of the plot. The (x_0,y_0) is not in the bottom left corner, x_0 is offset a little bit to the right and y_0 is offset a little bit upwards for some reason? I will demonstrate a quick example below with the

Why is there unnecessary whitespace while plotting figures with pandas, matplotlib and seaborn? [duplicate]

蓝咒 提交于 2020-01-25 06:40:11
问题 This question already has an answer here : How can I change the x axis in matplotlib so there is no white space? (1 answer) Closed 7 days ago . Whenever I plot figures using matplotlib or seaborn, there is always some whitespace remaining at the sides of the plot and the top and bottom of the plot. The (x_0,y_0) is not in the bottom left corner, x_0 is offset a little bit to the right and y_0 is offset a little bit upwards for some reason? I will demonstrate a quick example below with the

How to put multiple median values in the boxplot?

家住魔仙堡 提交于 2020-01-24 19:39:25
问题 I only found the code can put median in boxplot and I tried it. But since my boxplot is multiple, so it unable to get the x-tick get locator. How can I find the minor tick locator of the boxplot, I already tried it yet still cannot get the location of multiple boxplot location. Any suggestion to improve this plot? df = pd.DataFrame([['Apple', 10, 'A'],['Apple', 8, 'B'],['Apple', 10, 'C'], ['Apple', 5, 'A'],['Apple', 7, 'B'],['Apple', 9, 'C'], ['Apple', 3, 'A'],['Apple', 5, 'B'],['Apple', 4,

stacked bar chart using seaborn and matplotlib

坚强是说给别人听的谎言 提交于 2020-01-24 17:07:26
问题 I am new to pandas and matplotlib and trying to accomplish following. I have a data frame as shown below which is actually a listing the performance of players based on match date name runs match_date player_id Dockrell, G H 0 2018-06-17 3752 Stirling, P R 81 2018-06-17 3586 O'Brien, K J 28 2018-06-17 3391 McCarthy, B J 0 2018-06-17 4563 Poynter, S W 0 2018-06-17 4326 Poynter, S W 2 2018-06-17 4326 McCarthy, B J 0 2018-06-17 4563 Shannon, J N K 5 2018-06-17 4219 Shannon, J N K 6 2018-06-17

Violin plot for positive values with python

对着背影说爱祢 提交于 2020-01-24 12:29:06
问题 I find violin plots very informative and useful, I use python library 'seaborn'. However, when applied to positive values, they nearly always show negative values at the lower end. I find this really misleading, especially when working with real-life datasets. In the official documentation of seaborn https://seaborn.pydata.org/generated/seaborn.violinplot.html one can see examples with "total_bill" and "tip" which can not be negative. The violin plots show negative values, however. For

Ordering and Formatting Dates on X-Axis in Seaborn Bar Plot

 ̄綄美尐妖づ 提交于 2020-01-24 11:20:30
问题 This seems so simple, but for the life of me I can't figure it out. I am new to Python and Seaborn, and I am doing all this online at PythonAnywhere. All I am trying to do is create a simple barplot in seaborn, with dates ordered properly (that is, ascending from left to right), on the x-axis. When I try this: import matplotlib.pyplot as plt import matplotlib.dates as mdates import datetime import pandas as pd import seaborn as sns emp = pd.DataFrame([[32, "5/31/2018"], [3, "2/28/2018"], [40,

How to change the scatter transparency in Seaborn.pairplot?

对着背影说爱祢 提交于 2020-01-24 10:09:31
问题 sns.pairplot(data_new, kind="scatter", hue="location", plot_kws=dict(s=80, edgecolor="white", linewidth=2.5)) Hey folks, can someone tell me how to change the scatter transparency(alpha should be 0.3) following my code above? Thank you very much! 回答1: You are already using plot_kws to pass in parameters to the plotting function. Therefore, alpha is simply another parameter you can add to this dictionary: sns.pairplot(data_new, kind="scatter", hue="location", plot_kws=dict(s=80, edgecolor=