seaborn

Confusion with bandwidth on seaborn's kdeplot

浪尽此生 提交于 2020-05-27 11:51:06
问题 lineslist, below, represents a set of lines (for some chemical spectrum, let's say), in MHz. I know the linewidth of the laser used to probe these lines to be 5 MHz. So, naively, the kernel density estimate of these lines with a bandwidth of 5 should give me the continuous distribution that would be produced in an experiment using the aforementioned laser. The following code: import seaborn as sns import numpy as np import matplotlib.pyplot as plt lineslist=np.array([-153.3048645 , -75

Matplotlib/seaborn histogram using different colors for grouped bins

青春壹個敷衍的年華 提交于 2020-05-27 04:38:48
问题 I have this code, using a pandas df: import pandas as pd import matplotlib.pyplot as plt import seaborn as sns import os path_to = 'Data\\2017-04\\MonthlyData\q1analysis\Energy Usage' # where to save df = pd.read_csv('April2017NEW.csv', index_col =1) df1 = df.loc['Output Energy, (Wh/h)'] # choose index value and Average df1['Average'] = df1.mean(axis=1) print df1 print df1['Average'].describe() def hist(): p = sns.distplot(df1['Average'],kde=False, bins=25).set(xlim=(0, 100)); plt.xlabel(

Adding units to heatmap annotation in Seaborn

五迷三道 提交于 2020-05-25 12:23:11
问题 I am trying to show a table of percentages as a heatmap in Seaborn: sns.heatmap(S, annot=True, fmt=".1f", linewidths=1.0, square=1) However, I'd like the percent sign to appear after each number in the heatmap annotations. The fmt flag only seems to accept number format specifiers. Is there a way to do this either within Seaborn or with some matplotlib tweaking? 回答1: You have to iterate over all text values of a heatmap and add % sign: import matplotlib.pyplot as plt import seaborn as sns

Adding units to heatmap annotation in Seaborn

拜拜、爱过 提交于 2020-05-25 12:20:28
问题 I am trying to show a table of percentages as a heatmap in Seaborn: sns.heatmap(S, annot=True, fmt=".1f", linewidths=1.0, square=1) However, I'd like the percent sign to appear after each number in the heatmap annotations. The fmt flag only seems to accept number format specifiers. Is there a way to do this either within Seaborn or with some matplotlib tweaking? 回答1: You have to iterate over all text values of a heatmap and add % sign: import matplotlib.pyplot as plt import seaborn as sns

Incorrect marker sizes with Seaborn relplot and scatterplot relative to legend

为君一笑 提交于 2020-05-25 08:53:06
问题 I'm trying to understand how to get the legend examples to align with the dots plotted using Seaborn's relplot in a Jupyter notebook. I have a size ( float64 ) column in my pandas DataFrame df : sns.relplot(x="A", y="B", size="size", data=df) The values in the size column are [0.0, -7.0, -14.0, -7.0, 0.0, 1.0, 0.0, 0.0, 0.0, -1.0, 0.0, 8.0, 2.0, 0.0, -4.0, 7.0, -4.0, 0.0, 0.0, 4.0, 0.0, 0.0, -3.0, 0.0, 1.0, 7.0] and as you can see, the minimum value is -14 and the maximum value is 8 . It

Seaborn heatmap by column

天大地大妈咪最大 提交于 2020-05-25 07:12:11
问题 It seems to me the heatmap function is applied to the dataframe in its entirety. What if I only want the heatmap applied to a given set of column(s) from my dataset? I would imagine this can be achieved by smartly using cmap, but cannot seem to get it to work. 回答1: Pass the desired sub-DataFrame to seaborn.heatmap: seaborn.heatmap(df[[col1, col2]], ...) df[[col1, col2, ..., coln]] returns a DataFrame composed of the columns col1 , col2 , ... coln from df . Note the double brackets. If you

Increase tick label font size in seaborn

落爺英雄遲暮 提交于 2020-05-25 06:06:43
问题 I have a huge problem with my seaborn plots. For some reason, the numbers along the axis are printed with a really small font, which makes them unreadable. I've tried to scale them with with plt.rc_context(dict(sns.axes_style("whitegrid"), **sns.plotting_context(font_scale=5))): b = sns.violinplot(y="Draughts", data=dr) To no help, this only makes the axis text larger, but not the number along the axis. 回答1: The answer from here makes fonts larger in seaborn ... import pandas as pd, numpy as

seaborn AttributeError: 'module' object has no attribute 'set'

你离开我真会死。 提交于 2020-05-24 01:54:35
问题 I have anaconda2 in my windows10, and install seaborn by the command: conda install seaborn Then I download an example from seaborn website: import seaborn as sns sns.set(style="ticks") # Load the example dataset for Anscombe's quartet df = sns.load_dataset("anscombe") # Show the results of a linear regression within each dataset sns.lmplot(x="x", y="y", col="dataset", hue="dataset", data=df, col_wrap=2, ci=None, palette="muted", size=4, scatter_kws={"s": 50, "alpha": 1}) After I run the

seaborn AttributeError: 'module' object has no attribute 'set'

有些话、适合烂在心里 提交于 2020-05-24 01:51:55
问题 I have anaconda2 in my windows10, and install seaborn by the command: conda install seaborn Then I download an example from seaborn website: import seaborn as sns sns.set(style="ticks") # Load the example dataset for Anscombe's quartet df = sns.load_dataset("anscombe") # Show the results of a linear regression within each dataset sns.lmplot(x="x", y="y", col="dataset", hue="dataset", data=df, col_wrap=2, ci=None, palette="muted", size=4, scatter_kws={"s": 50, "alpha": 1}) After I run the

How to add a comparison line to all plots when using Seaborn's FacetGrid

旧时模样 提交于 2020-05-17 08:15:07
问题 I'm trying to add the same comparison line to multiple plots using FacetGrid. Here is where I get stuck: # Import the dataset tips = sns.load_dataset("tips") # Plot using FaceGrid, separated by smoke g = sns.FacetGrid(tips, col="smoker", size=5, aspect=1.5) g.map(plt.scatter, "tip", "total_bill") x = np.arange(0, 50, .5) y = 0.2*x plt.plot(y, x, C='k') plt.show() Here are the results As you can see, the line shows up on the last plot, but not the first. How do I get it on both? 回答1: You can