简体   繁体   中英

When to use line=r and line=45 in qqplot

Can anyone tell me when do we use line='r'??

sm.qqplot(df['Delivery_time'], line='r')

and when do we use line=45?

sm.qqplot(df['Delivery_time'], line='45')

According to the documentation stats.mode l,line can be {None, “45”, “s”, “r”, “q”} “45” - 45-degree line “r” - A regression line is fit

Let me add codes and output of the the two cases for better understanding.

Case 1:, if we are comparing the distribution of a sample of data to a theoretical normal distribution, we might use line='r' to plot a regression line that shows how well the sample data fits the normal distribution.

import numpy as np
import statsmodels.api as sm
import pylab as py
data_points = np.random.normal(0, 1, 100)   

sm.qqplot(data_points, line ='r')
py.show()

行='r'

Case 2: If the line='45' would refer to a 45-degree line, which is a line that has a slope of 1 and passes through the origin. This line is used as a reference for comparing the distribution of the data being plotted to a uniform distribution.

import numpy as np
import statsmodels.api as sm
import pylab as py
data_points = np.random.normal(0, 1, 100)   

sm.qqplot(data_points, line ='45')
py.show()

输出:45 度角的参考线

For example, in the above case we are compare the distribution of a sample of data to a uniform distribution, we might use line='45' to plot a reference line that shows how well the sample data fits the uniform distribution.

Note:The line parameter can be used to customize the reference line on the QQ plot to better compare the distribution of the data being plotted to a theoretical distribution.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM