Select to view content in your preferred language

How to add exponential trend line to a semi logarithmic scatter plot in arcpy?

655
0
05-07-2021 07:06 AM
Labels (3)
badrinathkar
Emerging Contributor

I want to create a semi-logarithmic scatter plot and add an exponential trend line to the graph. I would also like to limit the x and y (log y) axes extent with their highest value. Also want to define the interval of the x and y axes.

I have tried with the following code 

>>> import numpy as np
... import matplotlib.pyplot as plt
... fc='Yearwise'
... x= [r[0] for r in arcpy.da.SearchCursor(fc,'Year') if not r [0] is None]
... y= [r[0] for r in arcpy.da.SearchCursor(fc,'SMI') if not r [0] is None]
... ylog= np.log(y)
... plt.yscale('log')
... plt.ylim([0.1,10000])
... plt.scatter(x, ylog)
... curve_fit= np.polyfit(x,ylog,1)
... plt.show()
... print(curve_fit)

But have got the attached result (Please find the attached fig.).

Tags (3)
0 Kudos
0 Replies