Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
329 views
in Technique[技术] by (71.8m points)

pandas - Treating outlier value while plotting line chart in seaborn Python

I have the following data set that I would like to plot: column growth rate is in % meaning 0.01 = 1%

month      country       growth_rate
2018-01    DE            0.01
2018-02    DE            0.05
2018-03    DE            0.07
2018-01    IN            0.01
2019-02    IN            325.01
2019-03    IN            0.05

Now I will plot the above data with the following code : sns.lineplot(data=df, x="month", y="growth_rate", hue="country") But the chart I am getting is too skewed for the country IN as one of the values is too huge- 325.01 and the rest of the values are suppressed by that and not shown correctly on the trend

What is the best way to treat this? Can I scale down somehow to still show the impact of that huge growth and also show the trend of other values in the data frame?

question from:https://stackoverflow.com/questions/65946525/treating-outlier-value-while-plotting-line-chart-in-seaborn-python

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

How about setting a log scale on the y-axis?

fig, ax = plt.subplots()

ax.set(yscale="log")

sns.lineplot(data=df, x="month", y="growth_rate", ax = ax, hue="country")

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...