seaborn

Masking annotations in seaborn heatmap

夙愿已清 提交于 2020-05-17 03:51:08
问题 I would like to make a heatmap that has annotation only in specific cells. I though one way to do this would be to make a heatmap with annotations in all cells and then overlay another heatmap that has no annotation but that is masked in the regions that I want the original annotations to be visible: import numpy as np import seaborn as sns par_corr_p = np.array([[1, 2], [3, 4]]) masked_array = np.ma.array(par_corr_p, mask=par_corr_p<2) fig, ax = plt.subplots() sns.heatmap(par_corr_p, ax=ax,

Seaborn distplot y-axis normalisation wrong ticklabels

谁说我不能喝 提交于 2020-05-14 14:51:46
问题 Just to note, I have already checked this question and this question. So, I'm using distplot to draw some histograms on separate subplots: import numpy as np #import netCDF4 as nc # used to get p0_dict import matplotlib.pyplot as plt from collections import OrderedDict import seaborn.apionly as sns import cPickle as pickle ''' LINK TO PICKLE https://drive.google.com/file/d/0B8Xks3meeDq0aTFYcTZEZGFFVk0/view?usp=sharing ''' p0_dict = pickle.load(open('/path/to/pickle/test.dat', 'r')) fig = plt

How to draw distribution plot for discrete variables in seaborn

為{幸葍}努か 提交于 2020-05-13 07:09:41
问题 When I draw displot for discrete variables, the distribution might not be as what I think. For example. We can find that there are crevices in the barplot so that the curve in kdeplot is "lower" in y axis. In my work, it was even worse: I think it may because the "width" or "weight" was not 1 for each bar. But I didn't find any parameter that can justify it. I'd like to draw such curve (It should be more smooth) 回答1: If the problem is that there are some emptry bins in the histogram, it

How to draw distribution plot for discrete variables in seaborn

三世轮回 提交于 2020-05-13 07:04:48
问题 When I draw displot for discrete variables, the distribution might not be as what I think. For example. We can find that there are crevices in the barplot so that the curve in kdeplot is "lower" in y axis. In my work, it was even worse: I think it may because the "width" or "weight" was not 1 for each bar. But I didn't find any parameter that can justify it. I'd like to draw such curve (It should be more smooth) 回答1: If the problem is that there are some emptry bins in the histogram, it

How to draw distribution plot for discrete variables in seaborn

。_饼干妹妹 提交于 2020-05-13 07:04:08
问题 When I draw displot for discrete variables, the distribution might not be as what I think. For example. We can find that there are crevices in the barplot so that the curve in kdeplot is "lower" in y axis. In my work, it was even worse: I think it may because the "width" or "weight" was not 1 for each bar. But I didn't find any parameter that can justify it. I'd like to draw such curve (It should be more smooth) 回答1: If the problem is that there are some emptry bins in the histogram, it

Plotting a legend for facet grids

人盡茶涼 提交于 2020-05-13 06:12:52
问题 I have plotted around 10 graphs using facet grids in seaborn. How can I plot a legend in each graph? This is the current code I have: g = sns.FacetGrid(masterdata,row="departmentid",col = "coursename",hue="resulttype",size=5, aspect=1) g=g.map(plt.scatter, "totalscore", "semesterPercentage") If I include plt.legend() , then the legend only appears in the last graph. How can I plot a legend in each graph in the facet grids plot? Or is there a way to plot the legend in the first graph itself,

AttributeError: 'str' object has no attribute 'view' in Seaborn , Scatterplot

爱⌒轻易说出口 提交于 2020-05-13 04:58:20
问题 I am getting a bizarre exception in Seaborn. For a reproducible example: toy_data.to_json() '{"X":{"0":0.12765045,"1":0.0244816152,"2":0.1263715245,"3":0.0246376768,"4":0.1108581319,"5":0.1406719382,"6":0.1358105564,"7":0.1245863432,"8":0.1175445352,"9":0.1188479018,"10":0.1113148159,"11":0.117455495,"12":0.110555662,"13":0.1328567106,"14":0.103064284,"15":0.1119474442,"16":0.119390455,"17":0.1246727756,"18":0.1117827155,"19":0.1169972547},"Y":{"0":0.1241083714,"1":0.1394242378,"2":0

AttributeError: 'str' object has no attribute 'view' in Seaborn , Scatterplot

◇◆丶佛笑我妖孽 提交于 2020-05-13 04:56:04
问题 I am getting a bizarre exception in Seaborn. For a reproducible example: toy_data.to_json() '{"X":{"0":0.12765045,"1":0.0244816152,"2":0.1263715245,"3":0.0246376768,"4":0.1108581319,"5":0.1406719382,"6":0.1358105564,"7":0.1245863432,"8":0.1175445352,"9":0.1188479018,"10":0.1113148159,"11":0.117455495,"12":0.110555662,"13":0.1328567106,"14":0.103064284,"15":0.1119474442,"16":0.119390455,"17":0.1246727756,"18":0.1117827155,"19":0.1169972547},"Y":{"0":0.1241083714,"1":0.1394242378,"2":0

Subplot for seaborn boxplot

拥有回忆 提交于 2020-05-07 10:25:29
问题 I have a dataframe like this import seaborn as sns import pandas as pd %pylab inline df = pd.DataFrame({'a' :['one','one','two','two','one','two','one','one','one','two'], 'b': [1,2,1,2,1,2,1,2,1,1], 'c': [1,2,3,4,6,1,2,3,4,6]}) A single boxplot is OK sns.boxplot( y="b", x= "a", data=df, orient='v' ) But i want to build a subplot for all variables. I do names = ['b', 'c'] plt.subplots(1,2) sub = [] for name in names: ax = sns.boxplot( y=name, x= "a", data=df, orient='v' ) sub.append(ax) and i

Seaborn countplot with normalized y axis per group

安稳与你 提交于 2020-05-07 09:54:42
问题 I was wondering if it is possible to create a Seaborn count plot, but instead of actual counts on the y-axis, show the relative frequency (percentage) within its group (as specified with the hue parameter). I sort of fixed this with the following approach, but I can't imagine this is the easiest approach: # Plot percentage of occupation per income class grouped = df.groupby(['income'], sort=False) occupation_counts = grouped['occupation'].value_counts(normalize=True, sort=False) occupation