seaborn

How to add title to seaborn boxplot

点点圈 提交于 2020-12-21 05:30:22
问题 Seems pretty Googleable but haven't been able to find something online that works. I've tried both sns.boxplot('Day', 'Count', data= gg).title('lalala') and sns.boxplot('Day', 'Count', data= gg).suptitle('lalala') . None worked. I think it might be because I'm also working with matplotlib. 回答1: Seaborn box plot returns a matplotlib axes instance. Unlike pyplot itself, which has a method plt.title() , the corresponding argument for an axes is ax.set_title() . Therefore you need to call sns

8.(python)seaborn_visualizationSeaborn与可视化

坚强是说给别人听的谎言 提交于 2020-12-18 02:15:19
文章目录 8.1 一般绘图:factorplot 和 FacetGrid 8.1.1 根据2个维度变量绘图 8.1.2 可以按照第3个维度绘制不同的关系图 8.1.3 可以从折线图切成柱状图 8.1.4 散点图 8.1.5 绘图的同时还做回归 8.1.6 kde密度绘图 8.1.7 按照2个维度展开画图 8.2 pairplot and PairGrid 8.2.1 多个维度两两组合绘图 8.2.2 组合绘图的时候顺便回归一下 8.3 jointplot and JointGrid 8.3.1 联合绘图 8.3.2 联合绘图(加回归) Seaborn与可视化 Seaborn是斯坦福大学出的一个非常好用的可视化包,这一节我们一起来看看这个包和相关的一些用法。 # * coding:utf-8_*_ # 作者 :XiangLin # 创建时间 :12/02/2020 19:45 # 文件 :2-8_seaborn_visualization.py # IDE :PyCharm import numpy as np import warnings warnings . filterwarnings ( 'ignore' ) import pandas as pd import warnings warnings . filterwarnings ( 'ignore' ) import

足球数据处理——数据分析

流过昼夜 提交于 2020-12-16 06:01:12
今天是没有头绪的一天,也是学习的一天。 一、准备工作 刚拿过来数据的时候,以前没有做过这个,所以想了半天,goole怎么做数据关联性分析,看了好多博客,有关于 关联分析介绍 , Apriori(关联分析算法) , 使用Python做关联分析 , 特征工程之特征关联 , 介绍 Scikit-learn几种常用的特征选择方法 , 利用机器学习预测足球比赛 (它的数据要比我们的简单的太多,但是思路不错), 基于关联规则的足球比赛数据分析 , 机器学习里数据预处理及特征工程总结 , Pearson相关系数 , 协方差矩阵、相关矩阵的详细说明 ,看完这些博客后,自己根据老师的要求,尝试着对数据做了一些处理。 二、分析过程 1、先将数据做了中英文替换(方便后续的结果显示,不然中文乱码) 2、选择Person系数做数据特征之间相关性分析 首先,做胜平负对其他特征的关联度,看哪几个和它的关联度大 然后做赔率(剔除胜平负的特征)关联度分析 最后选取几个大联赛单独做关联度分析 import pandas as pd import seaborn as sns import matplotlib.pyplot as plt import numpy as np # 使用pearson 系数关联性分析 # 读取数据 f = open('特征提取结果.csv', encoding='UTF-8') #

How to plot 2 subplots that share the same x-axis

拟墨画扇 提交于 2020-12-15 05:31:34
问题 So currently i have a scatterplot and a kdeplot that i used seaborn library to plot out. Here is how i plotted the graphs: # plot a graph to see the zipcodes vs the density plt.figure(figsize=(16,8)) sns.kdeplot(king['zipcode'], shade=True, legend=False) plt.xlabel('Zipcode') plt.ylabel('Density') plt.figure(figsize=(16,8)) sns.scatterplot(king['zipcode'],king['price']) But when i try to do a subplot, my kdeplot seems to be gone: I tried to do in such a way: f, axarr = plt.subplots(2, sharex

Sort categorical x-axis in a seaborn scatter plot

自闭症网瘾萝莉.ら 提交于 2020-12-15 04:41:26
问题 I am trying to plot the top 30 percent values in a data frame using a seaborn scatter plot as shown below. The reproducible code for the same plot: import seaborn as sns df = sns.load_dataset('iris') #function to return top 30 percent values in a dataframe. def extract_top(df): n = int(0.3*len(df)) top = df.sort_values('sepal_length', ascending = False).head(n) return top #storing the top values top = extract_top(df) #plotting sns.scatterplot(data = top, x='species', y='sepal_length', color =

Make identical matplotlib plots with y-axes of different sizes

梦想的初衷 提交于 2020-12-13 05:42:50
问题 I am trying to make a series of matplotlib plots that plot timespans for different classes of objects. Each plot has an identical x-axis and plot elements like a title and a legend. However, which classes appear in each plot differs; each plot represents a different sampling unit, each of which only contains only a subset of all the possible classes. I am having a lot of trouble determining how to set the figure and axis dimensions. The horizontal size should always remain the same, but the

Changing alpha of a line in seaborn factorplot

狂风中的少年 提交于 2020-12-11 09:07:12
问题 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 code above, how can I change the rest line to an alpha of 0.5? 回答1: Find proper objects of FacetGrid axes with get_children() method and set alpha for lines and markers. To change marker property in legend ( g._legend object) find suitable element of legendHandles and apply set_alpha() method: import seaborn as sns import matplotlib

Selecting colors from Seaborn palette

人盡茶涼 提交于 2020-12-10 08:44:07
问题 I have five distribution plots side by side and usually changed the color of each one using the color property. However, now I want to use Seaborn's husl palette and I can't figure out how to apply a color from the palette to each chart. I'm pretty sure this is something simply I'm just over looking. # sns.set(style="white", palette="muted", color_codes=True) sns.set(style="white", palette="husl", color_codes=True) # Set up the matplotlib figure f, axes = plt.subplots(ncols=5, figsize=(15, 4)

Seaborn Title Position

随声附和 提交于 2020-12-06 07:07:07
问题 The position of my graph title is terrible on this jointplot . I've tried moving the loc = 'left , right , and center but it doesn't move from the position it's in. I've also tried something like ax.title.set_position([3, 15]) based on other suggestions from this site but that also doesn't move it at all. Any suggestions on controlling the location of the title? sns.jointplot(leagueWinners_season['Wins'], leagueWinners_season['Goals'], kind = 'reg', color = 'b') plt.title('Season Winners Goal

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

≡放荡痞女 提交于 2020-12-06 04:17:13
问题 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