Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Seaborn / Matplotlib: How to repress scientific notation in factorplot y-axis

Simple example below for this issue which I just can't solve.

N.B. Some other Seaborn plotting methods seems to have arguments to repress the exponential form but seemingly not factorplots. I tried some Matplotlib solutions including those suggested in this similar question but none work. Also this is not a dupe of this question. I use factorplots very frequently and ideally want to find a proper solution as opposed to a workaround.

data = {'reports': [4, 24, 31, 2, 3],'coverage': [35050800, 54899767, 57890789, 62890798, 70897871]} df = pd.DataFrame(data) df 

Produces this dataframe:

    coverage    reports 0   35050800    4 1   54899767    24 2   57890789    31 3   62890798    2 4   70897871    3 

And then this Seaborn code:

sns.factorplot(y="coverage", x="reports", kind='bar', data=df, label="Total")  

Produces this plot:

enter image description here

Is there a way to get the y axis to display an appropriate numeric scale based on the coverage values?

like image 969
RDJ Avatar asked Apr 21 '16 21:04

RDJ


People also ask

How do I stop matplotlib from scientific notation?

To prevent scientific notation, we must pass style='plain' in the ticklabel_format method.

How do I change the Y axis label in Seaborn?

Use the set_xlabel() and set_ylabel() Functions to Set the Axis Labels in a Seaborn Plot. A seaborn plot returns a matplotlib axes instance type object. We can use the set_xlabel() and set_ylabel to set the x and y-axis label respectively. We can use the fontsize parameter to control the size of the font.

How do I get rid of Y label in Seaborn?

To remove X or Y labels from a Seaborn heatmap, we can use yticklabel=False.


1 Answers

It looks like the following line solves the issue:

plt.ticklabel_format(style='plain', axis='y') 

Here is the documentation link.

like image 156
Tony Babarino Avatar answered Sep 23 '22 03:09

Tony Babarino