I want to display two Pandas dataframes within one figure as boxplots. As each of the two dataframes has different value range, I would like to have them combined in a twinx figure.
Reduced to the minimum, I have tried the following:
import pandas as pd import numpy as np import matplotlib.pyplot as plt df1 = pd.DataFrame(np.random.randint(0,100,size=(100, 4)), columns=list('ABCD')) df2 = pd.DataFrame(np.random.randint(100,200,size=(100, 2)), columns=list('EF')) fig, ax1 = plt.subplots() ax2 = ax1.twinx() df1.boxplot(ax=ax1) df2.boxplot(ax=ax2) plt.show() The result is expectedly not what it should look like (there should be 6 boxes on the plot, actually!)
How can I manage to have the boxplots next to each other? I tried to set some dummy scatter points on ax1 and ax2, but this did not really help.

