0

MY CODE:

***#Bar Graph 
plt.figure(figsize=(19,10))
sns.barplot(x="STATE_NAME", y="pop", data= sum_of_pop,ci = None)
plt.title(elevation+"_"+pop+"_"+str(year)+'_'+lecz)
plt.xticks(rotation=35,fontsize=11)
plt.yticks(fontsize=11)
plt.xlabel("State Name",fontsize=11) 
plt.ylabel("\nPopulation\n",fontsize=11) 
#plt.show()
plt.savefig(r"C:\\Users\\myname\\Desktop\\lecz_graph\\bar_graph\\"+elevation+"_"+pop+"_"+str(year)+"_"+lecz+".png", dpi=400)***

OUTPUT:

enter image description here

Mr. T
  • 11,960
  • 10
  • 32
  • 54
Qias
  • 1
  • 2
  • Does this answer your question? [prevent scientific notation in matplotlib.pyplot](https://stackoverflow.com/questions/28371674/prevent-scientific-notation-in-matplotlib-pyplot) – Mr. T Feb 18 '21 at 11:43

1 Answers1

0

You can format the y-axis tick using Formatter. Basically It's a function that lets you transform the tick label to be an integer, a fixed-place decimal, or lots of other things.

Refer below example.

import matplotlib.pyplot as plt
plt.style.use('classic')
%matplotlib inline
import numpy as np
from matplotlib.ticker import AutoMinorLocator, FormatStrFormatter

ax = plt.axes(xscale='log', yscale='log')
ax.set_xlim(10e3,100e5)
ax.set_ylim(10e4,10e5)
ax.grid()

this will generate normal plot as shown below.

Actual same data

Now let's add major and minor formatter

ax = plt.axes(xscale='log', yscale='log')
ax.set_xlim(10e3,100e5)
ax.set_ylim(10e4,10e5)
ax.yaxis.set_minor_formatter(FormatStrFormatter("%.3f")) # minor axis formattter
ax.yaxis.set_major_formatter(FormatStrFormatter("%.3f")) # major axis formattter
ax.grid()

Output Image: Please notice the Y-axis ticks. You can also do this for x-axis ticks if you want.

OutputImage

Jay Patel
  • 1,374
  • 1
  • 8
  • 17