I'm using seaborn to plot some biology data.
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')
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.
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?
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.
To make the x-axis to log scale, we first the make the scatter plot with Seaborn and save it to a variable and then use set function to specify 'xscale=log'. We see a linear pattern between lifeExp and gdpPercap. Now, the scatter plot makes more sense. However, a lot of data points overlap on each other.
To repress the scientific notation, use style="plain" in ticklabel_format() method.
This function has been deprecated and will be removed in seaborn v0. 14.0. It has been replaced by histplot() and displot() , two functions with a modern API and many more capabilities.
Behind the scenes, seaborn uses matplotlib to draw its plots. For interactive work, it's recommended to use a Jupyter/IPython interface in matplotlib mode, or else you'll have to call matplotlib. pyplot. show() when you want to see the plot.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With