如何绘制并排分组的条形图

时间:2020-10-06 22:02:28

标签: python pandas matplotlib

df <- structure(list(Date = c("9/09", "9/09", "10/09", "10/09"), Gulf = c("G", 
"S", "G", "S"), Calf = c(2L, 1L, 5L, 3L), Adult = c(18L, 20L,
2L, 2L), ALL = c(20L, 21L, 7L, 5L)), class = "data.frame", row.names = c("1",
"2", "3", "4"))

enter image description here

我正在尝试制作一个条形图,其中每组条形图的等级都不相同,并且在每组条形图中根据家庭收入进行划分。因此,总共有6条,2组条,每组3条。我在上面的Marplot绘制了其中的一个,但是我该如何为两者做呢?

1 个答案:

答案 0 :(得分:3)

尝试一下,转置和绘制熊猫图:

{
    "requestId": "11724082196092058876",
    "payload": {
        "agentUserId": "xxxxxx",
        "devices": [
            {
                "id": "10.0.6.252",
                "type": "action.devices.types.STREAMING_STICK",
                "traits": [
                    "action.devices.traits.TransportControl",
                    "action.devices.traits.Volume",
                    "action.devices.traits.MediaState"
                ],
                "name": {
                    "name": "Bedroom Stick"
                },
                "willReportState": true,
                "roomHint": "bedroom",
                "attributes": {
                    "transportControlSupportedCommands": [
                        "NEXT",
                        "PREVIOUS",
                        "PAUSE",
                        "STOP",
                        "RESUME",
                        "CAPTION_CONTROL",
                        "SEEK_TO_POSITION",
                        "SEEK_RELATIVE",
                        "SET_REPEAT",
                        "SHUFFLE"
                    ],
                    "volumeMaxLevel": 100,
                    "volumeCanMuteAndUnmute": true,
                    "levelStepSize": 10,
                    "commandOnlyVolume": false,
                    "volumeDefaultPercentage": 100,
                    "supportActivityState": false,
                    "supportPlaybackState": true
                }
            }
        ]
    }
}

enter image description here