草庐IT

python - Kaggle 类型错误 : slice indices must be integers or None or have an __index__ method

我正在尝试在Kaggle上绘制seaborn直方图笔记本这样:sns.distplot(myseries,bins=50,kde=True)但是我得到这个错误:TypeError:sliceindicesmustbeintegersorNoneorhavean__index__method这是Kaggle笔记本:https://www.kaggle.com/asindico/slice-indices-must-be-integers-or-none/这是系列头:058500001600000025700000313100000416331452Name:price_doc,dtype

python - Seaborn 中的黑白箱线图

我正在尝试使用Python的Seaborn包绘制多个黑白箱线图。默认情况下,绘图使用调色板。我想用纯黑色轮廓画出它们。我能想到的最好的是:#figurestylessns.set_style('white')sns.set_context('paper',font_scale=2)plt.figure(figsize=(3,5))sns.set_style('ticks',{'axes.edgecolor':'0','xtick.color':'0','ytick.color':'0'})ax=sns.boxplot(x="test1",y="test2",data=dataset,c

python - 在 seaborn 中使用 FacetGrid 为所有面重复 x 轴标签

我正在使用提供的FacetGrid示例here这导致下面的情节。在我的数据集中,有很多图,为每个面重复x轴标签会很方便,而不仅仅是在底部。对于这个例子,值62,...,76应该为每个A-Jfacet重复。 最佳答案 Bazingaa的答案适用于matplotlib2.0.2版。对于较新版本的matplotlib,使用ax.tick_params()并设置labelbottom=True似乎可行:foraxing.axes.flatten():ax.tick_params(labelbottom=True)

python - 使用 Seaborn 绘制具有最小/最大阴影的时间序列图

我正在尝试根据以下数据创建3行时间序列图,在WeekxOverload图中,每个Cluster是不同的线。我对每个(集群、周)对有多个观察(每个atm5个,将有1000个)。我希望线上的点是该特定(集群、周)对的平均过载值,而带是它的最小/最大值。目前正在使用以下代码来绘制它,但我没有得到任何线条,因为我不知道使用当前数据帧指定什么单位:ax14=sns.tsplot(data=long_total_cluster_capacity_overload_df,value="Overload",time="Week",condition="Cluster")GISTData我觉得我仍然需要

python - 在 seaborn 中订购箱线图 x 轴

我的数据框round_data如下所示:errorusernametask_path00.02n49vq14uhvy93i5uw33tf7s1ei07vngozrzlsr6q6cnh8w...39.png10.10n49vq14uhvy93i5uw33tf7s1ei07vngozrzlsr6q6cnh8w...45.png20.15n49vq14uhvy93i5uw33tf7s1ei07vngozrzlsr6q6cnh8w...44.png30.25xdoaztndsxoxk3wycpxxkhaiew3lrsou3eafx3em58uqth...43.png............11

python - 如何将箱线图叠加在 Seaborn 的群图之上?

我正在尝试使用matplotlib和Seaborn一起绘制群图和箱线图。我找到了如何将它们绘制在一起,但箱形图出现在群图下方。这样做的问题是群图点淹没了箱线图,箱线图丢失了。我认为通过切换调用函数的顺序,首先调用箱线图而不是下面链接中的第二个箱线图,会将箱线图覆盖在顶部,但事实并非如此。是否可以将箱线图叠加在群体绘图点之上?如果不是,是否可以创建指示四分位数位置的线?代码:swarm_name="Swarm_Plot_01"#sns.set_style("whitegrid")ax=sns.boxplot(data=[df.Rate_VL1R,df.Rate_V12R,df.Rate_

python - 相关矩阵图,一侧是系数,另一侧是散点图,对角线分布

我喜欢PerformanceAnalyticsR包的chart.Correlationfunction中的这个相关矩阵:我如何在Python中创建它?我见过的相关矩阵图主要是热图,例如thisseabornexample. 最佳答案 另一种解决方案是importmatplotlib.pyplotaspltimportseabornassnsdefcorrdot(*args,**kwargs):corr_r=args[0].corr(args[1],'pearson')corr_text=f"{corr_r:2.2f}".replac

python - 使用特征名称绘制特征重要性

在R中有预建函数来绘制随机森林模型的特征重要性。但是在python中似乎缺少这种方法。我在matplotlib中搜索一种方法。model.feature_importances给我以下内容:array([2.32421835e-03,7.21472336e-04,2.70491223e-03,3.34521084e-03,4.19443238e-03,1.50108737e-03,3.29160540e-03,4.82320256e-01,3.14117333e-03])然后使用以下绘图函数:>>pyplot.bar(range(len(model.feature_importance

python - 在 Seaborn 的 Regplot 中使用日期时间

我在Jupyter/IPython中工作以绘制每天的单词量,但在Seaborn中使用日期时间和Regplot时遇到问题。Regplot本身显然doesnotsupportregressionagainstdatedata,虽然我想要完成的事情并不一定需要Regplot的解决方法——也许只是一种格式化x轴标签的方法。一个最小的工作示例,使用简单的时间戳:%matplotlibinlineimportnumpyasnpimportpandasaspdimportmatplotlibasmplimportmatplotlib.pyplotaspltimportmatplotlib.dates

python - 如何从 seaborn distplot fit= 获取拟合参数?

我正在使用seaborndistplot(数据,fit=stats.gamma)如何获取返回的拟合参数?这是一个例子:importnumpyasnpimportpandasaspdimportseabornassnsfromscipyimportstatsdf=pd.read_csv('RequestSize.csv')importmatplotlib.pyplotaspltreqs=df['12webpages']reqs=reqs.dropna()reqs=reqs[np.logical_and(reqs>np.percentile(reqs,0),reqs