Reputation: 10373
I'm working on this kaggle dataset on the EDA.
I´m working with some boxplot in pandas with this code:
coupon_list[["CATALOG_PRICE","VALIDEND_MONTH"]].boxplot(by='VALIDEND_MONTH')
The problem I'm havaing here is that the y axes has a large scale and it hard to read the plot. Is there any way to limit the sixze of this axis? something similar to ylim ?
EDIT:
The dataset have outliers, adding the argument:
showfliers=False
Seems to solve the issue.
Upvotes: 1
Views: 3129
Reputation: 21888
It's weird since by default the Y axis is autoscaled, see the example below. Maybe you have some outliers in your data. Could you share more code?
import pandas as pd
import numpy as np
np.random.seed = 4
df = pd.DataFrame(np.random.randint(0,100,size=(100, 4)), columns=list('ABCD'))
ax = df.boxplot()
Here is the same plot with outliers
# Generating some outliers
df.loc[0] = df.loc[0] * 10
ax = df.boxplot()
Could you try the showfliers
option to plot the box without outliers? In this example the Y scale is back to [0-100].
ax = df.boxplot(showfliers=False)
showfliers
: bool, optional (True
) Show the outliers beyond the caps. matplotlib.axes.Axes.boxplot
Upvotes: 2