如何在X轴上绘制海洋柱状图和条形图的多列

时间:2019-11-05 21:15:51

标签: python plot seaborn

我正在尝试绘制Y轴与Seaborn中所有列的关系,其中箱形图和带状图位于箱形图的顶部。我想绘制类似这样的图形,但是,我想要数据框中的所有列。有谁知道如何在x轴上添加所有列而不是2列?

Plot two levels of x_ticklabels on a pandas multi-index dataframe

我能够以这种格式对数据进行多倍处理

arrays = [['L1', 'L1', 'L1', 'L1', 'L1', 'L1', 'L1', 'L1', 'L1', 'L1', 'L1', 'L1', 'L2', 'L2', 'L2', 'L2', 'L2', 'L2', 'L2', 'L2', 'L2', 'L2', 'L2', 'L2'],
      ['W1', 'W1', 'W2', 'W2', 'W3', 'W3', 'W1', 'W1', 'W2', 'W2', 'W3', 'W3', 'W1', 'W1', 'W2', 'W2', 'W3', 'W3', 'W1', 'W1', 'W2', 'W2', 'W3', 'W3'],
      ['1',   '1',  '2',  '2', '3',  '3',  '1',   '1',  '2',  '2', '3',  '3', '1',   '1',  '2',  '2', '3',  '3', '1',   '1',  '2',  '2', '3',  '3'],
      ['A',   'B',  'A',  'B', 'A',  'B', 'A',   'B',  'A',  'B', 'A',  'B', 'A',   'B',  'A',  'B', 'A',  'B', 'A',   'B',  'A',  'B', 'A',  'B'] 
]

index = pd.MultiIndex.from_arrays(arrays, names=   ('LOT', 'Wafer', 'Wire_Width', 'Penetration_Depth'))
df = pd.DataFrame({'Y_axis': [10,     5,    2,    6,   3,    4,   11,     3,    4,    3,   7,    5,  9,     3,    4,    5,    4,    3, 10.4,   2.4,    3.4,    4.5,   6.1,    3.9]}, index=index)
df

这是数据的字典

data = {'Lot': {0: 'L1', 1: 'L1', 2: 'L1', 3: 'L1', 4: 'L1', 5: 'L1',    6: 'L1', 7: 'L1', 8: 'L1', 9: 'L1', 10: 'L1', 11: 'L1', 12: 'L2', 13: 'L2', 14: 'L2', 15: 'L2', 16: 'L2', 17: 'L2', 18: 'L2', 19: 'L2', 20: 'L2', 21: 'L2', 22: 'L2', 23: 'L2'}, 'Wafer': {0: 'W1', 1: 'W1', 2: 'W2', 3: 'W2', 4: 'W3', 5: 'W3', 6: 'W1', 7: 'W1', 8: 'W2', 9: 'W2', 10: 'W3', 11: 'W3', 12: 'W1', 13: 'W1', 14: 'W2', 15: 'W2', 16: 'W3', 17: 'W3', 18: 'W1', 19: 'W1', 20: 'W2', 21: 'W2', 22: 'W3', 23: 'W3'}, 'Wire_Width': {0: '1', 1: '1', 2: '2', 3: '2', 4: '3', 5: '3', 6: '1', 7: '1', 8: '2', 9: '2', 10: '3', 11: '3', 12: '1', 13: '1', 14: '2', 15: '2', 16: '3', 17: '3', 18: '1', 19: '1', 20: '2', 21: '2', 22: '3', 23: '3'}, 'Penetration_Type': {0: 'A', 1: 'B', 2: 'A', 3: 'B', 4: 'A', 5: 'B', 6: 'A', 7: 'B', 8: 'A', 9: 'B', 10: 'A', 11: 'B', 12: 'A', 13: 'B', 14: 'A', 15: 'B', 16: 'A', 17: 'B', 18: 'A', 19: 'B', 20: 'A', 21: 'B', 22: 'A', 23: 'B'}, 'Y_axis': {0: 10.0, 1: 5.0, 2: 2.0, 3: 6.0, 4: 3.0, 5: 4.0, 6: 11.0, 7: 3.0, 8: 4.0, 9: 3.0, 10: 7.0, 11: 5.0, 12: 9.0, 13: 3.0, 14: 4.0, 15: 5.0, 16: 4.0, 17: 3.0, 18: 10.4, 19: 2.4, 20: 3.4, 21: 4.5, 22: 6.1, 23: 3.9}}

dataDf = pd.DataFrame(data)

0 个答案:

没有答案