pandas Seaborn:我只想要一个对数刻度
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/45439833/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Seaborn: I just want a log scale
提问by julianstanley
I'm using seaborn to plot some biology data.
我正在使用 seaborn 绘制一些生物学数据。
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')
我只想要一种基因与另一种基因的分布(在约 300 名患者中表达),这一切都很好,而且很花哨 graph = sns.jointplot(x='Gene1',y='Gene2',data=data,kind='reg')
I like that the graph gives me a nice linear fit and a PearsonR and a P value.
我喜欢这个图给我一个很好的线性拟合和一个 PearsonR 和一个 P 值。
All I want is to plot my data on a log scale, which is the way that such gene data is usually represented.
我想要的只是在对数刻度上绘制我的数据,这是通常表示此类基因数据的方式。
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.
我在网上查看了一些解决方案,但它们都摆脱了我的 PearsonR 值或线性拟合,或者它们看起来不太好。我是新手,但似乎在对数刻度上绘制图形应该不会太麻烦。
Any comments or solutions?
任何意见或解决方案?
Thanks!
谢谢!
Edit: 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.
编辑:为了回应评论,我已经接近我的答案。我现在有一个情节(如下所示),但我需要一条拟合线并做一些统计。现在正在努力,但在此期间的任何答案/建议都非常受欢迎。
采纳答案by julianstanley
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')
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.
这工作得很好。最后,我决定只将我的表值转换为log(x)
,因为这使得图表在短期内更容易缩放和可视化。