Seaborn:我只想要对数刻度 [英] Seaborn: I just want a log scale

查看:94
本文介绍了Seaborn:我只想要对数刻度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用seaborn绘制一些生物学数据.

I'm using seaborn to plot some biology data.

我只想要一个基因相对于另一个基因进行分布(约300位患者中的表达),并且在 graph = sns.jointplot(x ='Gene1',y ='Gene2',data= data,kind ='reg')

I just want a distribution one gene against another (expression in ~300 patients), and that's all worked fine and dandy with graph = sns.jointplot(x='Gene1',y='Gene2',data=data,kind='reg')

我喜欢该图为我提供了很好的线性拟合以及PearsonR和P值.

I like that the graph gives me a nice linear fit and a PearsonR and a P value.

我所要做的就是以对数刻度绘制数据,这通常是表示此类基因数据的方式.

All I want is to plot my data on a log scale, which is the way that such gene data is usually represented.

我在线上查看了一些解决方案,但是它们都摆脱了我的PearsonR值或线性拟合,或者看起来不那么好.我对此并不陌生,但似乎在对数刻度上绘制图形应该不会带来太多麻烦.

I've looked at a few solutions online, but they all get rid of my PearsonR value or my linear fit or they just don't look as good. I'm new to this, but it seems like graphing on a log scale shouldn't be too much trouble.

有任何评论或解决方案吗?

Any comments or solutions?

谢谢!

为了回应评论,我离答案越来越近了.我现在有一个图(如下所示),但是我需要一条拟合线并进行一些统计.现在正在努力解决这个问题,但是与此同时,任何答案/建议都非常受欢迎.

In response to comments, I've gotten closer to my answer. I now have a plot (shown below), but I need a line of fit and to do some statistics. Working on that now, but any answers/suggestions in the meantime are more than welcome.

推荐答案

mybins=np.logspace(0, np.log(100), 100)

g = sns.JointGrid(data1, data2, data, xlim=[.5, 1000000],
                  ylim=[.1, 10000000])
g.plot_marginals(sns.distplot, color='blue', bins=mybins)
g = g.plot(sns.regplot, sns.distplot)
g = g.annotate(stats.pearsonr)

ax = g.ax_joint
ax.set_xscale('log')
ax.set_yscale('log')

g.ax_marg_x.set_xscale('log')
g.ax_marg_y.set_yscale('log')

这很好.最后,我决定只将表值转换为 log(x),因为这使图形在短期内更易于缩放和可视化.

This worked just fine. In the end, I decided to just convert my table values into log(x), since that made the graph easier to scale and visualize in the short run.

这篇关于Seaborn:我只想要对数刻度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆