seaborn

Setting col_colors in seaborn clustermap from pandas

主宰稳场 提交于 2019-12-14 03:55:04
问题 I have a clustermap generated from a pandas dataframe. Two of the columns are used to generate the clustermap and I need to use a 3rd column to generate a col_colors bar using sns.palplot(sns.light_palette('red')) palette (values will be from 0 - 1, light - dark colors). The pseudo-code looks something like this: df=pd.DataFrame(input, columns = ['Source', 'amplicon', 'coverage', 'GC']) tiles = df.pivot("Source", "amplicon", "coverage") col_colors = [values from df['GC']] sns.clustermap(tiles

Stacked density plots with pandas and seaborn

狂风中的少年 提交于 2019-12-14 03:07:56
问题 I am trying to obtain the following plot from a pandas data frame. I am not sure how to combine seaborn with pandas for that task. This is the dataframe I want to use: import pandas as pd data = pd.DataFrame({'a': np.random.randn(1000) + 1, 'b': np.random.randn(1000), 'c': np.random.rand(1000) + 10}, columns=['a', 'b', 'c']) data.a[data.a.sample(100).index] = np.NaN data.b[data.b.sample(800).index] = np.NaN Notice that the frequency will need to be normalized (height of the histogram), as the

Why is picture annotation cropped when displaying or saving figure?

时间秒杀一切 提交于 2019-12-13 20:29:44
问题 I have been working at producing some boxplots that include an image that shows what the parts of boxplots represent. As shown in the top right here. This is fine. But, if I remove the green dashed line, which removes the legend, then the little boxplot image is cropped out when I view the plot in jupyter, but also if I save it as image file.e.g. The solution offered here using 'tight' doesn't work, i.e.: plt.savefig("test1.jpg", dpi=300,bbox_inches='tight') Nor does: plt.tight_layout() I've

Colorbar for seaborn.kdeplot

烂漫一生 提交于 2019-12-13 20:03:56
问题 I want to create a Kernel-Density-Estimation with Seaborn.kdeplot with a colorbar on the side. import matplotlib.pyplot as plt import seaborn as sns import numpy as np; np.random.seed(10) import seaborn as sns; sns.set(color_codes=True) mean, cov = [0, 2], [(1, .5), (.5, 1)] x, y = np.random.multivariate_normal(mean, cov, size=50).T sns.kdeplot(x,y,shade=True) plt.show() While the Kernel-Density-Estimation is created, I do not have a clue how to create the colorbar. I tried using plt.colorbar

Seaborn: Overlay line plot on top of bar chart

落爺英雄遲暮 提交于 2019-12-13 20:01:29
问题 Here is my dataframe - easy_donor length count freq 0 Donor 1 NS 0 15637 0.000188 1 Donor 1 NS 1 144539 0.001737 2 Donor 1 NS 2 129792 0.001560 3 Donor 1 NS 3 143610 0.001726 4 Donor 1 NS 4 189110 0.002273 5 Donor 1 NS 5 474718 0.005706 6 Donor 1 NS 6 741730 0.008916 7 Donor 1 NS 7 908024 0.010915 8 Donor 1 NS 8 1892080 0.022744 9 Donor 1 NS 9 3107487 0.037355 10 Donor 1 NS 10 3789310 0.045551 11 Donor 1 NS 11 6321035 0.075984 12 Donor 1 NS 12 7469065 0.089784 13 Donor 1 NS 13 8493704 0

Seaborn and Pandas: Make multiple x-category bar plot using multi index data in python

房东的猫 提交于 2019-12-13 19:25:50
问题 I have a multi-index dataframe that I've melted to look something like this: Color Frequency variable value Red 2-3 times a month x 22 Red A few days a week x 45 Red At least once a day x 344 Red Never x 5 Red Once a month x 1 Red Once a week x 0 Red Once every few months x 4 Blue 2-3 times a month x 4 Blue A few days a week x 49 Blue At least once a day x 200 Blue Never x 7 Blue Once a month x 19 Blue Once a week x 10 Blue Once every few months x 5 Red 2-3 times a month y 3 Red A few days a

Use “stacked” design in Seaborn Factorplot

一曲冷凌霜 提交于 2019-12-13 17:52:50
问题 I use a seaborn Factorplot (kind=bar) to represent in total 6 bars in 2 "categories" (3 bars for each category). I would like to enhance this factorplot by using the stacked design, that is I want to represent each bar by its "subcomponents". I know that this is possible for barplot but is it also possible for factorplot? 回答1: Randy Zwitch explains how to create a stacked bar chart in seaborn. The solution is to think of a stacked bar chart as multiple, overlaying, plots on the same graph so

using a custom colour scheme in pandas/matplotlib/seaborn python

陌路散爱 提交于 2019-12-13 12:29:17
问题 I want to use a custom colour scheme using for various plots but can't get it to work (using seaborn and/or matplob & pandas for these plots) flatui = ["#9b59b6", "#3498db", "#95a5a6", "#e74c3c", "#34495e", "#2ecc71"] ax = sns.violinplot(x="Contents", y="Flavour", data=rd, color="lol", inner="box") I get error code: ValueError: to_rgb: Invalid rgb arg "flatui" could not convert string to float: 'flatui' even ax = sns.violinplot(x="Contents", y="Flavour", data=rd, color=["9b59b6", "#3498db", "

Seaborn Heatmap Currency Format

倖福魔咒の 提交于 2019-12-13 10:52:18
问题 Given the following heatmap: import matplotlib.pyplot as plt import seaborn as sns import pandas as pd %matplotlib inline df = pd.DataFrame( {'A' : ['A', 'A', 'B', 'B','C', 'C', 'D', 'D'], 'B' : ['A', 'B', 'A', 'B','A', 'B', 'A', 'B'], 'C' : [22000, 4000, 500, 20000, 0, 3000, 90000, 1000], 'D' : [6000, 62000, 7000, 700, 30000, 30, 1000, 1000]}) df=df.pivot('A','B','C') fig, ax = plt.subplots(1, 1, figsize =(4,6)) sns.heatmap(df, annot=True, linewidths=0, cbar=False) plt.show() I would like

Why do i get HTTP400 error when i am plotting graphs in python?

强颜欢笑 提交于 2019-12-13 08:48:51
问题 I am working on a dataset to visualize basic plots in python. I use seaborn and matplotlib . Up until yesterday, the packages worked perfectly fine until this error showed up: stars = sns.load_dataset(vcsfeatures) sns.boxplot(stars) plt.xlim(-100, 8000, 500) plt.show() Traceback (most recent call last): File "<input>", line 1, in <module> File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/seaborn/utils.py", line 424, in load_dataset urlretrieve(full_path,