我用factorplot
in seaborn
和get facetgrid
对象绘制了我的数据,但仍无法理解如何在这样的情节中设置以下属性:
我正在使用factorplot(kind="bar")
seaborn.
情节很好,除了传说是错位的:右边太多,文字从情节的阴影区域出来.
如何让seaborn将传奇置于其他地方,例如左上角而不是右中角?
我想创建一个时间序列图,使用seaborn.tsplot
类似于此示例中的tsplot
文档,但图例移到右侧,图中.
基于seaborn的timeseries.py中的 339-340行,看起来seaborn.tsplot
目前不允许直接控制图例放置:
if legend:
ax.legend(loc=0, title=legend_name)
Run Code Online (Sandbox Code Playgroud)
是否有matplotlib解决方法?我正在使用seaborn 0.6-dev.
我对用于标记的几个问题clustermap
在seaborn
.首先,可以提取层次聚类的距离值,并在树结构可视化上绘制值(可能只有前三个级别).
这是我用于创建clustermap plot的示例代码:
import pandas as pd
import numpy as np
import seaborn as sns
get_ipython().magic(u'matplotlib inline')
m = np.random.rand(50, 50)
df = pd.DataFrame(m, columns=range(4123, 4173), index=range(4123, 4173))
sns.clustermap(df, metric="correlation")
Run Code Online (Sandbox Code Playgroud)
另外两个问题是: - 如何旋转y标签,因为它们重叠在一起.
- 如何将颜色条移动到底部或右侧.(有一个关于热图的问题,但对我的情况不起作用.也没有解决颜色条的位置)
python artificial-intelligence machine-learning matplotlib seaborn
有没有办法只使用Seaborn在Python中绘制Pandas系列的CDF +累积直方图?我有以下内容:
import numpy as np
import pandas as pd
import seaborn as sns
s = pd.Series(np.random.normal(size=1000))
Run Code Online (Sandbox Code Playgroud)
我知道我可以绘制累积直方图s.hist(cumulative=True, normed=1)
,并且我知道我可以使用绘制CDF sns.kdeplot(s, cumulative=True)
,但我想要一些可以在Seaborn中完成的东西,就像绘制分布时一样sns.distplot(s)
,既给出了kde拟合,又给出了直方图.有办法吗?
我正在绘制y轴上具有不同单位的两个数据集.有没有办法让刻度线和网格线在两个y轴上对齐?
第一张图片显示了我得到的内容,第二张图片显示了我想要获得的内容.
这是我用来绘制的代码:
import seaborn as sns
import numpy as np
import pandas as pd
np.random.seed(0)
fig = plt.figure()
ax1 = fig.add_subplot(111)
ax1.plot(pd.Series(np.random.uniform(0, 1, size=10)))
ax2 = ax1.twinx()
ax2.plot(pd.Series(np.random.uniform(10, 20, size=10)), color='r')
Run Code Online (Sandbox Code Playgroud)
有一个在 这个 热图的seaborn热图文档中找到.
现在,y轴从底部的9开始,在顶部以0结束.有没有办法扭转这种局面,即从底部的0开始到顶部的9结束?
在Python中使用数据框和此代码,我能够创建一个图:
g = sns.lmplot('credibility', 'percentWatched', data=data, hue = 'millennial', markers = ["+", "."], x_jitter = True, y_jitter = True, size=5)
g.set(xlabel = 'Credibility Ranking\n ? Low High ?', ylabel = 'Percent of Video Watched [%]')
Run Code Online (Sandbox Code Playgroud)
但是有传说说"+ 0"和".1"对读者来说并不是很有帮助.如何编辑图例的标签?理想情况下,它不是说"千禧一代",而是说"一代"和"+千禧一代"."老一代"
我在将Seaborn Jointplot
放在多列中时遇到了问题subplot
.
import pandas as pd
import seaborn as sns
df = pd.DataFrame({'C1': {'a': 1,'b': 15,'c': 9,'d': 7,'e': 2,'f': 2,'g': 6,'h': 5,'k': 5,'l': 8},
'C2': {'a': 6,'b': 18,'c': 13,'d': 8,'e': 6,'f': 6,'g': 8,'h': 9,'k': 13,'l': 15}})
fig = plt.figure();
ax1 = fig.add_subplot(121);
ax2 = fig.add_subplot(122);
sns.jointplot("C1", "C2", data=df, kind='reg', ax=ax1)
sns.jointplot("C1", "C2", data=df, kind='kde', ax=ax2)
Run Code Online (Sandbox Code Playgroud)
注意如何只将一部分jointplot
放置在子图内,其余部分留在另外两个图框内.我想要的是distributions
同时插入内部subplots
.
有人能帮忙吗?
我从他们自己的网站上运行了这个散点图 seaborn 示例,
import seaborn as sns; sns.set()
import matplotlib.pyplot as plt
tips = sns.load_dataset("tips")
# this works:
ax = sns.scatterplot(x="total_bill", y="tip", data=tips)
# But adding 'hue' gives the error below:
ax = sns.scatterplot(x="total_bill", y="tip", hue="time", data=tips)
Run Code Online (Sandbox Code Playgroud)
这个错误:
import seaborn as sns; sns.set()
import matplotlib.pyplot as plt
tips = sns.load_dataset("tips")
# this works:
ax = sns.scatterplot(x="total_bill", y="tip", data=tips)
# But adding 'hue' gives the error below:
ax = sns.scatterplot(x="total_bill", y="tip", hue="time", data=tips)
Run Code Online (Sandbox Code Playgroud)
昨天它确实起作用了。但是,我运行了使用conda update --all
. 有什么改变了吗? …