seaborn

How to add a label to Seaborn Heatmap color bar?

让人想犯罪 __ 提交于 2019-12-21 03:12:06
问题 If I have the following data and Seaborn Heatmap: import pandas as pd data = pd.DataFrame({'x':(1,2,3,4),'y':(1,2,3,4),'z':(14,15,23,2)}) sns.heatmap(data.pivot_table(index='y', columns='x', values='z')) How do I add a label to the colour bar? 回答1: You could set it afterwards after collecting it from an ax , or simply pass a label in cbar_kws like so. import seaborn as sns import pandas as pd data = pd.DataFrame({'x':(1,2,3,4),'y':(1,2,3,4),'z':(14,15,23,2)}) sns.heatmap(data.pivot_table

How to overlay a Seaborn jointplot with a “marginal” (distribution histogram) from a different dataset

浪尽此生 提交于 2019-12-21 02:02:12
问题 I have plotted a Seaborn JointPlot from a set of "observed counts vs concentration" which are stored in a pandas DataFrame . I would like to overlay (on the same set of axes) a marginal (ie: univariate distribution) of the "expected counts" for each concentration on top of the existing marginal, so that the difference can be easily compared. This graph is very similar to what I want, although it will have different axes and only two datasets: Here is an example of how my data is laid out and

Scatterplot without linear fit in seaborn

杀马特。学长 韩版系。学妹 提交于 2019-12-20 17:42:03
问题 I am wondering if there is a way to turn off the linear fit in seaborn's lmplot or if there is an equivalent function that just produces the scatterplot. Sure, I could also use matplotlib, however, I find the syntax and aesthetics in seaborn quite appealing. E.g,. I want to plot the following plot import seaborn as sns sns.set(style="ticks") df = sns.load_dataset("anscombe") sns.lmplot("x", "y", data=df, hue='dataset') Without the linear fit like so: from itertools import cycle import numpy

tick frequency when using seaborn/matplotlib boxplot

我们两清 提交于 2019-12-20 14:25:46
问题 I am plotting with seaborn a series of boxplots with sns.boxplot(full_array) where full_array contains 200 arrays. Therefore, I have 200 boxplots and ticks on the x-axis from 0 to 200. The xticks are too close to each other and I would like to show only some of them, for instance, a labeled xtick every 20, or so. I tried several solutions as those mentioned here but they did not work. Every time I sample the xticks, I get wrong labels for the ticks, as they get numbered from 0 to N, with unit

tick frequency when using seaborn/matplotlib boxplot

时光总嘲笑我的痴心妄想 提交于 2019-12-20 14:24:27
问题 I am plotting with seaborn a series of boxplots with sns.boxplot(full_array) where full_array contains 200 arrays. Therefore, I have 200 boxplots and ticks on the x-axis from 0 to 200. The xticks are too close to each other and I would like to show only some of them, for instance, a labeled xtick every 20, or so. I tried several solutions as those mentioned here but they did not work. Every time I sample the xticks, I get wrong labels for the ticks, as they get numbered from 0 to N, with unit

Plot lower triangle in a seaborn Pairgrid

怎甘沉沦 提交于 2019-12-20 14:11:55
问题 I'm a bit struggling with seaborn Pairgrid. Let's say I have a Pairgrid like this: As you can see, the upper triangle plots mirror the lower triangle ones. I'd like to be able to plot only the lower triangle plots, but I found no easy way so far to do it. Can you help me? 回答1: Probably should be an easier way, but this works import numpy as np import seaborn as sns iris = sns.load_dataset("iris") g = sns.pairplot(iris) for i, j in zip(*np.triu_indices_from(g.axes, 1)): g.axes[i, j].set

how to set readable xticks in seaborn's facetgrid?

假装没事ソ 提交于 2019-12-20 12:38:53
问题 i have this plot of a dataframe with seaborn's facetgrid: import seaborn as sns import matplotlib.pylab as plt import pandas import numpy as np plt.figure() df = pandas.DataFrame({"a": map(str, np.arange(1001, 1001 + 30)), "l": ["A"] * 15 + ["B"] * 15, "v": np.random.rand(30)}) g = sns.FacetGrid(row="l", data=df) g.map(sns.pointplot, "a", "v") plt.show() seaborn plots all the xtick labels instead of just picking a few and it looks horrible: Is there a way to customize it so that it plots

How to get rid of grid lines when plotting with Seaborn + Pandas with secondary_y

吃可爱长大的小学妹 提交于 2019-12-20 10:34:16
问题 I'm plotting two data series with Pandas with seaborn imported. Ideally I would like the horizontal grid lines shared between both the left and the right y-axis, but I'm under the impression that this is hard to do. As a compromise I would like to remove the grid lines all together. The following code however produces the horizontal gridlines for the secondary y-axis. import pandas as pd import numpy as np import seaborn as sns data = pd.DataFrame(np.cumsum(np.random.normal(size=(100,2)),axis

changing the marker size in python seaborn lmplot

烂漫一生 提交于 2019-12-20 10:25:15
问题 I am trying to change the size of the lmplot markers in seaborn. I have tried passing 's' or 'size' as arguments and neither of them work. lm = sns.lmplot(x="totalX",y="NormI", hue="Data Type", data=df, palette="Set1", legend_out=False, S=20) I have tried "s", "markersize", "size" I get no effect. I want to make the data points larger on the plot. Any help is much appreciated. 回答1: You want to use scatter_kws={"s": 100} As in: lm = sns.lmplot(x = "totalX", y = "NormI", hue = "Data Type", data

Seaborn palettes - prevent recycling of colors

空扰寡人 提交于 2019-12-20 09:56:13
问题 Seaborn allows defining color palettes that contain multiple colors, useful for charts with many lines. However, when setting the palette to one with multiple colors, only the first six are used, after which colors recycle, making it hard to distinguish lines. This can be overridden by explicitly calling the palette, but that's not convenient. Is there a way to force the Seaborn current palette not to recycle colors, when more than 6 are defined? Example: from matplotlib import pyplot as plt