3

I'm plotting some latitude longitude points as a square using "matplotlib.pyplot". My x-axis has negative range -122.5 to -122.3. When I plot the figure my x-axis ticks are not a decimal value rather they are in exponential form(Refer Fig).

xmin = -122.522916
xmax = -122.363957
ymin = 37.702103
ymax = 37.811763

for point in points:
    point1,point2 = point.split("%")
    x1,y1 = point1.split(",")
    x2,y2 = point2.split(",")
    plt.plot([y1, y1], [x1, x2], linestyle="solid", marker="", color="green")
    plt.plot([y2, y2], [x1, x2], linestyle="solid", marker="", color="green")
    plt.plot([y1, y2], [x1, x1], linestyle="solid", marker="", color="green")
    plt.plot([y1, y2], [x2, x2], linestyle="solid", marker="", color="green")

plt.xlabel('Latitude',fontsize=20)
plt.xlim([xmin,xmax])
plt.ylabel('Longitude',fontsize=20)
plt.ylim([ymin,ymax])
plt.tight_layout()
plt.savefig(output_file_name, dpi=300, bbox_inches='tight')

enter image description here

How to avoid this error?. I need the X-axis tick values like -122.5 , -122.48, -122.45 ...

  • I added the following code from the existing answers, and it works perfectly. ax = plt.gca() ax.get_xaxis().get_major_formatter().set_useOffset(False) –  Mar 23 '15 at 14:33

0 Answers0