seaborn

How to move the legend in Seaborn FacetGrid outside of the plot?

空扰寡人 提交于 2020-08-08 03:39:09
问题 I have the following code: g = sns.FacetGrid(df, row="Type", hue="Name", size=3, aspect=3) g = g.map(sns.plt.plot, "Volume", "Index") g.add_legend() sns.plt.show() This results in the following plot: How can I move the legend outside of the plot? 回答1: You can do this by resizing the plots: g = sns.FacetGrid(df, row="Type", hue="Name", size=3, aspect=3) g = g.map(sns.plt.plot, "Volume", "Index") for ax in g.axes.flat: box = ax.get_position() ax.set_position([box.x0,box.y0,box.width*0.9,box

How to move the legend in Seaborn FacetGrid outside of the plot?

巧了我就是萌 提交于 2020-08-08 03:38:49
问题 I have the following code: g = sns.FacetGrid(df, row="Type", hue="Name", size=3, aspect=3) g = g.map(sns.plt.plot, "Volume", "Index") g.add_legend() sns.plt.show() This results in the following plot: How can I move the legend outside of the plot? 回答1: You can do this by resizing the plots: g = sns.FacetGrid(df, row="Type", hue="Name", size=3, aspect=3) g = g.map(sns.plt.plot, "Volume", "Index") for ax in g.axes.flat: box = ax.get_position() ax.set_position([box.x0,box.y0,box.width*0.9,box

How to move the legend in Seaborn FacetGrid outside of the plot?

蹲街弑〆低调 提交于 2020-08-08 03:38:09
问题 I have the following code: g = sns.FacetGrid(df, row="Type", hue="Name", size=3, aspect=3) g = g.map(sns.plt.plot, "Volume", "Index") g.add_legend() sns.plt.show() This results in the following plot: How can I move the legend outside of the plot? 回答1: You can do this by resizing the plots: g = sns.FacetGrid(df, row="Type", hue="Name", size=3, aspect=3) g = g.map(sns.plt.plot, "Volume", "Index") for ax in g.axes.flat: box = ax.get_position() ax.set_position([box.x0,box.y0,box.width*0.9,box

Changing color of seaborn plot line

这一生的挚爱 提交于 2020-08-07 04:05:21
问题 I cant change color of a 2d line in seaborn. I have 2 lines in my plot and I want to assign different colors for both of them. sns.set(style="whitegrid") data = pd.DataFrame(result_prices, columns=['Size percentage increase']) data2 = pd.DataFrame(result_sizes, columns=['Size percentage increase']) sns_plot = sns.lineplot(data=data, color='red', linewidth=2.5) sns_plot = sns.lineplot(data=data2, linewidth=2.5) sns_plot.figure.savefig("size_percentage_increase.png") But color='red' does not

Python笔记:使用matplotlib,seaborn,plotly,pyecharts绘制同一种图形

|▌冷眼眸甩不掉的悲伤 提交于 2020-08-05 22:27:58
我分别用 matplotlib, seaborn, plotly, pyecharts 这4个库来绘制同一种图形 ① matplotlib import matplotlib matplotlib.__version__ # '2.2.2' import matplotlib.pyplot as plt # import matplotlib as mp1 # 显示中文 plt.rcParams["font.sans-serif"] = [u"SimHei"] # mp1.rcParams["font.family"] = "STFangsong" # plt.rcParams["axes.unicode_minus"] = False # 在线显示matplotlib作出来的图形 %matplotlib inline plt.plot(["周一","周二","周三","周四","周五","周六","周日"], [1, 1.5, 4, -1.2, 0.8, 2.3, -2] ,c='red') plt.bar(["周一","周二","周三","周四","周五","周六","周日"], [2, 3, -1.5, -1.04, 4.2, 3,0.5] ) plt.show() # 保存图片 # plt.savefig(r"C:\Users\QDM\Desktop\混合图.jpg") #

Matplotlib绘图 | 快速定义图表样式的小技巧

久未见 提交于 2020-08-05 03:15:54
Matpltlibrc file 设置图表属性 Matplotlib 在绘图过程中,每创建一个图表,都要对该图表内的样式(例如 字体大小、颜色、分辨率、横纵坐标刻度、横纵坐标标签)设置一次,重复乏味,如下展示的是一个正弦函数曲线 $\sin(\theta)$ X =np.linspace(-np.pi,np.pi,256,endpoint =True) S = np.sin(X) plt.plot(X,S,color = "blue",linewidth = 3.0,linestyle = ":") 为了方便起见,matplotlib 提供一个 matplotlibrc 文件接口,来全局自定义图表属性(图表大小、DPI、线的宽度、坐标轴、样式、网格属性等),使用方法为 rcParams 命令,一次定义,对接下来创建的全部图表的样式都起效,避免了来回调参的麻烦 rcParsms 参数是以字典键值对的形式声明,格式如下 matplotlib.rcParams['lines.linewidth'] = 2 matplotlib.rcParams['lines.linestyle'] = '--' 在创建图表之前,对全局参数进行设定,设定好了之后可以应用到全部图表中,不需要自己再进行逐一设置 mpl.rcParams['lines.linewidth'] = 2.5 #linewidth

Extract outliers from Seaborn Boxplot

随声附和 提交于 2020-08-04 18:39:46
问题 Is there a way to extract all outliers after plotting a Seaborn Boxplot? For example, if I am plotting a boxplot for the below data client total 1 LA 1 2 Sultan 128 3 ElderCare 1 4 CA 3 5 More 900 I want to see the below records returned as outliers after the boxplot is plotted. 2 Sultan 128 5 More 900 回答1: Seaborn uses matplotlib to handle outlier calculations, meaning the key parameter, whis , is passed onto ax.boxplot . The specific function taking care of the calculation is documented

Extract outliers from Seaborn Boxplot

隐身守侯 提交于 2020-08-04 18:38:52
问题 Is there a way to extract all outliers after plotting a Seaborn Boxplot? For example, if I am plotting a boxplot for the below data client total 1 LA 1 2 Sultan 128 3 ElderCare 1 4 CA 3 5 More 900 I want to see the below records returned as outliers after the boxplot is plotted. 2 Sultan 128 5 More 900 回答1: Seaborn uses matplotlib to handle outlier calculations, meaning the key parameter, whis , is passed onto ax.boxplot . The specific function taking care of the calculation is documented

Colorize the background of a seaborn plot using a column in dataframe

眉间皱痕 提交于 2020-08-02 07:40:52
问题 Question How to shade or colorize the background of a seaborn plot using a column of a dataframe? Code snippet import numpy as np import seaborn as sns; sns.set() import matplotlib.pyplot as plt fmri = sns.load_dataset("fmri") fmri.sort_values('timepoint',inplace=True) ax = sns.lineplot(x="timepoint", y="signal", data=fmri) arr = np.ones(len(fmri)) arr[:300] = 0 arr[600:] = 2 fmri['background'] = arr ax = sns.lineplot(x="timepoint", y="signal", hue="event", data=fmri) Which produced this

Py之matplotlib&seaborn :高级图可视化之Q-Q分位数图probplot、boxplot箱线图、stripplot分类散点图案例应用及代码实现

最后都变了- 提交于 2020-07-29 08:22:50
Py之matplotlib&seaborn :高级图可视化之Q-Q分位数图probplot、boxplot箱线图、stripplot分类散点图案例应用及代码实现 目录 基于百分位数原理寻找异常点的案例应用及代码实现 T1、百分位数划分法寻找异 来源: oschina 链接: https://my.oschina.net/u/4347613/blog/4375197