Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

logarithmic scale fitting python

fig=plt.figure()
ax = fig.add_subplot(111)

z=np.arange(1, len(x)+1) #start at 1, to avoid error from log(0)

logA = np.log(z) #no need for list comprehension since all z values >= 1
logB = np.log(y)

m, c = np.polyfit(logA, logB, 1, w=np.sqrt(y)) # fit log(y) = m*log(x) + c
y_fit = np.exp(m*logA + c) # calculate the fitted values of y 

plt.plot(z, y, color = 'r')
plt.plot(z, y_fit, ':')

ax.set_yscale('symlog')
ax.set_xscale('symlog')
#slope, intercept = np.polyfit(logA, logB, 1)
plt.xlabel("Pre_referer")
plt.ylabel("Popularity")
ax.set_title('Pre Referral URL Popularity distribution')
plt.show()
Comment

PREVIOUS NEXT
Code Example
Python :: python type hinting pandas dataframe 
Python :: cufflink install python jupyter 
Python :: plt add y gridlines 
Python :: create excel file python 
Python :: how to rename columns in pandas dataframe 
Python :: length of int in python 
Python :: python how to align text writen to a file 
Python :: make a new environment conda 
Python :: how to make a dice program in python 
Python :: python countdown from 20 down to 0 
Python :: matplotlib remove duplicate legend entries from plotting loop 
Python :: delete variable python 
Python :: python command line start server 
Python :: f-string print 
Python :: use mongo replica set python 
Python :: discord.py message user 
Python :: funcions in python 
Python :: datetime from float python 
Python :: how to use css in php example 
Python :: cursor.fetchall() to list 
Python :: python venv usage 
Python :: print colored text to console python 
Python :: how to center a string python 
Python :: change month name in python 
Python :: python trim 
Python :: create nested dictionary with user input in python 
Python :: type checking python 
Python :: Python list files only in given directory 
Python :: python list files in directory 
Python :: matplot lib 3d plot autoscale 
ADD CONTENT
Topic
Content
Source link
Name
4+1 =