first time asking something here on stackoverflow.
I have encountered a problem while using seaborn's lmplot.
my dataset after cleaning it up is simple like this: image of data set
I am trying to create a facetgrid scatter plot that has a linear regression (which is what lmplot is used for), using:
to look something like this: lmplot example from seaborn
Below is my code and I was expecting a scatterplot + regression that looks like the above example.
ridership_year = ridership_mg.groupby(['stationame', 'year']).monthtotal.sum().reset_index()
sns.lmplot(x = 'year', y = 'monthtotal', col ='stationame', data= ridership_year, col_wrap = 5)
However, the figure output was this: seaborn lmplot image
What can I do to remedy this situation? Thanks in advance for the help!
There is a parameter in lmplot called truncate which restricts the graph boundary to the data. Thanks for the help!
truncate: bool, optional
By default, the regression line is drawn to fill the x axis limits after the scatterplot is drawn. If truncate is True, it will instead by bounded by the data limits.
sns.lmplot(x = 'year', y = 'monthtotal', col = 'stationame',
data = ridership_year, truncate = True,
col_wrap = 5)
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.