Skip to content
Advertisement

Pandas secondary y axis for boxplots

I’d like to use a secondary y-axis for some boxplots in pandas, but it doesn’t seem available.

JavaScript

Now, using the default line plot it’s easy enough to plot to a second y-axis:

JavaScript

normal line plot

But if I use boxplot style, it doesn’t work:

JavaScript

box plot without second yaxis

Is there any way (maybe through matplotlib) I can get pandas to plot 2 axes for boxplot? Using the boxplot() method would be preferable, but I’ll take plot(). Thanks.

Advertisement

Answer

Actually not that hard with matplotlib.

JavaScript

There’s still some cleanup with the styling, ticklabels etc. But that should get you started.

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement