seaborn

How to plot a mean line on a distplot between 0 and the y value of the mean?

别来无恙 提交于 2020-12-06 04:16:26
问题 I have a distplot and I would like to plot a mean line that goes from 0 to the y value of the mean frequency. I want to do this, but have the line stop at when the distplot does. Why isn't there a simple parameter that does this? It would be very useful. I have some code that gets me almost there: plt.plot([x.mean(),x.mean()], [0, *what here?*]) This code plots a line just as I'd like except for my desired y-value. What would the correct math be to get the y max to stop at the frequency of

How to change the X axis range in seaborn in python?

|▌冷眼眸甩不掉的悲伤 提交于 2020-12-02 08:20:09
问题 By default the seaborn displaces the X axis ranges from -5 to 35 in distplots. But I need to display the distplots with the X axis ranges from 1 to 30 with 1 unit. How can I do that? 回答1: For the most flexible control with these kind of plots, create your own axes object then add the seaborn plots to it. Then you can perform the standard matplotlib changes to features like the x-axis, or use any of the normal controls available through the matplotlib API. import matplotlib.pyplot as plt

How to change the X axis range in seaborn in python?

血红的双手。 提交于 2020-12-02 08:18:49
问题 By default the seaborn displaces the X axis ranges from -5 to 35 in distplots. But I need to display the distplots with the X axis ranges from 1 to 30 with 1 unit. How can I do that? 回答1: For the most flexible control with these kind of plots, create your own axes object then add the seaborn plots to it. Then you can perform the standard matplotlib changes to features like the x-axis, or use any of the normal controls available through the matplotlib API. import matplotlib.pyplot as plt

Turn off marginal distribution axes on jointplot using seaborn package

有些话、适合烂在心里 提交于 2020-12-01 06:15:03
问题 I like this particular plot and the ability to pass a function to the stat_func keyword to quickly plot up and visualize relationships between variables, but there's one thing. How do I 'turn off' or not plot the marginal distribution axes? It looks nice but sometime I don't want this feature. For example using this code: import numpy as np import seaborn as sns x = np.arange(100) + np.random.randn(100)*20 y = np.arange(100) + np.random.randn(100)*20 sns.jointplot(x, y, kind='reg') How can I

Turn off marginal distribution axes on jointplot using seaborn package

放肆的年华 提交于 2020-12-01 06:15:01
问题 I like this particular plot and the ability to pass a function to the stat_func keyword to quickly plot up and visualize relationships between variables, but there's one thing. How do I 'turn off' or not plot the marginal distribution axes? It looks nice but sometime I don't want this feature. For example using this code: import numpy as np import seaborn as sns x = np.arange(100) + np.random.randn(100)*20 y = np.arange(100) + np.random.randn(100)*20 sns.jointplot(x, y, kind='reg') How can I

Turn off marginal distribution axes on jointplot using seaborn package

元气小坏坏 提交于 2020-12-01 06:14:01
问题 I like this particular plot and the ability to pass a function to the stat_func keyword to quickly plot up and visualize relationships between variables, but there's one thing. How do I 'turn off' or not plot the marginal distribution axes? It looks nice but sometime I don't want this feature. For example using this code: import numpy as np import seaborn as sns x = np.arange(100) + np.random.randn(100)*20 y = np.arange(100) + np.random.randn(100)*20 sns.jointplot(x, y, kind='reg') How can I

Matplotlib loop through axes in a seaborn plot for multiple subplots

别说谁变了你拦得住时间么 提交于 2020-11-30 00:09:04
问题 I'd like to create five subplots (one for each category in a specific column of a dataframe) on a seaborn histogram (distplot). My dataset is: prog score cool 1.9 cool 3.7 yay 4.5 yay 2.6 neat 1.4 neat 7 neat 6 wow 4.1 wow 1.7 wow 1.4 hooray 6.6 hooray 5.6 hooray 4.9 yikes 1.2 yikes 3.9 yikes 6.9 I don't want all of the 'prog's plotted, just each in a list: prog_list = ['cool', 'yay', 'neat', 'yikes', 'wow'] scores = df['score'] f, axes = plt.subplots(3, 2, figsize=(15, 15)) # Delete last

Matplotlib loop through axes in a seaborn plot for multiple subplots

纵然是瞬间 提交于 2020-11-30 00:08:16
问题 I'd like to create five subplots (one for each category in a specific column of a dataframe) on a seaborn histogram (distplot). My dataset is: prog score cool 1.9 cool 3.7 yay 4.5 yay 2.6 neat 1.4 neat 7 neat 6 wow 4.1 wow 1.7 wow 1.4 hooray 6.6 hooray 5.6 hooray 4.9 yikes 1.2 yikes 3.9 yikes 6.9 I don't want all of the 'prog's plotted, just each in a list: prog_list = ['cool', 'yay', 'neat', 'yikes', 'wow'] scores = df['score'] f, axes = plt.subplots(3, 2, figsize=(15, 15)) # Delete last

Labeling horizontal barplot with values in Seaborn

廉价感情. 提交于 2020-11-28 02:38:46
问题 I have a horizontal barplot, for example, a simplified version of the example from the seaborn documentation: https://seaborn.pydata.org/examples/horizontal_barplot.html import seaborn as sns import matplotlib.pyplot as plt f, ax = plt.subplots(figsize=(6, 15)) crashes = sns.load_dataset("car_crashes").sort_values("total", ascending=False) sns.barplot(x="total", y="abbrev", data=crashes, label="Total", color="b") ax.set(xlim=(0, 24), ylabel="", xlabel="Automobile collisions per billion miles"

Python数据可视化-seaborn Iris鸢尾花数据

别来无恙 提交于 2020-11-25 05:54:24
原文链接:http://tecdat.cn/?p=5261 首先介绍一下Iris鸢尾花数据集,内容摘自百度百科:Iris数据集是常用的分类实验数据集,由Fisher, 1936收集整理。“Iris也称鸢尾花卉数据集,是一类多重变量分析的数据集。数据集包含150个数据集,分为3类,每类50个数据,每个数据包含4个属性。可通过花萼长度,花萼宽度,花瓣长度,花瓣宽度4个属性预测鸢尾花卉属于(Setosa,Versicolour,Virginica)三个种类中的哪一类”。 导入库 读取数据 数据字段介绍: sepal_length:花萼长度,单位cm sepal_width:花萼宽度,单位cm petal_length:花瓣长度,单位cm petal_width:花瓣宽度,单位cm 种类:setosa(山鸢尾),versicolor(杂色鸢尾),virginica(弗吉尼亚鸢尾) 在做categorical visualization的时候,seaborn给出了基础的 stripplot & swarmplot , boxplot & violinplot , barplot & pointplot ,以及抽象化的 factorplot .下面就用纸鸢花数据集做一下讲解。 StripplotStripplot的本质就是把数据集中具有quantitative属性的变量按照类别去做散点图