10

Is it possible to set ylim parameters on a seaborn boxplot?

as an example:

y = np.random.randn(300)
sns.boxplot (y=y)

Displays

boxplot

but if I try

ax.set_ylim=(-5, 5)

It makes no difference. Is it possible to set ylim values for a boxplot different from the default ones for a given dataset plot?

chrisrb10
  • 189
  • 1
  • 3
  • 12

1 Answers1

13

You use the axes-approach without having an axes-object.

Try (figure-based approach):

import matplotlib.pyplot as plt
plt.ylim([-5,5])

or probably better in your case:

ax = sns.boxplot (y=y)
ax.set_ylim([-5, 5])      # function! your code-sample is wrong here!

The docs here show the return-value of sns.boxplot.

And here is the general overview of matplotlib's objects.

sascha
  • 32,238
  • 6
  • 68
  • 110