seaborn

Module Seaborn has no attribute '<any graph>'

家住魔仙堡 提交于 2019-12-20 09:53:19
问题 I am having trouble switching from ggplot2 into seaborn. Currently using Anaconda v. 4.5.8 and Python 3.6.3 Any graph I use cannot be found. For example I can take any code from seaborn's site and run: import matplotlib as plt import seaborn as sns sns.set(style="ticks") dots = sns.load_dataset("dots") # Define a palette to ensure that colors will be # shared across the facets palette = dict(zip(dots.coherence.unique(), sns.color_palette("rocket_r", 6))) # Plot the lines on two facets sns

How to manually change the tick labels of the margin plots on a Seaborn jointplot

怎甘沉沦 提交于 2019-12-20 06:43:28
问题 I am trying to use a log scale as the margin plots for my seaborn jointplot. I am usings set_xticks() and set_yticks(), but my changes do not appear. Here is my code below and the resulting graph: import matplotlib.pyplot as plt %matplotlib inline import numpy as np import seaborn as sns import pandas as pd tips = sns.load_dataset('tips') female_waiters = tips[tips['sex']=='Female'] def graph_joint_histograms(df1): g=sns.jointplot(x = 'total_bill',y = 'tip', data = tips, space = 0.3,ratio = 3

How to save multiple plot in a loop?

↘锁芯ラ 提交于 2019-12-20 06:35:06
问题 I tried to save multiple plot in a loop, but It draw them over each other. what should I do? sample code: import pandas as pd import seaborn as sns data=pd.DataFrame({'a':[1,2,3,4,5,6],'b':[0,1,1,0,1,1],'c':[0,0,0,1,1,1]}) for i in ['b','c']: img=sns.boxplot(data.a, groupby=data[i]) fig = img.get_figure() fig.savefig(i) 回答1: You need to clear the data from the previous figure which is rolling over in the loop. This should work, noting fig.clf() as the end of each loop: import pandas as pd

How to remove x and y axis labels in a clustermap?

泪湿孤枕 提交于 2019-12-20 04:54:10
问题 I am creating a plot based on a DataFrame : cg = sns.clustermap(df_correlations.T) The problem is that the x and y axis have unwanted labels in it which come from a hierarchical index. Thus I want to try and remove those labels e.g. like this: ax = cg.fig.gca() ax.set_xlabel('') ax.set_ylabel('') But this has no effect. How can I remove the labels on the x and y axis? 回答1: Without a mcve of the issue it's hard to know where the labels come from (I don't know how the dataframe needs to look

changing size of seaborn plots and matplotlib library plots in a common way

烂漫一生 提交于 2019-12-20 04:19:40
问题 from pylab import rcParams rcParams['figure.figsize'] = (10, 10) This works fine for histogram plots but not for factor plots. sns.factorplot (.....) still shows the default size. sns.factorplot('Pclass','Survived',hue='person',data = titanic_df,size = 6,aspect =1) I have to specify size,aspect everytime. Please suggest something that works for both of them globally. 回答1: It's not possible to change the figure size of a factorplot via rcParams. The figure size is hardcoded inside the

How to specify linewidth in Seaborn's clustermap dendrograms

不打扰是莪最后的温柔 提交于 2019-12-20 02:59:22
问题 Normally I would increase matplotlib's global linewidths by editing the matplotlib.rcParams. This seems to work well directly with SciPy's dendrogram implementation but not with Seaborn's clustermap (which uses SciPy's dendrograms). Can anyone suggest a working method? import matplotlib matplotlib.rcParams['lines.linewidth'] = 10 import seaborn as sns; sns.set() flights = sns.load_dataset("flights") flights = flights.pivot("month", "year", "passengers") g = sns.clustermap(flights) 回答1: for

How to pass weights to a Seaborn FacetGrid

瘦欲@ 提交于 2019-12-20 02:12:05
问题 I have a set of data that I'm trying to plot using a FacetGrid in seaborn. Each data point has a weight associated with it, and I want to plot a weighted histogram in each of the facets of the grid. For example, say I had the following (randomly created) data set: import seaborn as sns import pandas as pd import numpy as np import matplotlib.pyplot as plt d = pd.DataFrame(np.array([np.random.randint(0, 6, 5000), np.random.normal(0, 1., 5000), np.random.uniform(0, 1, 5000)]).T, columns=('cat',

Plotting time series using Seaborn FacetGrid

梦想与她 提交于 2019-12-19 16:12:11
问题 I have a DataFrame ( data ) with a simple integer index and 5 columns. The columns are Date , Country , AgeGroup , Gender , Stat . (Names changed to protect the innocent.) I would like to produce a FacetGrid where the Country defines the row, AgeGroup defines the column, and Gender defines the hue. For each of those particulars, I would like to produce a time series graph. I.e. I should get an array of graphs each of which has 2 time series on it (1 male, 1 female). I can get very close with:

Seaborn PointPlot Category Ordering Issue

隐身守侯 提交于 2019-12-19 11:26:22
问题 I have been trying to use pointplot in Seaborn and in general it does what I need and I'm very impressed with the functionality. My use case is fairly standard: sns.pointplot(x="Category_1", y="Parameter", hue="Category 2", data=df); My issue is that the Category I use for the hue contains strings in the form: "1 string1", "2 string2", "3 string3", etc.... This is by design so that I can get a particular order if I sort. However when I run the Seaborn function the order is different. By what

Lineplot doesn't show all dates in axis

為{幸葍}努か 提交于 2019-12-19 10:49:15
问题 I have the followings: fig, ax = plt.subplots(figsize=(40, 10)) sns.lineplot(x="Date", y="KFQ imports", data=df_dry, color="BLACK", ax=ax) sns.lineplot(x="Date", y="QRR imports", data=df_dry, color="RED",ax=ax) ax.set(xlabel="Date", ylabel="Value", ) x_dates = df_dry['Date'].dt.strftime('%b-%Y') ax.set_xticklabels(labels=x_dates, rotation=45) Result When I use a barchart ( sns.barplot ) the entire spectrum of dates are shown. Am I missing something for the line chart? I 回答1: The idea would be