Hướng dẫn multiple stacked bar chart python - nhiều python biểu đồ thanh xếp chồng lên nhau

Điều này sẽ hoạt động theo cách bạn muốn:

import pandas as pd

df = pd.DataFrame[dict[
    A=[1, 2, 3, 4],
    B=[2, 3, 4, 5],
    C=[3, 4, 5, 6],
    D=[4, 5, 6, 7]]]

import matplotlib.pyplot as plt
%matplotlib inline
fig = plt.figure[figsize=[20, 10]]

ab_bar_list = [plt.bar[[0, 1, 2, 3], df.B, align='edge', width= 0.2],
               plt.bar[[0, 1, 2, 3], df.A, align='edge', width= 0.2]]

cd_bar_list = [plt.bar[[0, 1, 2, 3], df.D, align='edge',width= -0.2],
               plt.bar[[0, 1, 2, 3], df.C, align='edge',width= -0.2]]

Chỉ cần ghi nhớ, giá trị width cho một nhóm phải là tích cực và tiêu cực cho nhóm thứ hai. Sử dụng align bằng edge là tốt. Bạn phải đặt thanh với các giá trị lớn nhất trước thanh với các giá trị thấp nhất và nếu bạn muốn các thanh xuất hiện xếp chồng lên nhau chứ không phải là một giá trị khác, hãy thay đổi df.Bdf.D thành df.B + df.Adf.D + df.C, tương ứng. Nếu không có mẫu rõ ràng hoặc bao gồm, hãy sử dụng phương thức align bằng edgewidth với phương pháp được đề xuất bởi @pirsquared. Một giải pháp khác là truy cập từng giá trị từ thanh màu xanh lá cây và so sánh nó với giá trị tương ứng từ thanh màu đỏ và vẽ đồ thị phù hợp [quá nhiều công việc không cần thiết trong cái này].
You have to place the bar with the biggest values before the bar with the lowest values, and if you want the bars to appear stacked above one another rather than one in front of another, change df.B and df.D to df.B + df.A and df.D + df.C, respectively. If there's no apparent or consisting pattern, use the align by edge and width method with the one suggested by @piRSquared.
Another alternative would be to access each value from a green bar and compare it to the corresponding value from the red bar, and plot accordingly [too much unnecessary work in this one].

# libraries
import numpy as np
import matplotlib.pyplot as plt
from matplotlib import rc
import pandas as pd
 
# y-axis in bold
rc['font', weight='bold']
 
# Values of each group
bars1 = [12, 28, 1, 8, 22]
bars2 = [28, 7, 16, 4, 10]
bars3 = [25, 3, 23, 25, 17]
 
# Heights of bars1 + bars2
bars = np.add[bars1, bars2].tolist[]
 
# The position of the bars on the x-axis
r = [0,1,2,3,4]
 
# Names of group and bar width
names = ['A','B','C','D','E']
barWidth = 1
 
# Create brown bars
plt.bar[r, bars1, color='#7f6d5f', edgecolor='white', width=barWidth]
# Create green bars [middle], on top of the first ones
plt.bar[r, bars2, bottom=bars1, color='#557f2d', edgecolor='white', width=barWidth]
# Create green bars [top]
plt.bar[r, bars3, bottom=bars, color='#2d7f5e', edgecolor='white', width=barWidth]
 
# Custom X axis
plt.xticks[r, names, fontweight='bold']
plt.xlabel["group"]
 
# Show graphic
plt.show[]

Xem thảo luận

Cải thiện bài viết

Lưu bài viết

  • Đọc
  • Bàn luận
  • Xem thảo luận

    Cải thiện bài viết

    Lưu bài viết

    Đọc

    • Bàn luận
    • Trong bài viết này, chúng tôi sẽ học cách tạo ra một cốt truyện xếp chồng lên nhau trong matplotlib. Hãy để thảo luận về một số khái niệm:
    • Matplotlib là một thư viện trực quan to lớn trong Python cho các lô 2D của mảng. Matplotlib có thể là một thư viện trực quan hóa dữ liệu đa nền tảng được xây dựng trên các mảng numpy và được thiết kế để tìm ra ngăn xếp Scipy rộng hơn.

    Approach:

    1. Biểu đồ thanh hoặc biểu đồ thanh có thể là một biểu đồ đại diện cho danh mục kiến ​​thức với các thanh hình chữ nhật có độ dài và độ cao mà tỷ lệ thuận với các giá trị mà chúng đại diện. Các ô thanh thường được vẽ theo chiều ngang hoặc chiều dọc.
    2. Các ô thanh xếp chồng lên nhau đại diện cho các nhóm khác nhau ở mức cao nhất trong số 1 người khác. Đỉnh của thanh phụ thuộc vào chiều cao kết quả của hỗn hợp kết quả của các nhóm. Nó đi từ đáy đá đến giá trị thay vì đi từ 0 đến giá trị.
    3. Thư viện nhập [Matplotlib]

    Nhập / tạo dữ liệu.

    Python3

    Vẽ các thanh theo cách ngăn xếp.

    Ví dụ 1: [lô thanh xếp chồng đơn giản]

    # libraries
    import numpy as np
    import matplotlib.pyplot as plt
    from matplotlib import rc
    import pandas as pd
     
    # y-axis in bold
    rc['font', weight='bold']
     
    # Values of each group
    bars1 = [12, 28, 1, 8, 22]
    bars2 = [28, 7, 16, 4, 10]
    bars3 = [25, 3, 23, 25, 17]
     
    # Heights of bars1 + bars2
    bars = np.add[bars1, bars2].tolist[]
     
    # The position of the bars on the x-axis
    r = [0,1,2,3,4]
     
    # Names of group and bar width
    names = ['A','B','C','D','E']
    barWidth = 1
     
    # Create brown bars
    plt.bar[r, bars1, color='#7f6d5f', edgecolor='white', width=barWidth]
    # Create green bars [middle], on top of the first ones
    plt.bar[r, bars2, bottom=bars1, color='#557f2d', edgecolor='white', width=barWidth]
    # Create green bars [top]
    plt.bar[r, bars3, bottom=bars, color='#2d7f5e', edgecolor='white', width=barWidth]
     
    # Custom X axis
    plt.xticks[r, names, fontweight='bold']
    plt.xlabel["group"]
     
    # Show graphic
    plt.show[]
    3
    # libraries
    import numpy as np
    import matplotlib.pyplot as plt
    from matplotlib import rc
    import pandas as pd
     
    # y-axis in bold
    rc['font', weight='bold']
     
    # Values of each group
    bars1 = [12, 28, 1, 8, 22]
    bars2 = [28, 7, 16, 4, 10]
    bars3 = [25, 3, 23, 25, 17]
     
    # Heights of bars1 + bars2
    bars = np.add[bars1, bars2].tolist[]
     
    # The position of the bars on the x-axis
    r = [0,1,2,3,4]
     
    # Names of group and bar width
    names = ['A','B','C','D','E']
    barWidth = 1
     
    # Create brown bars
    plt.bar[r, bars1, color='#7f6d5f', edgecolor='white', width=barWidth]
    # Create green bars [middle], on top of the first ones
    plt.bar[r, bars2, bottom=bars1, color='#557f2d', edgecolor='white', width=barWidth]
    # Create green bars [top]
    plt.bar[r, bars3, bottom=bars, color='#2d7f5e', edgecolor='white', width=barWidth]
     
    # Custom X axis
    plt.xticks[r, names, fontweight='bold']
    plt.xlabel["group"]
     
    # Show graphic
    plt.show[]
    4

    # libraries
    import numpy as np
    import matplotlib.pyplot as plt
    from matplotlib import rc
    import pandas as pd
     
    # y-axis in bold
    rc['font', weight='bold']
     
    # Values of each group
    bars1 = [12, 28, 1, 8, 22]
    bars2 = [28, 7, 16, 4, 10]
    bars3 = [25, 3, 23, 25, 17]
     
    # Heights of bars1 + bars2
    bars = np.add[bars1, bars2].tolist[]
     
    # The position of the bars on the x-axis
    r = [0,1,2,3,4]
     
    # Names of group and bar width
    names = ['A','B','C','D','E']
    barWidth = 1
     
    # Create brown bars
    plt.bar[r, bars1, color='#7f6d5f', edgecolor='white', width=barWidth]
    # Create green bars [middle], on top of the first ones
    plt.bar[r, bars2, bottom=bars1, color='#557f2d', edgecolor='white', width=barWidth]
    # Create green bars [top]
    plt.bar[r, bars3, bottom=bars, color='#2d7f5e', edgecolor='white', width=barWidth]
     
    # Custom X axis
    plt.xticks[r, names, fontweight='bold']
    plt.xlabel["group"]
     
    # Show graphic
    plt.show[]
    5
    # libraries
    import numpy as np
    import matplotlib.pyplot as plt
    from matplotlib import rc
    import pandas as pd
     
    # y-axis in bold
    rc['font', weight='bold']
     
    # Values of each group
    bars1 = [12, 28, 1, 8, 22]
    bars2 = [28, 7, 16, 4, 10]
    bars3 = [25, 3, 23, 25, 17]
     
    # Heights of bars1 + bars2
    bars = np.add[bars1, bars2].tolist[]
     
    # The position of the bars on the x-axis
    r = [0,1,2,3,4]
     
    # Names of group and bar width
    names = ['A','B','C','D','E']
    barWidth = 1
     
    # Create brown bars
    plt.bar[r, bars1, color='#7f6d5f', edgecolor='white', width=barWidth]
    # Create green bars [middle], on top of the first ones
    plt.bar[r, bars2, bottom=bars1, color='#557f2d', edgecolor='white', width=barWidth]
    # Create green bars [top]
    plt.bar[r, bars3, bottom=bars, color='#2d7f5e', edgecolor='white', width=barWidth]
     
    # Custom X axis
    plt.xticks[r, names, fontweight='bold']
    plt.xlabel["group"]
     
    # Show graphic
    plt.show[]
    6
    # libraries
    import numpy as np
    import matplotlib.pyplot as plt
    from matplotlib import rc
    import pandas as pd
     
    # y-axis in bold
    rc['font', weight='bold']
     
    # Values of each group
    bars1 = [12, 28, 1, 8, 22]
    bars2 = [28, 7, 16, 4, 10]
    bars3 = [25, 3, 23, 25, 17]
     
    # Heights of bars1 + bars2
    bars = np.add[bars1, bars2].tolist[]
     
    # The position of the bars on the x-axis
    r = [0,1,2,3,4]
     
    # Names of group and bar width
    names = ['A','B','C','D','E']
    barWidth = 1
     
    # Create brown bars
    plt.bar[r, bars1, color='#7f6d5f', edgecolor='white', width=barWidth]
    # Create green bars [middle], on top of the first ones
    plt.bar[r, bars2, bottom=bars1, color='#557f2d', edgecolor='white', width=barWidth]
    # Create green bars [top]
    plt.bar[r, bars3, bottom=bars, color='#2d7f5e', edgecolor='white', width=barWidth]
     
    # Custom X axis
    plt.xticks[r, names, fontweight='bold']
    plt.xlabel["group"]
     
    # Show graphic
    plt.show[]
    7
    # libraries
    import numpy as np
    import matplotlib.pyplot as plt
    from matplotlib import rc
    import pandas as pd
     
    # y-axis in bold
    rc['font', weight='bold']
     
    # Values of each group
    bars1 = [12, 28, 1, 8, 22]
    bars2 = [28, 7, 16, 4, 10]
    bars3 = [25, 3, 23, 25, 17]
     
    # Heights of bars1 + bars2
    bars = np.add[bars1, bars2].tolist[]
     
    # The position of the bars on the x-axis
    r = [0,1,2,3,4]
     
    # Names of group and bar width
    names = ['A','B','C','D','E']
    barWidth = 1
     
    # Create brown bars
    plt.bar[r, bars1, color='#7f6d5f', edgecolor='white', width=barWidth]
    # Create green bars [middle], on top of the first ones
    plt.bar[r, bars2, bottom=bars1, color='#557f2d', edgecolor='white', width=barWidth]
    # Create green bars [top]
    plt.bar[r, bars3, bottom=bars, color='#2d7f5e', edgecolor='white', width=barWidth]
     
    # Custom X axis
    plt.xticks[r, names, fontweight='bold']
    plt.xlabel["group"]
     
    # Show graphic
    plt.show[]
    8
    # libraries
    import numpy as np
    import matplotlib.pyplot as plt
    from matplotlib import rc
    import pandas as pd
     
    # y-axis in bold
    rc['font', weight='bold']
     
    # Values of each group
    bars1 = [12, 28, 1, 8, 22]
    bars2 = [28, 7, 16, 4, 10]
    bars3 = [25, 3, 23, 25, 17]
     
    # Heights of bars1 + bars2
    bars = np.add[bars1, bars2].tolist[]
     
    # The position of the bars on the x-axis
    r = [0,1,2,3,4]
     
    # Names of group and bar width
    names = ['A','B','C','D','E']
    barWidth = 1
     
    # Create brown bars
    plt.bar[r, bars1, color='#7f6d5f', edgecolor='white', width=barWidth]
    # Create green bars [middle], on top of the first ones
    plt.bar[r, bars2, bottom=bars1, color='#557f2d', edgecolor='white', width=barWidth]
    # Create green bars [top]
    plt.bar[r, bars3, bottom=bars, color='#2d7f5e', edgecolor='white', width=barWidth]
     
    # Custom X axis
    plt.xticks[r, names, fontweight='bold']
    plt.xlabel["group"]
     
    # Show graphic
    plt.show[]
    9
      Team  Round 1  Round 2  Round 3  Round 4
    0    A       10       20       10       26
    1    B       20       25       15       21
    2    C       12       15       19        6
    3    D       10       18       11       19
    0
    # libraries
    import numpy as np
    import matplotlib.pyplot as plt
    from matplotlib import rc
    import pandas as pd
     
    # y-axis in bold
    rc['font', weight='bold']
     
    # Values of each group
    bars1 = [12, 28, 1, 8, 22]
    bars2 = [28, 7, 16, 4, 10]
    bars3 = [25, 3, 23, 25, 17]
     
    # Heights of bars1 + bars2
    bars = np.add[bars1, bars2].tolist[]
     
    # The position of the bars on the x-axis
    r = [0,1,2,3,4]
     
    # Names of group and bar width
    names = ['A','B','C','D','E']
    barWidth = 1
     
    # Create brown bars
    plt.bar[r, bars1, color='#7f6d5f', edgecolor='white', width=barWidth]
    # Create green bars [middle], on top of the first ones
    plt.bar[r, bars2, bottom=bars1, color='#557f2d', edgecolor='white', width=barWidth]
    # Create green bars [top]
    plt.bar[r, bars3, bottom=bars, color='#2d7f5e', edgecolor='white', width=barWidth]
     
    # Custom X axis
    plt.xticks[r, names, fontweight='bold']
    plt.xlabel["group"]
     
    # Show graphic
    plt.show[]
    9
      Team  Round 1  Round 2  Round 3  Round 4
    0    A       10       20       10       26
    1    B       20       25       15       21
    2    C       12       15       19        6
    3    D       10       18       11       19
    222

    align8

    # libraries
    import numpy as np
    import matplotlib.pyplot as plt
    from matplotlib import rc
    import pandas as pd
     
    # y-axis in bold
    rc['font', weight='bold']
     
    # Values of each group
    bars1 = [12, 28, 1, 8, 22]
    bars2 = [28, 7, 16, 4, 10]
    bars3 = [25, 3, 23, 25, 17]
     
    # Heights of bars1 + bars2
    bars = np.add[bars1, bars2].tolist[]
     
    # The position of the bars on the x-axis
    r = [0,1,2,3,4]
     
    # Names of group and bar width
    names = ['A','B','C','D','E']
    barWidth = 1
     
    # Create brown bars
    plt.bar[r, bars1, color='#7f6d5f', edgecolor='white', width=barWidth]
    # Create green bars [middle], on top of the first ones
    plt.bar[r, bars2, bottom=bars1, color='#557f2d', edgecolor='white', width=barWidth]
    # Create green bars [top]
    plt.bar[r, bars3, bottom=bars, color='#2d7f5e', edgecolor='white', width=barWidth]
     
    # Custom X axis
    plt.xticks[r, names, fontweight='bold']
    plt.xlabel["group"]
     
    # Show graphic
    plt.show[]
    6edge0edge1

    edge2

    # libraries
    import numpy as np
    import matplotlib.pyplot as plt
    from matplotlib import rc
    import pandas as pd
     
    # y-axis in bold
    rc['font', weight='bold']
     
    # Values of each group
    bars1 = [12, 28, 1, 8, 22]
    bars2 = [28, 7, 16, 4, 10]
    bars3 = [25, 3, 23, 25, 17]
     
    # Heights of bars1 + bars2
    bars = np.add[bars1, bars2].tolist[]
     
    # The position of the bars on the x-axis
    r = [0,1,2,3,4]
     
    # Names of group and bar width
    names = ['A','B','C','D','E']
    barWidth = 1
     
    # Create brown bars
    plt.bar[r, bars1, color='#7f6d5f', edgecolor='white', width=barWidth]
    # Create green bars [middle], on top of the first ones
    plt.bar[r, bars2, bottom=bars1, color='#557f2d', edgecolor='white', width=barWidth]
    # Create green bars [top]
    plt.bar[r, bars3, bottom=bars, color='#2d7f5e', edgecolor='white', width=barWidth]
     
    # Custom X axis
    plt.xticks[r, names, fontweight='bold']
    plt.xlabel["group"]
     
    # Show graphic
    plt.show[]
    6edge4
    # libraries
    import numpy as np
    import matplotlib.pyplot as plt
    from matplotlib import rc
    import pandas as pd
     
    # y-axis in bold
    rc['font', weight='bold']
     
    # Values of each group
    bars1 = [12, 28, 1, 8, 22]
    bars2 = [28, 7, 16, 4, 10]
    bars3 = [25, 3, 23, 25, 17]
     
    # Heights of bars1 + bars2
    bars = np.add[bars1, bars2].tolist[]
     
    # The position of the bars on the x-axis
    r = [0,1,2,3,4]
     
    # Names of group and bar width
    names = ['A','B','C','D','E']
    barWidth = 1
     
    # Create brown bars
    plt.bar[r, bars1, color='#7f6d5f', edgecolor='white', width=barWidth]
    # Create green bars [middle], on top of the first ones
    plt.bar[r, bars2, bottom=bars1, color='#557f2d', edgecolor='white', width=barWidth]
    # Create green bars [top]
    plt.bar[r, bars3, bottom=bars, color='#2d7f5e', edgecolor='white', width=barWidth]
     
    # Custom X axis
    plt.xticks[r, names, fontweight='bold']
    plt.xlabel["group"]
     
    # Show graphic
    plt.show[]
    6edge6edge1

    edge8

    Đầu ra:

      Team  Round 1  Round 2  Round 3  Round 4
    0    A       10       20       10       26
    1    B       20       25       15       21
    2    C       12       15       19        6
    3    D       10       18       11       19
    6
    # libraries
    import numpy as np
    import matplotlib.pyplot as plt
    from matplotlib import rc
    import pandas as pd
     
    # y-axis in bold
    rc['font', weight='bold']
     
    # Values of each group
    bars1 = [12, 28, 1, 8, 22]
    bars2 = [28, 7, 16, 4, 10]
    bars3 = [25, 3, 23, 25, 17]
     
    # Heights of bars1 + bars2
    bars = np.add[bars1, bars2].tolist[]
     
    # The position of the bars on the x-axis
    r = [0,1,2,3,4]
     
    # Names of group and bar width
    names = ['A','B','C','D','E']
    barWidth = 1
     
    # Create brown bars
    plt.bar[r, bars1, color='#7f6d5f', edgecolor='white', width=barWidth]
    # Create green bars [middle], on top of the first ones
    plt.bar[r, bars2, bottom=bars1, color='#557f2d', edgecolor='white', width=barWidth]
    # Create green bars [top]
    plt.bar[r, bars3, bottom=bars, color='#2d7f5e', edgecolor='white', width=barWidth]
     
    # Custom X axis
    plt.xticks[r, names, fontweight='bold']
    plt.xlabel["group"]
     
    # Show graphic
    plt.show[]
    6
    # libraries
    import numpy as np
    import matplotlib.pyplot as plt
    from matplotlib import rc
    import pandas as pd
     
    # y-axis in bold
    rc['font', weight='bold']
     
    # Values of each group
    bars1 = [12, 28, 1, 8, 22]
    bars2 = [28, 7, 16, 4, 10]
    bars3 = [25, 3, 23, 25, 17]
     
    # Heights of bars1 + bars2
    bars = np.add[bars1, bars2].tolist[]
     
    # The position of the bars on the x-axis
    r = [0,1,2,3,4]
     
    # Names of group and bar width
    names = ['A','B','C','D','E']
    barWidth = 1
     
    # Create brown bars
    plt.bar[r, bars1, color='#7f6d5f', edgecolor='white', width=barWidth]
    # Create green bars [middle], on top of the first ones
    plt.bar[r, bars2, bottom=bars1, color='#557f2d', edgecolor='white', width=barWidth]
    # Create green bars [top]
    plt.bar[r, bars3, bottom=bars, color='#2d7f5e', edgecolor='white', width=barWidth]
     
    # Custom X axis
    plt.xticks[r, names, fontweight='bold']
    plt.xlabel["group"]
     
    # Show graphic
    plt.show[]
    7
      Team  Round 1  Round 2  Round 3  Round 4
    0    A       10       20       10       26
    1    B       20       25       15       21
    2    C       12       15       19        6
    3    D       10       18       11       19
    9
    # libraries
    import numpy as np
    import matplotlib.pyplot as plt
    from matplotlib import rc
    import pandas as pd
     
    # y-axis in bold
    rc['font', weight='bold']
     
    # Values of each group
    bars1 = [12, 28, 1, 8, 22]
    bars2 = [28, 7, 16, 4, 10]
    bars3 = [25, 3, 23, 25, 17]
     
    # Heights of bars1 + bars2
    bars = np.add[bars1, bars2].tolist[]
     
    # The position of the bars on the x-axis
    r = [0,1,2,3,4]
     
    # Names of group and bar width
    names = ['A','B','C','D','E']
    barWidth = 1
     
    # Create brown bars
    plt.bar[r, bars1, color='#7f6d5f', edgecolor='white', width=barWidth]
    # Create green bars [middle], on top of the first ones
    plt.bar[r, bars2, bottom=bars1, color='#557f2d', edgecolor='white', width=barWidth]
    # Create green bars [top]
    plt.bar[r, bars3, bottom=bars, color='#2d7f5e', edgecolor='white', width=barWidth]
     
    # Custom X axis
    plt.xticks[r, names, fontweight='bold']
    plt.xlabel["group"]
     
    # Show graphic
    plt.show[]
    9width1
    # libraries
    import numpy as np
    import matplotlib.pyplot as plt
    from matplotlib import rc
    import pandas as pd
     
    # y-axis in bold
    rc['font', weight='bold']
     
    # Values of each group
    bars1 = [12, 28, 1, 8, 22]
    bars2 = [28, 7, 16, 4, 10]
    bars3 = [25, 3, 23, 25, 17]
     
    # Heights of bars1 + bars2
    bars = np.add[bars1, bars2].tolist[]
     
    # The position of the bars on the x-axis
    r = [0,1,2,3,4]
     
    # Names of group and bar width
    names = ['A','B','C','D','E']
    barWidth = 1
     
    # Create brown bars
    plt.bar[r, bars1, color='#7f6d5f', edgecolor='white', width=barWidth]
    # Create green bars [middle], on top of the first ones
    plt.bar[r, bars2, bottom=bars1, color='#557f2d', edgecolor='white', width=barWidth]
    # Create green bars [top]
    plt.bar[r, bars3, bottom=bars, color='#2d7f5e', edgecolor='white', width=barWidth]
     
    # Custom X axis
    plt.xticks[r, names, fontweight='bold']
    plt.xlabel["group"]
     
    # Show graphic
    plt.show[]
    9
      Team  Round 1  Round 2  Round 3  Round 4
    0    A       10       20       10       26
    1    B       20       25       15       21
    2    C       12       15       19        6
    3    D       10       18       11       19
    9
    # libraries
    import numpy as np
    import matplotlib.pyplot as plt
    from matplotlib import rc
    import pandas as pd
     
    # y-axis in bold
    rc['font', weight='bold']
     
    # Values of each group
    bars1 = [12, 28, 1, 8, 22]
    bars2 = [28, 7, 16, 4, 10]
    bars3 = [25, 3, 23, 25, 17]
     
    # Heights of bars1 + bars2
    bars = np.add[bars1, bars2].tolist[]
     
    # The position of the bars on the x-axis
    r = [0,1,2,3,4]
     
    # Names of group and bar width
    names = ['A','B','C','D','E']
    barWidth = 1
     
    # Create brown bars
    plt.bar[r, bars1, color='#7f6d5f', edgecolor='white', width=barWidth]
    # Create green bars [middle], on top of the first ones
    plt.bar[r, bars2, bottom=bars1, color='#557f2d', edgecolor='white', width=barWidth]
    # Create green bars [top]
    plt.bar[r, bars3, bottom=bars, color='#2d7f5e', edgecolor='white', width=barWidth]
     
    # Custom X axis
    plt.xticks[r, names, fontweight='bold']
    plt.xlabel["group"]
     
    # Show graphic
    plt.show[]
    9width5
      Team  Round 1  Round 2  Round 3  Round 4
    0    A       10       20       10       26
    1    B       20       25       15       21
    2    C       12       15       19        6
    3    D       10       18       11       19
    5

    Python3

    Vẽ các thanh theo cách ngăn xếp.

    Ví dụ 1: [lô thanh xếp chồng đơn giản]

    Ví dụ 1: [lô thanh xếp chồng đơn giản]

    # libraries
    import numpy as np
    import matplotlib.pyplot as plt
    from matplotlib import rc
    import pandas as pd
     
    # y-axis in bold
    rc['font', weight='bold']
     
    # Values of each group
    bars1 = [12, 28, 1, 8, 22]
    bars2 = [28, 7, 16, 4, 10]
    bars3 = [25, 3, 23, 25, 17]
     
    # Heights of bars1 + bars2
    bars = np.add[bars1, bars2].tolist[]
     
    # The position of the bars on the x-axis
    r = [0,1,2,3,4]
     
    # Names of group and bar width
    names = ['A','B','C','D','E']
    barWidth = 1
     
    # Create brown bars
    plt.bar[r, bars1, color='#7f6d5f', edgecolor='white', width=barWidth]
    # Create green bars [middle], on top of the first ones
    plt.bar[r, bars2, bottom=bars1, color='#557f2d', edgecolor='white', width=barWidth]
    # Create green bars [top]
    plt.bar[r, bars3, bottom=bars, color='#2d7f5e', edgecolor='white', width=barWidth]
     
    # Custom X axis
    plt.xticks[r, names, fontweight='bold']
    plt.xlabel["group"]
     
    # Show graphic
    plt.show[]
    3
    # libraries
    import numpy as np
    import matplotlib.pyplot as plt
    from matplotlib import rc
    import pandas as pd
     
    # y-axis in bold
    rc['font', weight='bold']
     
    # Values of each group
    bars1 = [12, 28, 1, 8, 22]
    bars2 = [28, 7, 16, 4, 10]
    bars3 = [25, 3, 23, 25, 17]
     
    # Heights of bars1 + bars2
    bars = np.add[bars1, bars2].tolist[]
     
    # The position of the bars on the x-axis
    r = [0,1,2,3,4]
     
    # Names of group and bar width
    names = ['A','B','C','D','E']
    barWidth = 1
     
    # Create brown bars
    plt.bar[r, bars1, color='#7f6d5f', edgecolor='white', width=barWidth]
    # Create green bars [middle], on top of the first ones
    plt.bar[r, bars2, bottom=bars1, color='#557f2d', edgecolor='white', width=barWidth]
    # Create green bars [top]
    plt.bar[r, bars3, bottom=bars, color='#2d7f5e', edgecolor='white', width=barWidth]
     
    # Custom X axis
    plt.xticks[r, names, fontweight='bold']
    plt.xlabel["group"]
     
    # Show graphic
    plt.show[]
    4

    # libraries
    import numpy as np
    import matplotlib.pyplot as plt
    from matplotlib import rc
    import pandas as pd
     
    # y-axis in bold
    rc['font', weight='bold']
     
    # Values of each group
    bars1 = [12, 28, 1, 8, 22]
    bars2 = [28, 7, 16, 4, 10]
    bars3 = [25, 3, 23, 25, 17]
     
    # Heights of bars1 + bars2
    bars = np.add[bars1, bars2].tolist[]
     
    # The position of the bars on the x-axis
    r = [0,1,2,3,4]
     
    # Names of group and bar width
    names = ['A','B','C','D','E']
    barWidth = 1
     
    # Create brown bars
    plt.bar[r, bars1, color='#7f6d5f', edgecolor='white', width=barWidth]
    # Create green bars [middle], on top of the first ones
    plt.bar[r, bars2, bottom=bars1, color='#557f2d', edgecolor='white', width=barWidth]
    # Create green bars [top]
    plt.bar[r, bars3, bottom=bars, color='#2d7f5e', edgecolor='white', width=barWidth]
     
    # Custom X axis
    plt.xticks[r, names, fontweight='bold']
    plt.xlabel["group"]
     
    # Show graphic
    plt.show[]
    5
    # libraries
    import numpy as np
    import matplotlib.pyplot as plt
    from matplotlib import rc
    import pandas as pd
     
    # y-axis in bold
    rc['font', weight='bold']
     
    # Values of each group
    bars1 = [12, 28, 1, 8, 22]
    bars2 = [28, 7, 16, 4, 10]
    bars3 = [25, 3, 23, 25, 17]
     
    # Heights of bars1 + bars2
    bars = np.add[bars1, bars2].tolist[]
     
    # The position of the bars on the x-axis
    r = [0,1,2,3,4]
     
    # Names of group and bar width
    names = ['A','B','C','D','E']
    barWidth = 1
     
    # Create brown bars
    plt.bar[r, bars1, color='#7f6d5f', edgecolor='white', width=barWidth]
    # Create green bars [middle], on top of the first ones
    plt.bar[r, bars2, bottom=bars1, color='#557f2d', edgecolor='white', width=barWidth]
    # Create green bars [top]
    plt.bar[r, bars3, bottom=bars, color='#2d7f5e', edgecolor='white', width=barWidth]
     
    # Custom X axis
    plt.xticks[r, names, fontweight='bold']
    plt.xlabel["group"]
     
    # Show graphic
    plt.show[]
    6
    # libraries
    import numpy as np
    import matplotlib.pyplot as plt
    from matplotlib import rc
    import pandas as pd
     
    # y-axis in bold
    rc['font', weight='bold']
     
    # Values of each group
    bars1 = [12, 28, 1, 8, 22]
    bars2 = [28, 7, 16, 4, 10]
    bars3 = [25, 3, 23, 25, 17]
     
    # Heights of bars1 + bars2
    bars = np.add[bars1, bars2].tolist[]
     
    # The position of the bars on the x-axis
    r = [0,1,2,3,4]
     
    # Names of group and bar width
    names = ['A','B','C','D','E']
    barWidth = 1
     
    # Create brown bars
    plt.bar[r, bars1, color='#7f6d5f', edgecolor='white', width=barWidth]
    # Create green bars [middle], on top of the first ones
    plt.bar[r, bars2, bottom=bars1, color='#557f2d', edgecolor='white', width=barWidth]
    # Create green bars [top]
    plt.bar[r, bars3, bottom=bars, color='#2d7f5e', edgecolor='white', width=barWidth]
     
    # Custom X axis
    plt.xticks[r, names, fontweight='bold']
    plt.xlabel["group"]
     
    # Show graphic
    plt.show[]
    7
    # libraries
    import numpy as np
    import matplotlib.pyplot as plt
    from matplotlib import rc
    import pandas as pd
     
    # y-axis in bold
    rc['font', weight='bold']
     
    # Values of each group
    bars1 = [12, 28, 1, 8, 22]
    bars2 = [28, 7, 16, 4, 10]
    bars3 = [25, 3, 23, 25, 17]
     
    # Heights of bars1 + bars2
    bars = np.add[bars1, bars2].tolist[]
     
    # The position of the bars on the x-axis
    r = [0,1,2,3,4]
     
    # Names of group and bar width
    names = ['A','B','C','D','E']
    barWidth = 1
     
    # Create brown bars
    plt.bar[r, bars1, color='#7f6d5f', edgecolor='white', width=barWidth]
    # Create green bars [middle], on top of the first ones
    plt.bar[r, bars2, bottom=bars1, color='#557f2d', edgecolor='white', width=barWidth]
    # Create green bars [top]
    plt.bar[r, bars3, bottom=bars, color='#2d7f5e', edgecolor='white', width=barWidth]
     
    # Custom X axis
    plt.xticks[r, names, fontweight='bold']
    plt.xlabel["group"]
     
    # Show graphic
    plt.show[]
    8
    # libraries
    import numpy as np
    import matplotlib.pyplot as plt
    from matplotlib import rc
    import pandas as pd
     
    # y-axis in bold
    rc['font', weight='bold']
     
    # Values of each group
    bars1 = [12, 28, 1, 8, 22]
    bars2 = [28, 7, 16, 4, 10]
    bars3 = [25, 3, 23, 25, 17]
     
    # Heights of bars1 + bars2
    bars = np.add[bars1, bars2].tolist[]
     
    # The position of the bars on the x-axis
    r = [0,1,2,3,4]
     
    # Names of group and bar width
    names = ['A','B','C','D','E']
    barWidth = 1
     
    # Create brown bars
    plt.bar[r, bars1, color='#7f6d5f', edgecolor='white', width=barWidth]
    # Create green bars [middle], on top of the first ones
    plt.bar[r, bars2, bottom=bars1, color='#557f2d', edgecolor='white', width=barWidth]
    # Create green bars [top]
    plt.bar[r, bars3, bottom=bars, color='#2d7f5e', edgecolor='white', width=barWidth]
     
    # Custom X axis
    plt.xticks[r, names, fontweight='bold']
    plt.xlabel["group"]
     
    # Show graphic
    plt.show[]
    9
      Team  Round 1  Round 2  Round 3  Round 4
    0    A       10       20       10       26
    1    B       20       25       15       21
    2    C       12       15       19        6
    3    D       10       18       11       19
    0
    # libraries
    import numpy as np
    import matplotlib.pyplot as plt
    from matplotlib import rc
    import pandas as pd
     
    # y-axis in bold
    rc['font', weight='bold']
     
    # Values of each group
    bars1 = [12, 28, 1, 8, 22]
    bars2 = [28, 7, 16, 4, 10]
    bars3 = [25, 3, 23, 25, 17]
     
    # Heights of bars1 + bars2
    bars = np.add[bars1, bars2].tolist[]
     
    # The position of the bars on the x-axis
    r = [0,1,2,3,4]
     
    # Names of group and bar width
    names = ['A','B','C','D','E']
    barWidth = 1
     
    # Create brown bars
    plt.bar[r, bars1, color='#7f6d5f', edgecolor='white', width=barWidth]
    # Create green bars [middle], on top of the first ones
    plt.bar[r, bars2, bottom=bars1, color='#557f2d', edgecolor='white', width=barWidth]
    # Create green bars [top]
    plt.bar[r, bars3, bottom=bars, color='#2d7f5e', edgecolor='white', width=barWidth]
     
    # Custom X axis
    plt.xticks[r, names, fontweight='bold']
    plt.xlabel["group"]
     
    # Show graphic
    plt.show[]
    9
      Team  Round 1  Round 2  Round 3  Round 4
    0    A       10       20       10       26
    1    B       20       25       15       21
    2    C       12       15       19        6
    3    D       10       18       11       19
    222

      Team  Round 1  Round 2  Round 3  Round 4
    0    A       10       20       10       26
    1    B       20       25       15       21
    2    C       12       15       19        6
    3    D       10       18       11       19
    6
    # libraries
    import numpy as np
    import matplotlib.pyplot as plt
    from matplotlib import rc
    import pandas as pd
     
    # y-axis in bold
    rc['font', weight='bold']
     
    # Values of each group
    bars1 = [12, 28, 1, 8, 22]
    bars2 = [28, 7, 16, 4, 10]
    bars3 = [25, 3, 23, 25, 17]
     
    # Heights of bars1 + bars2
    bars = np.add[bars1, bars2].tolist[]
     
    # The position of the bars on the x-axis
    r = [0,1,2,3,4]
     
    # Names of group and bar width
    names = ['A','B','C','D','E']
    barWidth = 1
     
    # Create brown bars
    plt.bar[r, bars1, color='#7f6d5f', edgecolor='white', width=barWidth]
    # Create green bars [middle], on top of the first ones
    plt.bar[r, bars2, bottom=bars1, color='#557f2d', edgecolor='white', width=barWidth]
    # Create green bars [top]
    plt.bar[r, bars3, bottom=bars, color='#2d7f5e', edgecolor='white', width=barWidth]
     
    # Custom X axis
    plt.xticks[r, names, fontweight='bold']
    plt.xlabel["group"]
     
    # Show graphic
    plt.show[]
    6
    # libraries
    import numpy as np
    import matplotlib.pyplot as plt
    from matplotlib import rc
    import pandas as pd
     
    # y-axis in bold
    rc['font', weight='bold']
     
    # Values of each group
    bars1 = [12, 28, 1, 8, 22]
    bars2 = [28, 7, 16, 4, 10]
    bars3 = [25, 3, 23, 25, 17]
     
    # Heights of bars1 + bars2
    bars = np.add[bars1, bars2].tolist[]
     
    # The position of the bars on the x-axis
    r = [0,1,2,3,4]
     
    # Names of group and bar width
    names = ['A','B','C','D','E']
    barWidth = 1
     
    # Create brown bars
    plt.bar[r, bars1, color='#7f6d5f', edgecolor='white', width=barWidth]
    # Create green bars [middle], on top of the first ones
    plt.bar[r, bars2, bottom=bars1, color='#557f2d', edgecolor='white', width=barWidth]
    # Create green bars [top]
    plt.bar[r, bars3, bottom=bars, color='#2d7f5e', edgecolor='white', width=barWidth]
     
    # Custom X axis
    plt.xticks[r, names, fontweight='bold']
    plt.xlabel["group"]
     
    # Show graphic
    plt.show[]
    7
      Team  Round 1  Round 2  Round 3  Round 4
    0    A       10       20       10       26
    1    B       20       25       15       21
    2    C       12       15       19        6
    3    D       10       18       11       19
    9
    # libraries
    import numpy as np
    import matplotlib.pyplot as plt
    from matplotlib import rc
    import pandas as pd
     
    # y-axis in bold
    rc['font', weight='bold']
     
    # Values of each group
    bars1 = [12, 28, 1, 8, 22]
    bars2 = [28, 7, 16, 4, 10]
    bars3 = [25, 3, 23, 25, 17]
     
    # Heights of bars1 + bars2
    bars = np.add[bars1, bars2].tolist[]
     
    # The position of the bars on the x-axis
    r = [0,1,2,3,4]
     
    # Names of group and bar width
    names = ['A','B','C','D','E']
    barWidth = 1
     
    # Create brown bars
    plt.bar[r, bars1, color='#7f6d5f', edgecolor='white', width=barWidth]
    # Create green bars [middle], on top of the first ones
    plt.bar[r, bars2, bottom=bars1, color='#557f2d', edgecolor='white', width=barWidth]
    # Create green bars [top]
    plt.bar[r, bars3, bottom=bars, color='#2d7f5e', edgecolor='white', width=barWidth]
     
    # Custom X axis
    plt.xticks[r, names, fontweight='bold']
    plt.xlabel["group"]
     
    # Show graphic
    plt.show[]
    9width1
    # libraries
    import numpy as np
    import matplotlib.pyplot as plt
    from matplotlib import rc
    import pandas as pd
     
    # y-axis in bold
    rc['font', weight='bold']
     
    # Values of each group
    bars1 = [12, 28, 1, 8, 22]
    bars2 = [28, 7, 16, 4, 10]
    bars3 = [25, 3, 23, 25, 17]
     
    # Heights of bars1 + bars2
    bars = np.add[bars1, bars2].tolist[]
     
    # The position of the bars on the x-axis
    r = [0,1,2,3,4]
     
    # Names of group and bar width
    names = ['A','B','C','D','E']
    barWidth = 1
     
    # Create brown bars
    plt.bar[r, bars1, color='#7f6d5f', edgecolor='white', width=barWidth]
    # Create green bars [middle], on top of the first ones
    plt.bar[r, bars2, bottom=bars1, color='#557f2d', edgecolor='white', width=barWidth]
    # Create green bars [top]
    plt.bar[r, bars3, bottom=bars, color='#2d7f5e', edgecolor='white', width=barWidth]
     
    # Custom X axis
    plt.xticks[r, names, fontweight='bold']
    plt.xlabel["group"]
     
    # Show graphic
    plt.show[]
    9
      Team  Round 1  Round 2  Round 3  Round 4
    0    A       10       20       10       26
    1    B       20       25       15       21
    2    C       12       15       19        6
    3    D       10       18       11       19
    9
    # libraries
    import numpy as np
    import matplotlib.pyplot as plt
    from matplotlib import rc
    import pandas as pd
     
    # y-axis in bold
    rc['font', weight='bold']
     
    # Values of each group
    bars1 = [12, 28, 1, 8, 22]
    bars2 = [28, 7, 16, 4, 10]
    bars3 = [25, 3, 23, 25, 17]
     
    # Heights of bars1 + bars2
    bars = np.add[bars1, bars2].tolist[]
     
    # The position of the bars on the x-axis
    r = [0,1,2,3,4]
     
    # Names of group and bar width
    names = ['A','B','C','D','E']
    barWidth = 1
     
    # Create brown bars
    plt.bar[r, bars1, color='#7f6d5f', edgecolor='white', width=barWidth]
    # Create green bars [middle], on top of the first ones
    plt.bar[r, bars2, bottom=bars1, color='#557f2d', edgecolor='white', width=barWidth]
    # Create green bars [top]
    plt.bar[r, bars3, bottom=bars, color='#2d7f5e', edgecolor='white', width=barWidth]
     
    # Custom X axis
    plt.xticks[r, names, fontweight='bold']
    plt.xlabel["group"]
     
    # Show graphic
    plt.show[]
    9width5
      Team  Round 1  Round 2  Round 3  Round 4
    0    A       10       20       10       26
    1    B       20       25       15       21
    2    C       12       15       19        6
    3    D       10       18       11       19
    5

    width7

    # libraries
    import numpy as np
    import matplotlib.pyplot as plt
    from matplotlib import rc
    import pandas as pd
     
    # y-axis in bold
    rc['font', weight='bold']
     
    # Values of each group
    bars1 = [12, 28, 1, 8, 22]
    bars2 = [28, 7, 16, 4, 10]
    bars3 = [25, 3, 23, 25, 17]
     
    # Heights of bars1 + bars2
    bars = np.add[bars1, bars2].tolist[]
     
    # The position of the bars on the x-axis
    r = [0,1,2,3,4]
     
    # Names of group and bar width
    names = ['A','B','C','D','E']
    barWidth = 1
     
    # Create brown bars
    plt.bar[r, bars1, color='#7f6d5f', edgecolor='white', width=barWidth]
    # Create green bars [middle], on top of the first ones
    plt.bar[r, bars2, bottom=bars1, color='#557f2d', edgecolor='white', width=barWidth]
    # Create green bars [top]
    plt.bar[r, bars3, bottom=bars, color='#2d7f5e', edgecolor='white', width=barWidth]
     
    # Custom X axis
    plt.xticks[r, names, fontweight='bold']
    plt.xlabel["group"]
     
    # Show graphic
    plt.show[]
    6
    # libraries
    import numpy as np
    import matplotlib.pyplot as plt
    from matplotlib import rc
    import pandas as pd
     
    # y-axis in bold
    rc['font', weight='bold']
     
    # Values of each group
    bars1 = [12, 28, 1, 8, 22]
    bars2 = [28, 7, 16, 4, 10]
    bars3 = [25, 3, 23, 25, 17]
     
    # Heights of bars1 + bars2
    bars = np.add[bars1, bars2].tolist[]
     
    # The position of the bars on the x-axis
    r = [0,1,2,3,4]
     
    # Names of group and bar width
    names = ['A','B','C','D','E']
    barWidth = 1
     
    # Create brown bars
    plt.bar[r, bars1, color='#7f6d5f', edgecolor='white', width=barWidth]
    # Create green bars [middle], on top of the first ones
    plt.bar[r, bars2, bottom=bars1, color='#557f2d', edgecolor='white', width=barWidth]
    # Create green bars [top]
    plt.bar[r, bars3, bottom=bars, color='#2d7f5e', edgecolor='white', width=barWidth]
     
    # Custom X axis
    plt.xticks[r, names, fontweight='bold']
    plt.xlabel["group"]
     
    # Show graphic
    plt.show[]
    7width1
    # libraries
    import numpy as np
    import matplotlib.pyplot as plt
    from matplotlib import rc
    import pandas as pd
     
    # y-axis in bold
    rc['font', weight='bold']
     
    # Values of each group
    bars1 = [12, 28, 1, 8, 22]
    bars2 = [28, 7, 16, 4, 10]
    bars3 = [25, 3, 23, 25, 17]
     
    # Heights of bars1 + bars2
    bars = np.add[bars1, bars2].tolist[]
     
    # The position of the bars on the x-axis
    r = [0,1,2,3,4]
     
    # Names of group and bar width
    names = ['A','B','C','D','E']
    barWidth = 1
     
    # Create brown bars
    plt.bar[r, bars1, color='#7f6d5f', edgecolor='white', width=barWidth]
    # Create green bars [middle], on top of the first ones
    plt.bar[r, bars2, bottom=bars1, color='#557f2d', edgecolor='white', width=barWidth]
    # Create green bars [top]
    plt.bar[r, bars3, bottom=bars, color='#2d7f5e', edgecolor='white', width=barWidth]
     
    # Custom X axis
    plt.xticks[r, names, fontweight='bold']
    plt.xlabel["group"]
     
    # Show graphic
    plt.show[]
    9align2
    # libraries
    import numpy as np
    import matplotlib.pyplot as plt
    from matplotlib import rc
    import pandas as pd
     
    # y-axis in bold
    rc['font', weight='bold']
     
    # Values of each group
    bars1 = [12, 28, 1, 8, 22]
    bars2 = [28, 7, 16, 4, 10]
    bars3 = [25, 3, 23, 25, 17]
     
    # Heights of bars1 + bars2
    bars = np.add[bars1, bars2].tolist[]
     
    # The position of the bars on the x-axis
    r = [0,1,2,3,4]
     
    # Names of group and bar width
    names = ['A','B','C','D','E']
    barWidth = 1
     
    # Create brown bars
    plt.bar[r, bars1, color='#7f6d5f', edgecolor='white', width=barWidth]
    # Create green bars [middle], on top of the first ones
    plt.bar[r, bars2, bottom=bars1, color='#557f2d', edgecolor='white', width=barWidth]
    # Create green bars [top]
    plt.bar[r, bars3, bottom=bars, color='#2d7f5e', edgecolor='white', width=barWidth]
     
    # Custom X axis
    plt.xticks[r, names, fontweight='bold']
    plt.xlabel["group"]
     
    # Show graphic
    plt.show[]
    9align4
    # libraries
    import numpy as np
    import matplotlib.pyplot as plt
    from matplotlib import rc
    import pandas as pd
     
    # y-axis in bold
    rc['font', weight='bold']
     
    # Values of each group
    bars1 = [12, 28, 1, 8, 22]
    bars2 = [28, 7, 16, 4, 10]
    bars3 = [25, 3, 23, 25, 17]
     
    # Heights of bars1 + bars2
    bars = np.add[bars1, bars2].tolist[]
     
    # The position of the bars on the x-axis
    r = [0,1,2,3,4]
     
    # Names of group and bar width
    names = ['A','B','C','D','E']
    barWidth = 1
     
    # Create brown bars
    plt.bar[r, bars1, color='#7f6d5f', edgecolor='white', width=barWidth]
    # Create green bars [middle], on top of the first ones
    plt.bar[r, bars2, bottom=bars1, color='#557f2d', edgecolor='white', width=barWidth]
    # Create green bars [top]
    plt.bar[r, bars3, bottom=bars, color='#2d7f5e', edgecolor='white', width=barWidth]
     
    # Custom X axis
    plt.xticks[r, names, fontweight='bold']
    plt.xlabel["group"]
     
    # Show graphic
    plt.show[]
    9align2

    align8

    # libraries
    import numpy as np
    import matplotlib.pyplot as plt
    from matplotlib import rc
    import pandas as pd
     
    # y-axis in bold
    rc['font', weight='bold']
     
    # Values of each group
    bars1 = [12, 28, 1, 8, 22]
    bars2 = [28, 7, 16, 4, 10]
    bars3 = [25, 3, 23, 25, 17]
     
    # Heights of bars1 + bars2
    bars = np.add[bars1, bars2].tolist[]
     
    # The position of the bars on the x-axis
    r = [0,1,2,3,4]
     
    # Names of group and bar width
    names = ['A','B','C','D','E']
    barWidth = 1
     
    # Create brown bars
    plt.bar[r, bars1, color='#7f6d5f', edgecolor='white', width=barWidth]
    # Create green bars [middle], on top of the first ones
    plt.bar[r, bars2, bottom=bars1, color='#557f2d', edgecolor='white', width=barWidth]
    # Create green bars [top]
    plt.bar[r, bars3, bottom=bars, color='#2d7f5e', edgecolor='white', width=barWidth]
     
    # Custom X axis
    plt.xticks[r, names, fontweight='bold']
    plt.xlabel["group"]
     
    # Show graphic
    plt.show[]
    6edge0edge1

    edge2

    # libraries
    import numpy as np
    import matplotlib.pyplot as plt
    from matplotlib import rc
    import pandas as pd
     
    # y-axis in bold
    rc['font', weight='bold']
     
    # Values of each group
    bars1 = [12, 28, 1, 8, 22]
    bars2 = [28, 7, 16, 4, 10]
    bars3 = [25, 3, 23, 25, 17]
     
    # Heights of bars1 + bars2
    bars = np.add[bars1, bars2].tolist[]
     
    # The position of the bars on the x-axis
    r = [0,1,2,3,4]
     
    # Names of group and bar width
    names = ['A','B','C','D','E']
    barWidth = 1
     
    # Create brown bars
    plt.bar[r, bars1, color='#7f6d5f', edgecolor='white', width=barWidth]
    # Create green bars [middle], on top of the first ones
    plt.bar[r, bars2, bottom=bars1, color='#557f2d', edgecolor='white', width=barWidth]
    # Create green bars [top]
    plt.bar[r, bars3, bottom=bars, color='#2d7f5e', edgecolor='white', width=barWidth]
     
    # Custom X axis
    plt.xticks[r, names, fontweight='bold']
    plt.xlabel["group"]
     
    # Show graphic
    plt.show[]
    6edge4
    # libraries
    import numpy as np
    import matplotlib.pyplot as plt
    from matplotlib import rc
    import pandas as pd
     
    # y-axis in bold
    rc['font', weight='bold']
     
    # Values of each group
    bars1 = [12, 28, 1, 8, 22]
    bars2 = [28, 7, 16, 4, 10]
    bars3 = [25, 3, 23, 25, 17]
     
    # Heights of bars1 + bars2
    bars = np.add[bars1, bars2].tolist[]
     
    # The position of the bars on the x-axis
    r = [0,1,2,3,4]
     
    # Names of group and bar width
    names = ['A','B','C','D','E']
    barWidth = 1
     
    # Create brown bars
    plt.bar[r, bars1, color='#7f6d5f', edgecolor='white', width=barWidth]
    # Create green bars [middle], on top of the first ones
    plt.bar[r, bars2, bottom=bars1, color='#557f2d', edgecolor='white', width=barWidth]
    # Create green bars [top]
    plt.bar[r, bars3, bottom=bars, color='#2d7f5e', edgecolor='white', width=barWidth]
     
    # Custom X axis
    plt.xticks[r, names, fontweight='bold']
    plt.xlabel["group"]
     
    # Show graphic
    plt.show[]
    6edge6edge1

    # libraries
    import numpy as np
    import matplotlib.pyplot as plt
    from matplotlib import rc
    import pandas as pd
     
    # y-axis in bold
    rc['font', weight='bold']
     
    # Values of each group
    bars1 = [12, 28, 1, 8, 22]
    bars2 = [28, 7, 16, 4, 10]
    bars3 = [25, 3, 23, 25, 17]
     
    # Heights of bars1 + bars2
    bars = np.add[bars1, bars2].tolist[]
     
    # The position of the bars on the x-axis
    r = [0,1,2,3,4]
     
    # Names of group and bar width
    names = ['A','B','C','D','E']
    barWidth = 1
     
    # Create brown bars
    plt.bar[r, bars1, color='#7f6d5f', edgecolor='white', width=barWidth]
    # Create green bars [middle], on top of the first ones
    plt.bar[r, bars2, bottom=bars1, color='#557f2d', edgecolor='white', width=barWidth]
    # Create green bars [top]
    plt.bar[r, bars3, bottom=bars, color='#2d7f5e', edgecolor='white', width=barWidth]
     
    # Custom X axis
    plt.xticks[r, names, fontweight='bold']
    plt.xlabel["group"]
     
    # Show graphic
    plt.show[]
    28
    # libraries
    import numpy as np
    import matplotlib.pyplot as plt
    from matplotlib import rc
    import pandas as pd
     
    # y-axis in bold
    rc['font', weight='bold']
     
    # Values of each group
    bars1 = [12, 28, 1, 8, 22]
    bars2 = [28, 7, 16, 4, 10]
    bars3 = [25, 3, 23, 25, 17]
     
    # Heights of bars1 + bars2
    bars = np.add[bars1, bars2].tolist[]
     
    # The position of the bars on the x-axis
    r = [0,1,2,3,4]
     
    # Names of group and bar width
    names = ['A','B','C','D','E']
    barWidth = 1
     
    # Create brown bars
    plt.bar[r, bars1, color='#7f6d5f', edgecolor='white', width=barWidth]
    # Create green bars [middle], on top of the first ones
    plt.bar[r, bars2, bottom=bars1, color='#557f2d', edgecolor='white', width=barWidth]
    # Create green bars [top]
    plt.bar[r, bars3, bottom=bars, color='#2d7f5e', edgecolor='white', width=barWidth]
     
    # Custom X axis
    plt.xticks[r, names, fontweight='bold']
    plt.xlabel["group"]
     
    # Show graphic
    plt.show[]
    6
    # libraries
    import numpy as np
    import matplotlib.pyplot as plt
    from matplotlib import rc
    import pandas as pd
     
    # y-axis in bold
    rc['font', weight='bold']
     
    # Values of each group
    bars1 = [12, 28, 1, 8, 22]
    bars2 = [28, 7, 16, 4, 10]
    bars3 = [25, 3, 23, 25, 17]
     
    # Heights of bars1 + bars2
    bars = np.add[bars1, bars2].tolist[]
     
    # The position of the bars on the x-axis
    r = [0,1,2,3,4]
     
    # Names of group and bar width
    names = ['A','B','C','D','E']
    barWidth = 1
     
    # Create brown bars
    plt.bar[r, bars1, color='#7f6d5f', edgecolor='white', width=barWidth]
    # Create green bars [middle], on top of the first ones
    plt.bar[r, bars2, bottom=bars1, color='#557f2d', edgecolor='white', width=barWidth]
    # Create green bars [top]
    plt.bar[r, bars3, bottom=bars, color='#2d7f5e', edgecolor='white', width=barWidth]
     
    # Custom X axis
    plt.xticks[r, names, fontweight='bold']
    plt.xlabel["group"]
     
    # Show graphic
    plt.show[]
    30
    # libraries
    import numpy as np
    import matplotlib.pyplot as plt
    from matplotlib import rc
    import pandas as pd
     
    # y-axis in bold
    rc['font', weight='bold']
     
    # Values of each group
    bars1 = [12, 28, 1, 8, 22]
    bars2 = [28, 7, 16, 4, 10]
    bars3 = [25, 3, 23, 25, 17]
     
    # Heights of bars1 + bars2
    bars = np.add[bars1, bars2].tolist[]
     
    # The position of the bars on the x-axis
    r = [0,1,2,3,4]
     
    # Names of group and bar width
    names = ['A','B','C','D','E']
    barWidth = 1
     
    # Create brown bars
    plt.bar[r, bars1, color='#7f6d5f', edgecolor='white', width=barWidth]
    # Create green bars [middle], on top of the first ones
    plt.bar[r, bars2, bottom=bars1, color='#557f2d', edgecolor='white', width=barWidth]
    # Create green bars [top]
    plt.bar[r, bars3, bottom=bars, color='#2d7f5e', edgecolor='white', width=barWidth]
     
    # Custom X axis
    plt.xticks[r, names, fontweight='bold']
    plt.xlabel["group"]
     
    # Show graphic
    plt.show[]
    31
    # libraries
    import numpy as np
    import matplotlib.pyplot as plt
    from matplotlib import rc
    import pandas as pd
     
    # y-axis in bold
    rc['font', weight='bold']
     
    # Values of each group
    bars1 = [12, 28, 1, 8, 22]
    bars2 = [28, 7, 16, 4, 10]
    bars3 = [25, 3, 23, 25, 17]
     
    # Heights of bars1 + bars2
    bars = np.add[bars1, bars2].tolist[]
     
    # The position of the bars on the x-axis
    r = [0,1,2,3,4]
     
    # Names of group and bar width
    names = ['A','B','C','D','E']
    barWidth = 1
     
    # Create brown bars
    plt.bar[r, bars1, color='#7f6d5f', edgecolor='white', width=barWidth]
    # Create green bars [middle], on top of the first ones
    plt.bar[r, bars2, bottom=bars1, color='#557f2d', edgecolor='white', width=barWidth]
    # Create green bars [top]
    plt.bar[r, bars3, bottom=bars, color='#2d7f5e', edgecolor='white', width=barWidth]
     
    # Custom X axis
    plt.xticks[r, names, fontweight='bold']
    plt.xlabel["group"]
     
    # Show graphic
    plt.show[]
    32
    # libraries
    import numpy as np
    import matplotlib.pyplot as plt
    from matplotlib import rc
    import pandas as pd
     
    # y-axis in bold
    rc['font', weight='bold']
     
    # Values of each group
    bars1 = [12, 28, 1, 8, 22]
    bars2 = [28, 7, 16, 4, 10]
    bars3 = [25, 3, 23, 25, 17]
     
    # Heights of bars1 + bars2
    bars = np.add[bars1, bars2].tolist[]
     
    # The position of the bars on the x-axis
    r = [0,1,2,3,4]
     
    # Names of group and bar width
    names = ['A','B','C','D','E']
    barWidth = 1
     
    # Create brown bars
    plt.bar[r, bars1, color='#7f6d5f', edgecolor='white', width=barWidth]
    # Create green bars [middle], on top of the first ones
    plt.bar[r, bars2, bottom=bars1, color='#557f2d', edgecolor='white', width=barWidth]
    # Create green bars [top]
    plt.bar[r, bars3, bottom=bars, color='#2d7f5e', edgecolor='white', width=barWidth]
     
    # Custom X axis
    plt.xticks[r, names, fontweight='bold']
    plt.xlabel["group"]
     
    # Show graphic
    plt.show[]
    6
    # libraries
    import numpy as np
    import matplotlib.pyplot as plt
    from matplotlib import rc
    import pandas as pd
     
    # y-axis in bold
    rc['font', weight='bold']
     
    # Values of each group
    bars1 = [12, 28, 1, 8, 22]
    bars2 = [28, 7, 16, 4, 10]
    bars3 = [25, 3, 23, 25, 17]
     
    # Heights of bars1 + bars2
    bars = np.add[bars1, bars2].tolist[]
     
    # The position of the bars on the x-axis
    r = [0,1,2,3,4]
     
    # Names of group and bar width
    names = ['A','B','C','D','E']
    barWidth = 1
     
    # Create brown bars
    plt.bar[r, bars1, color='#7f6d5f', edgecolor='white', width=barWidth]
    # Create green bars [middle], on top of the first ones
    plt.bar[r, bars2, bottom=bars1, color='#557f2d', edgecolor='white', width=barWidth]
    # Create green bars [top]
    plt.bar[r, bars3, bottom=bars, color='#2d7f5e', edgecolor='white', width=barWidth]
     
    # Custom X axis
    plt.xticks[r, names, fontweight='bold']
    plt.xlabel["group"]
     
    # Show graphic
    plt.show[]
    34edge1

    # libraries
    import numpy as np
    import matplotlib.pyplot as plt
    from matplotlib import rc
    import pandas as pd
     
    # y-axis in bold
    rc['font', weight='bold']
     
    # Values of each group
    bars1 = [12, 28, 1, 8, 22]
    bars2 = [28, 7, 16, 4, 10]
    bars3 = [25, 3, 23, 25, 17]
     
    # Heights of bars1 + bars2
    bars = np.add[bars1, bars2].tolist[]
     
    # The position of the bars on the x-axis
    r = [0,1,2,3,4]
     
    # Names of group and bar width
    names = ['A','B','C','D','E']
    barWidth = 1
     
    # Create brown bars
    plt.bar[r, bars1, color='#7f6d5f', edgecolor='white', width=barWidth]
    # Create green bars [middle], on top of the first ones
    plt.bar[r, bars2, bottom=bars1, color='#557f2d', edgecolor='white', width=barWidth]
    # Create green bars [top]
    plt.bar[r, bars3, bottom=bars, color='#2d7f5e', edgecolor='white', width=barWidth]
     
    # Custom X axis
    plt.xticks[r, names, fontweight='bold']
    plt.xlabel["group"]
     
    # Show graphic
    plt.show[]
    36
    # libraries
    import numpy as np
    import matplotlib.pyplot as plt
    from matplotlib import rc
    import pandas as pd
     
    # y-axis in bold
    rc['font', weight='bold']
     
    # Values of each group
    bars1 = [12, 28, 1, 8, 22]
    bars2 = [28, 7, 16, 4, 10]
    bars3 = [25, 3, 23, 25, 17]
     
    # Heights of bars1 + bars2
    bars = np.add[bars1, bars2].tolist[]
     
    # The position of the bars on the x-axis
    r = [0,1,2,3,4]
     
    # Names of group and bar width
    names = ['A','B','C','D','E']
    barWidth = 1
     
    # Create brown bars
    plt.bar[r, bars1, color='#7f6d5f', edgecolor='white', width=barWidth]
    # Create green bars [middle], on top of the first ones
    plt.bar[r, bars2, bottom=bars1, color='#557f2d', edgecolor='white', width=barWidth]
    # Create green bars [top]
    plt.bar[r, bars3, bottom=bars, color='#2d7f5e', edgecolor='white', width=barWidth]
     
    # Custom X axis
    plt.xticks[r, names, fontweight='bold']
    plt.xlabel["group"]
     
    # Show graphic
    plt.show[]
    6
    # libraries
    import numpy as np
    import matplotlib.pyplot as plt
    from matplotlib import rc
    import pandas as pd
     
    # y-axis in bold
    rc['font', weight='bold']
     
    # Values of each group
    bars1 = [12, 28, 1, 8, 22]
    bars2 = [28, 7, 16, 4, 10]
    bars3 = [25, 3, 23, 25, 17]
     
    # Heights of bars1 + bars2
    bars = np.add[bars1, bars2].tolist[]
     
    # The position of the bars on the x-axis
    r = [0,1,2,3,4]
     
    # Names of group and bar width
    names = ['A','B','C','D','E']
    barWidth = 1
     
    # Create brown bars
    plt.bar[r, bars1, color='#7f6d5f', edgecolor='white', width=barWidth]
    # Create green bars [middle], on top of the first ones
    plt.bar[r, bars2, bottom=bars1, color='#557f2d', edgecolor='white', width=barWidth]
    # Create green bars [top]
    plt.bar[r, bars3, bottom=bars, color='#2d7f5e', edgecolor='white', width=barWidth]
     
    # Custom X axis
    plt.xticks[r, names, fontweight='bold']
    plt.xlabel["group"]
     
    # Show graphic
    plt.show[]
    30
    # libraries
    import numpy as np
    import matplotlib.pyplot as plt
    from matplotlib import rc
    import pandas as pd
     
    # y-axis in bold
    rc['font', weight='bold']
     
    # Values of each group
    bars1 = [12, 28, 1, 8, 22]
    bars2 = [28, 7, 16, 4, 10]
    bars3 = [25, 3, 23, 25, 17]
     
    # Heights of bars1 + bars2
    bars = np.add[bars1, bars2].tolist[]
     
    # The position of the bars on the x-axis
    r = [0,1,2,3,4]
     
    # Names of group and bar width
    names = ['A','B','C','D','E']
    barWidth = 1
     
    # Create brown bars
    plt.bar[r, bars1, color='#7f6d5f', edgecolor='white', width=barWidth]
    # Create green bars [middle], on top of the first ones
    plt.bar[r, bars2, bottom=bars1, color='#557f2d', edgecolor='white', width=barWidth]
    # Create green bars [top]
    plt.bar[r, bars3, bottom=bars, color='#2d7f5e', edgecolor='white', width=barWidth]
     
    # Custom X axis
    plt.xticks[r, names, fontweight='bold']
    plt.xlabel["group"]
     
    # Show graphic
    plt.show[]
    31
    # libraries
    import numpy as np
    import matplotlib.pyplot as plt
    from matplotlib import rc
    import pandas as pd
     
    # y-axis in bold
    rc['font', weight='bold']
     
    # Values of each group
    bars1 = [12, 28, 1, 8, 22]
    bars2 = [28, 7, 16, 4, 10]
    bars3 = [25, 3, 23, 25, 17]
     
    # Heights of bars1 + bars2
    bars = np.add[bars1, bars2].tolist[]
     
    # The position of the bars on the x-axis
    r = [0,1,2,3,4]
     
    # Names of group and bar width
    names = ['A','B','C','D','E']
    barWidth = 1
     
    # Create brown bars
    plt.bar[r, bars1, color='#7f6d5f', edgecolor='white', width=barWidth]
    # Create green bars [middle], on top of the first ones
    plt.bar[r, bars2, bottom=bars1, color='#557f2d', edgecolor='white', width=barWidth]
    # Create green bars [top]
    plt.bar[r, bars3, bottom=bars, color='#2d7f5e', edgecolor='white', width=barWidth]
     
    # Custom X axis
    plt.xticks[r, names, fontweight='bold']
    plt.xlabel["group"]
     
    # Show graphic
    plt.show[]
    40
    # libraries
    import numpy as np
    import matplotlib.pyplot as plt
    from matplotlib import rc
    import pandas as pd
     
    # y-axis in bold
    rc['font', weight='bold']
     
    # Values of each group
    bars1 = [12, 28, 1, 8, 22]
    bars2 = [28, 7, 16, 4, 10]
    bars3 = [25, 3, 23, 25, 17]
     
    # Heights of bars1 + bars2
    bars = np.add[bars1, bars2].tolist[]
     
    # The position of the bars on the x-axis
    r = [0,1,2,3,4]
     
    # Names of group and bar width
    names = ['A','B','C','D','E']
    barWidth = 1
     
    # Create brown bars
    plt.bar[r, bars1, color='#7f6d5f', edgecolor='white', width=barWidth]
    # Create green bars [middle], on top of the first ones
    plt.bar[r, bars2, bottom=bars1, color='#557f2d', edgecolor='white', width=barWidth]
    # Create green bars [top]
    plt.bar[r, bars3, bottom=bars, color='#2d7f5e', edgecolor='white', width=barWidth]
     
    # Custom X axis
    plt.xticks[r, names, fontweight='bold']
    plt.xlabel["group"]
     
    # Show graphic
    plt.show[]
    31
    # libraries
    import numpy as np
    import matplotlib.pyplot as plt
    from matplotlib import rc
    import pandas as pd
     
    # y-axis in bold
    rc['font', weight='bold']
     
    # Values of each group
    bars1 = [12, 28, 1, 8, 22]
    bars2 = [28, 7, 16, 4, 10]
    bars3 = [25, 3, 23, 25, 17]
     
    # Heights of bars1 + bars2
    bars = np.add[bars1, bars2].tolist[]
     
    # The position of the bars on the x-axis
    r = [0,1,2,3,4]
     
    # Names of group and bar width
    names = ['A','B','C','D','E']
    barWidth = 1
     
    # Create brown bars
    plt.bar[r, bars1, color='#7f6d5f', edgecolor='white', width=barWidth]
    # Create green bars [middle], on top of the first ones
    plt.bar[r, bars2, bottom=bars1, color='#557f2d', edgecolor='white', width=barWidth]
    # Create green bars [top]
    plt.bar[r, bars3, bottom=bars, color='#2d7f5e', edgecolor='white', width=barWidth]
     
    # Custom X axis
    plt.xticks[r, names, fontweight='bold']
    plt.xlabel["group"]
     
    # Show graphic
    plt.show[]
    42
    # libraries
    import numpy as np
    import matplotlib.pyplot as plt
    from matplotlib import rc
    import pandas as pd
     
    # y-axis in bold
    rc['font', weight='bold']
     
    # Values of each group
    bars1 = [12, 28, 1, 8, 22]
    bars2 = [28, 7, 16, 4, 10]
    bars3 = [25, 3, 23, 25, 17]
     
    # Heights of bars1 + bars2
    bars = np.add[bars1, bars2].tolist[]
     
    # The position of the bars on the x-axis
    r = [0,1,2,3,4]
     
    # Names of group and bar width
    names = ['A','B','C','D','E']
    barWidth = 1
     
    # Create brown bars
    plt.bar[r, bars1, color='#7f6d5f', edgecolor='white', width=barWidth]
    # Create green bars [middle], on top of the first ones
    plt.bar[r, bars2, bottom=bars1, color='#557f2d', edgecolor='white', width=barWidth]
    # Create green bars [top]
    plt.bar[r, bars3, bottom=bars, color='#2d7f5e', edgecolor='white', width=barWidth]
     
    # Custom X axis
    plt.xticks[r, names, fontweight='bold']
    plt.xlabel["group"]
     
    # Show graphic
    plt.show[]
    6
    # libraries
    import numpy as np
    import matplotlib.pyplot as plt
    from matplotlib import rc
    import pandas as pd
     
    # y-axis in bold
    rc['font', weight='bold']
     
    # Values of each group
    bars1 = [12, 28, 1, 8, 22]
    bars2 = [28, 7, 16, 4, 10]
    bars3 = [25, 3, 23, 25, 17]
     
    # Heights of bars1 + bars2
    bars = np.add[bars1, bars2].tolist[]
     
    # The position of the bars on the x-axis
    r = [0,1,2,3,4]
     
    # Names of group and bar width
    names = ['A','B','C','D','E']
    barWidth = 1
     
    # Create brown bars
    plt.bar[r, bars1, color='#7f6d5f', edgecolor='white', width=barWidth]
    # Create green bars [middle], on top of the first ones
    plt.bar[r, bars2, bottom=bars1, color='#557f2d', edgecolor='white', width=barWidth]
    # Create green bars [top]
    plt.bar[r, bars3, bottom=bars, color='#2d7f5e', edgecolor='white', width=barWidth]
     
    # Custom X axis
    plt.xticks[r, names, fontweight='bold']
    plt.xlabel["group"]
     
    # Show graphic
    plt.show[]
    44edge1

    # libraries
    import numpy as np
    import matplotlib.pyplot as plt
    from matplotlib import rc
    import pandas as pd
     
    # y-axis in bold
    rc['font', weight='bold']
     
    # Values of each group
    bars1 = [12, 28, 1, 8, 22]
    bars2 = [28, 7, 16, 4, 10]
    bars3 = [25, 3, 23, 25, 17]
     
    # Heights of bars1 + bars2
    bars = np.add[bars1, bars2].tolist[]
     
    # The position of the bars on the x-axis
    r = [0,1,2,3,4]
     
    # Names of group and bar width
    names = ['A','B','C','D','E']
    barWidth = 1
     
    # Create brown bars
    plt.bar[r, bars1, color='#7f6d5f', edgecolor='white', width=barWidth]
    # Create green bars [middle], on top of the first ones
    plt.bar[r, bars2, bottom=bars1, color='#557f2d', edgecolor='white', width=barWidth]
    # Create green bars [top]
    plt.bar[r, bars3, bottom=bars, color='#2d7f5e', edgecolor='white', width=barWidth]
     
    # Custom X axis
    plt.xticks[r, names, fontweight='bold']
    plt.xlabel["group"]
     
    # Show graphic
    plt.show[]
    46
    # libraries
    import numpy as np
    import matplotlib.pyplot as plt
    from matplotlib import rc
    import pandas as pd
     
    # y-axis in bold
    rc['font', weight='bold']
     
    # Values of each group
    bars1 = [12, 28, 1, 8, 22]
    bars2 = [28, 7, 16, 4, 10]
    bars3 = [25, 3, 23, 25, 17]
     
    # Heights of bars1 + bars2
    bars = np.add[bars1, bars2].tolist[]
     
    # The position of the bars on the x-axis
    r = [0,1,2,3,4]
     
    # Names of group and bar width
    names = ['A','B','C','D','E']
    barWidth = 1
     
    # Create brown bars
    plt.bar[r, bars1, color='#7f6d5f', edgecolor='white', width=barWidth]
    # Create green bars [middle], on top of the first ones
    plt.bar[r, bars2, bottom=bars1, color='#557f2d', edgecolor='white', width=barWidth]
    # Create green bars [top]
    plt.bar[r, bars3, bottom=bars, color='#2d7f5e', edgecolor='white', width=barWidth]
     
    # Custom X axis
    plt.xticks[r, names, fontweight='bold']
    plt.xlabel["group"]
     
    # Show graphic
    plt.show[]
    47edge1

    # libraries
    import numpy as np
    import matplotlib.pyplot as plt
    from matplotlib import rc
    import pandas as pd
     
    # y-axis in bold
    rc['font', weight='bold']
     
    # Values of each group
    bars1 = [12, 28, 1, 8, 22]
    bars2 = [28, 7, 16, 4, 10]
    bars3 = [25, 3, 23, 25, 17]
     
    # Heights of bars1 + bars2
    bars = np.add[bars1, bars2].tolist[]
     
    # The position of the bars on the x-axis
    r = [0,1,2,3,4]
     
    # Names of group and bar width
    names = ['A','B','C','D','E']
    barWidth = 1
     
    # Create brown bars
    plt.bar[r, bars1, color='#7f6d5f', edgecolor='white', width=barWidth]
    # Create green bars [middle], on top of the first ones
    plt.bar[r, bars2, bottom=bars1, color='#557f2d', edgecolor='white', width=barWidth]
    # Create green bars [top]
    plt.bar[r, bars3, bottom=bars, color='#2d7f5e', edgecolor='white', width=barWidth]
     
    # Custom X axis
    plt.xticks[r, names, fontweight='bold']
    plt.xlabel["group"]
     
    # Show graphic
    plt.show[]
    49
    # libraries
    import numpy as np
    import matplotlib.pyplot as plt
    from matplotlib import rc
    import pandas as pd
     
    # y-axis in bold
    rc['font', weight='bold']
     
    # Values of each group
    bars1 = [12, 28, 1, 8, 22]
    bars2 = [28, 7, 16, 4, 10]
    bars3 = [25, 3, 23, 25, 17]
     
    # Heights of bars1 + bars2
    bars = np.add[bars1, bars2].tolist[]
     
    # The position of the bars on the x-axis
    r = [0,1,2,3,4]
     
    # Names of group and bar width
    names = ['A','B','C','D','E']
    barWidth = 1
     
    # Create brown bars
    plt.bar[r, bars1, color='#7f6d5f', edgecolor='white', width=barWidth]
    # Create green bars [middle], on top of the first ones
    plt.bar[r, bars2, bottom=bars1, color='#557f2d', edgecolor='white', width=barWidth]
    # Create green bars [top]
    plt.bar[r, bars3, bottom=bars, color='#2d7f5e', edgecolor='white', width=barWidth]
     
    # Custom X axis
    plt.xticks[r, names, fontweight='bold']
    plt.xlabel["group"]
     
    # Show graphic
    plt.show[]
    50edge1

    Ví dụ 2: [Biểu đồ thanh xếp chồng với hơn 2 dữ liệu]

    # libraries
    import numpy as np
    import matplotlib.pyplot as plt
    from matplotlib import rc
    import pandas as pd
     
    # y-axis in bold
    rc['font', weight='bold']
     
    # Values of each group
    bars1 = [12, 28, 1, 8, 22]
    bars2 = [28, 7, 16, 4, 10]
    bars3 = [25, 3, 23, 25, 17]
     
    # Heights of bars1 + bars2
    bars = np.add[bars1, bars2].tolist[]
     
    # The position of the bars on the x-axis
    r = [0,1,2,3,4]
     
    # Names of group and bar width
    names = ['A','B','C','D','E']
    barWidth = 1
     
    # Create brown bars
    plt.bar[r, bars1, color='#7f6d5f', edgecolor='white', width=barWidth]
    # Create green bars [middle], on top of the first ones
    plt.bar[r, bars2, bottom=bars1, color='#557f2d', edgecolor='white', width=barWidth]
    # Create green bars [top]
    plt.bar[r, bars3, bottom=bars, color='#2d7f5e', edgecolor='white', width=barWidth]
     
    # Custom X axis
    plt.xticks[r, names, fontweight='bold']
    plt.xlabel["group"]
     
    # Show graphic
    plt.show[]
    61
    # libraries
    import numpy as np
    import matplotlib.pyplot as plt
    from matplotlib import rc
    import pandas as pd
     
    # y-axis in bold
    rc['font', weight='bold']
     
    # Values of each group
    bars1 = [12, 28, 1, 8, 22]
    bars2 = [28, 7, 16, 4, 10]
    bars3 = [25, 3, 23, 25, 17]
     
    # Heights of bars1 + bars2
    bars = np.add[bars1, bars2].tolist[]
     
    # The position of the bars on the x-axis
    r = [0,1,2,3,4]
     
    # Names of group and bar width
    names = ['A','B','C','D','E']
    barWidth = 1
     
    # Create brown bars
    plt.bar[r, bars1, color='#7f6d5f', edgecolor='white', width=barWidth]
    # Create green bars [middle], on top of the first ones
    plt.bar[r, bars2, bottom=bars1, color='#557f2d', edgecolor='white', width=barWidth]
    # Create green bars [top]
    plt.bar[r, bars3, bottom=bars, color='#2d7f5e', edgecolor='white', width=barWidth]
     
    # Custom X axis
    plt.xticks[r, names, fontweight='bold']
    plt.xlabel["group"]
     
    # Show graphic
    plt.show[]
    62edge1

    edge8

    Đầu ra:

    # libraries
    import numpy as np
    import matplotlib.pyplot as plt
    from matplotlib import rc
    import pandas as pd
     
    # y-axis in bold
    rc['font', weight='bold']
     
    # Values of each group
    bars1 = [12, 28, 1, 8, 22]
    bars2 = [28, 7, 16, 4, 10]
    bars3 = [25, 3, 23, 25, 17]
     
    # Heights of bars1 + bars2
    bars = np.add[bars1, bars2].tolist[]
     
    # The position of the bars on the x-axis
    r = [0,1,2,3,4]
     
    # Names of group and bar width
    names = ['A','B','C','D','E']
    barWidth = 1
     
    # Create brown bars
    plt.bar[r, bars1, color='#7f6d5f', edgecolor='white', width=barWidth]
    # Create green bars [middle], on top of the first ones
    plt.bar[r, bars2, bottom=bars1, color='#557f2d', edgecolor='white', width=barWidth]
    # Create green bars [top]
    plt.bar[r, bars3, bottom=bars, color='#2d7f5e', edgecolor='white', width=barWidth]
     
    # Custom X axis
    plt.xticks[r, names, fontweight='bold']
    plt.xlabel["group"]
     
    # Show graphic
    plt.show[]
    3 df.B2dataframe plot]

    Python3

    Vẽ các thanh theo cách ngăn xếp.

    Ví dụ 1: [lô thanh xếp chồng đơn giản]

    # libraries
    import numpy as np
    import matplotlib.pyplot as plt
    from matplotlib import rc
    import pandas as pd
     
    # y-axis in bold
    rc['font', weight='bold']
     
    # Values of each group
    bars1 = [12, 28, 1, 8, 22]
    bars2 = [28, 7, 16, 4, 10]
    bars3 = [25, 3, 23, 25, 17]
     
    # Heights of bars1 + bars2
    bars = np.add[bars1, bars2].tolist[]
     
    # The position of the bars on the x-axis
    r = [0,1,2,3,4]
     
    # Names of group and bar width
    names = ['A','B','C','D','E']
    barWidth = 1
     
    # Create brown bars
    plt.bar[r, bars1, color='#7f6d5f', edgecolor='white', width=barWidth]
    # Create green bars [middle], on top of the first ones
    plt.bar[r, bars2, bottom=bars1, color='#557f2d', edgecolor='white', width=barWidth]
    # Create green bars [top]
    plt.bar[r, bars3, bottom=bars, color='#2d7f5e', edgecolor='white', width=barWidth]
     
    # Custom X axis
    plt.xticks[r, names, fontweight='bold']
    plt.xlabel["group"]
     
    # Show graphic
    plt.show[]
    3
    # libraries
    import numpy as np
    import matplotlib.pyplot as plt
    from matplotlib import rc
    import pandas as pd
     
    # y-axis in bold
    rc['font', weight='bold']
     
    # Values of each group
    bars1 = [12, 28, 1, 8, 22]
    bars2 = [28, 7, 16, 4, 10]
    bars3 = [25, 3, 23, 25, 17]
     
    # Heights of bars1 + bars2
    bars = np.add[bars1, bars2].tolist[]
     
    # The position of the bars on the x-axis
    r = [0,1,2,3,4]
     
    # Names of group and bar width
    names = ['A','B','C','D','E']
    barWidth = 1
     
    # Create brown bars
    plt.bar[r, bars1, color='#7f6d5f', edgecolor='white', width=barWidth]
    # Create green bars [middle], on top of the first ones
    plt.bar[r, bars2, bottom=bars1, color='#557f2d', edgecolor='white', width=barWidth]
    # Create green bars [top]
    plt.bar[r, bars3, bottom=bars, color='#2d7f5e', edgecolor='white', width=barWidth]
     
    # Custom X axis
    plt.xticks[r, names, fontweight='bold']
    plt.xlabel["group"]
     
    # Show graphic
    plt.show[]
    4

    # libraries
    import numpy as np
    import matplotlib.pyplot as plt
    from matplotlib import rc
    import pandas as pd
     
    # y-axis in bold
    rc['font', weight='bold']
     
    # Values of each group
    bars1 = [12, 28, 1, 8, 22]
    bars2 = [28, 7, 16, 4, 10]
    bars3 = [25, 3, 23, 25, 17]
     
    # Heights of bars1 + bars2
    bars = np.add[bars1, bars2].tolist[]
     
    # The position of the bars on the x-axis
    r = [0,1,2,3,4]
     
    # Names of group and bar width
    names = ['A','B','C','D','E']
    barWidth = 1
     
    # Create brown bars
    plt.bar[r, bars1, color='#7f6d5f', edgecolor='white', width=barWidth]
    # Create green bars [middle], on top of the first ones
    plt.bar[r, bars2, bottom=bars1, color='#557f2d', edgecolor='white', width=barWidth]
    # Create green bars [top]
    plt.bar[r, bars3, bottom=bars, color='#2d7f5e', edgecolor='white', width=barWidth]
     
    # Custom X axis
    plt.xticks[r, names, fontweight='bold']
    plt.xlabel["group"]
     
    # Show graphic
    plt.show[]
    5
    # libraries
    import numpy as np
    import matplotlib.pyplot as plt
    from matplotlib import rc
    import pandas as pd
     
    # y-axis in bold
    rc['font', weight='bold']
     
    # Values of each group
    bars1 = [12, 28, 1, 8, 22]
    bars2 = [28, 7, 16, 4, 10]
    bars3 = [25, 3, 23, 25, 17]
     
    # Heights of bars1 + bars2
    bars = np.add[bars1, bars2].tolist[]
     
    # The position of the bars on the x-axis
    r = [0,1,2,3,4]
     
    # Names of group and bar width
    names = ['A','B','C','D','E']
    barWidth = 1
     
    # Create brown bars
    plt.bar[r, bars1, color='#7f6d5f', edgecolor='white', width=barWidth]
    # Create green bars [middle], on top of the first ones
    plt.bar[r, bars2, bottom=bars1, color='#557f2d', edgecolor='white', width=barWidth]
    # Create green bars [top]
    plt.bar[r, bars3, bottom=bars, color='#2d7f5e', edgecolor='white', width=barWidth]
     
    # Custom X axis
    plt.xticks[r, names, fontweight='bold']
    plt.xlabel["group"]
     
    # Show graphic
    plt.show[]
    6
    # libraries
    import numpy as np
    import matplotlib.pyplot as plt
    from matplotlib import rc
    import pandas as pd
     
    # y-axis in bold
    rc['font', weight='bold']
     
    # Values of each group
    bars1 = [12, 28, 1, 8, 22]
    bars2 = [28, 7, 16, 4, 10]
    bars3 = [25, 3, 23, 25, 17]
     
    # Heights of bars1 + bars2
    bars = np.add[bars1, bars2].tolist[]
     
    # The position of the bars on the x-axis
    r = [0,1,2,3,4]
     
    # Names of group and bar width
    names = ['A','B','C','D','E']
    barWidth = 1
     
    # Create brown bars
    plt.bar[r, bars1, color='#7f6d5f', edgecolor='white', width=barWidth]
    # Create green bars [middle], on top of the first ones
    plt.bar[r, bars2, bottom=bars1, color='#557f2d', edgecolor='white', width=barWidth]
    # Create green bars [top]
    plt.bar[r, bars3, bottom=bars, color='#2d7f5e', edgecolor='white', width=barWidth]
     
    # Custom X axis
    plt.xticks[r, names, fontweight='bold']
    plt.xlabel["group"]
     
    # Show graphic
    plt.show[]
    7
    # libraries
    import numpy as np
    import matplotlib.pyplot as plt
    from matplotlib import rc
    import pandas as pd
     
    # y-axis in bold
    rc['font', weight='bold']
     
    # Values of each group
    bars1 = [12, 28, 1, 8, 22]
    bars2 = [28, 7, 16, 4, 10]
    bars3 = [25, 3, 23, 25, 17]
     
    # Heights of bars1 + bars2
    bars = np.add[bars1, bars2].tolist[]
     
    # The position of the bars on the x-axis
    r = [0,1,2,3,4]
     
    # Names of group and bar width
    names = ['A','B','C','D','E']
    barWidth = 1
     
    # Create brown bars
    plt.bar[r, bars1, color='#7f6d5f', edgecolor='white', width=barWidth]
    # Create green bars [middle], on top of the first ones
    plt.bar[r, bars2, bottom=bars1, color='#557f2d', edgecolor='white', width=barWidth]
    # Create green bars [top]
    plt.bar[r, bars3, bottom=bars, color='#2d7f5e', edgecolor='white', width=barWidth]
     
    # Custom X axis
    plt.xticks[r, names, fontweight='bold']
    plt.xlabel["group"]
     
    # Show graphic
    plt.show[]
    8
    # libraries
    import numpy as np
    import matplotlib.pyplot as plt
    from matplotlib import rc
    import pandas as pd
     
    # y-axis in bold
    rc['font', weight='bold']
     
    # Values of each group
    bars1 = [12, 28, 1, 8, 22]
    bars2 = [28, 7, 16, 4, 10]
    bars3 = [25, 3, 23, 25, 17]
     
    # Heights of bars1 + bars2
    bars = np.add[bars1, bars2].tolist[]
     
    # The position of the bars on the x-axis
    r = [0,1,2,3,4]
     
    # Names of group and bar width
    names = ['A','B','C','D','E']
    barWidth = 1
     
    # Create brown bars
    plt.bar[r, bars1, color='#7f6d5f', edgecolor='white', width=barWidth]
    # Create green bars [middle], on top of the first ones
    plt.bar[r, bars2, bottom=bars1, color='#557f2d', edgecolor='white', width=barWidth]
    # Create green bars [top]
    plt.bar[r, bars3, bottom=bars, color='#2d7f5e', edgecolor='white', width=barWidth]
     
    # Custom X axis
    plt.xticks[r, names, fontweight='bold']
    plt.xlabel["group"]
     
    # Show graphic
    plt.show[]
    9
      Team  Round 1  Round 2  Round 3  Round 4
    0    A       10       20       10       26
    1    B       20       25       15       21
    2    C       12       15       19        6
    3    D       10       18       11       19
    0
    # libraries
    import numpy as np
    import matplotlib.pyplot as plt
    from matplotlib import rc
    import pandas as pd
     
    # y-axis in bold
    rc['font', weight='bold']
     
    # Values of each group
    bars1 = [12, 28, 1, 8, 22]
    bars2 = [28, 7, 16, 4, 10]
    bars3 = [25, 3, 23, 25, 17]
     
    # Heights of bars1 + bars2
    bars = np.add[bars1, bars2].tolist[]
     
    # The position of the bars on the x-axis
    r = [0,1,2,3,4]
     
    # Names of group and bar width
    names = ['A','B','C','D','E']
    barWidth = 1
     
    # Create brown bars
    plt.bar[r, bars1, color='#7f6d5f', edgecolor='white', width=barWidth]
    # Create green bars [middle], on top of the first ones
    plt.bar[r, bars2, bottom=bars1, color='#557f2d', edgecolor='white', width=barWidth]
    # Create green bars [top]
    plt.bar[r, bars3, bottom=bars, color='#2d7f5e', edgecolor='white', width=barWidth]
     
    # Custom X axis
    plt.xticks[r, names, fontweight='bold']
    plt.xlabel["group"]
     
    # Show graphic
    plt.show[]
    9
      Team  Round 1  Round 2  Round 3  Round 4
    0    A       10       20       10       26
    1    B       20       25       15       21
    2    C       12       15       19        6
    3    D       10       18       11       19
    222

      Team  Round 1  Round 2  Round 3  Round 4
    0    A       10       20       10       26
    1    B       20       25       15       21
    2    C       12       15       19        6
    3    D       10       18       11       19
    04
    # libraries
    import numpy as np
    import matplotlib.pyplot as plt
    from matplotlib import rc
    import pandas as pd
     
    # y-axis in bold
    rc['font', weight='bold']
     
    # Values of each group
    bars1 = [12, 28, 1, 8, 22]
    bars2 = [28, 7, 16, 4, 10]
    bars3 = [25, 3, 23, 25, 17]
     
    # Heights of bars1 + bars2
    bars = np.add[bars1, bars2].tolist[]
     
    # The position of the bars on the x-axis
    r = [0,1,2,3,4]
     
    # Names of group and bar width
    names = ['A','B','C','D','E']
    barWidth = 1
     
    # Create brown bars
    plt.bar[r, bars1, color='#7f6d5f', edgecolor='white', width=barWidth]
    # Create green bars [middle], on top of the first ones
    plt.bar[r, bars2, bottom=bars1, color='#557f2d', edgecolor='white', width=barWidth]
    # Create green bars [top]
    plt.bar[r, bars3, bottom=bars, color='#2d7f5e', edgecolor='white', width=barWidth]
     
    # Custom X axis
    plt.xticks[r, names, fontweight='bold']
    plt.xlabel["group"]
     
    # Show graphic
    plt.show[]
    7
      Team  Round 1  Round 2  Round 3  Round 4
    0    A       10       20       10       26
    1    B       20       25       15       21
    2    C       12       15       19        6
    3    D       10       18       11       19
    4
    # libraries
    import numpy as np
    import matplotlib.pyplot as plt
    from matplotlib import rc
    import pandas as pd
     
    # y-axis in bold
    rc['font', weight='bold']
     
    # Values of each group
    bars1 = [12, 28, 1, 8, 22]
    bars2 = [28, 7, 16, 4, 10]
    bars3 = [25, 3, 23, 25, 17]
     
    # Heights of bars1 + bars2
    bars = np.add[bars1, bars2].tolist[]
     
    # The position of the bars on the x-axis
    r = [0,1,2,3,4]
     
    # Names of group and bar width
    names = ['A','B','C','D','E']
    barWidth = 1
     
    # Create brown bars
    plt.bar[r, bars1, color='#7f6d5f', edgecolor='white', width=barWidth]
    # Create green bars [middle], on top of the first ones
    plt.bar[r, bars2, bottom=bars1, color='#557f2d', edgecolor='white', width=barWidth]
    # Create green bars [top]
    plt.bar[r, bars3, bottom=bars, color='#2d7f5e', edgecolor='white', width=barWidth]
     
    # Custom X axis
    plt.xticks[r, names, fontweight='bold']
    plt.xlabel["group"]
     
    # Show graphic
    plt.show[]
    9
      Team  Round 1  Round 2  Round 3  Round 4
    0    A       10       20       10       26
    1    B       20       25       15       21
    2    C       12       15       19        6
    3    D       10       18       11       19
    9
    # libraries
    import numpy as np
    import matplotlib.pyplot as plt
    from matplotlib import rc
    import pandas as pd
     
    # y-axis in bold
    rc['font', weight='bold']
     
    # Values of each group
    bars1 = [12, 28, 1, 8, 22]
    bars2 = [28, 7, 16, 4, 10]
    bars3 = [25, 3, 23, 25, 17]
     
    # Heights of bars1 + bars2
    bars = np.add[bars1, bars2].tolist[]
     
    # The position of the bars on the x-axis
    r = [0,1,2,3,4]
     
    # Names of group and bar width
    names = ['A','B','C','D','E']
    barWidth = 1
     
    # Create brown bars
    plt.bar[r, bars1, color='#7f6d5f', edgecolor='white', width=barWidth]
    # Create green bars [middle], on top of the first ones
    plt.bar[r, bars2, bottom=bars1, color='#557f2d', edgecolor='white', width=barWidth]
    # Create green bars [top]
    plt.bar[r, bars3, bottom=bars, color='#2d7f5e', edgecolor='white', width=barWidth]
     
    # Custom X axis
    plt.xticks[r, names, fontweight='bold']
    plt.xlabel["group"]
     
    # Show graphic
    plt.show[]
    9
      Team  Round 1  Round 2  Round 3  Round 4
    0    A       10       20       10       26
    1    B       20       25       15       21
    2    C       12       15       19        6
    3    D       10       18       11       19
    10
    # libraries
    import numpy as np
    import matplotlib.pyplot as plt
    from matplotlib import rc
    import pandas as pd
     
    # y-axis in bold
    rc['font', weight='bold']
     
    # Values of each group
    bars1 = [12, 28, 1, 8, 22]
    bars2 = [28, 7, 16, 4, 10]
    bars3 = [25, 3, 23, 25, 17]
     
    # Heights of bars1 + bars2
    bars = np.add[bars1, bars2].tolist[]
     
    # The position of the bars on the x-axis
    r = [0,1,2,3,4]
     
    # Names of group and bar width
    names = ['A','B','C','D','E']
    barWidth = 1
     
    # Create brown bars
    plt.bar[r, bars1, color='#7f6d5f', edgecolor='white', width=barWidth]
    # Create green bars [middle], on top of the first ones
    plt.bar[r, bars2, bottom=bars1, color='#557f2d', edgecolor='white', width=barWidth]
    # Create green bars [top]
    plt.bar[r, bars3, bottom=bars, color='#2d7f5e', edgecolor='white', width=barWidth]
     
    # Custom X axis
    plt.xticks[r, names, fontweight='bold']
    plt.xlabel["group"]
     
    # Show graphic
    plt.show[]
    9
      Team  Round 1  Round 2  Round 3  Round 4
    0    A       10       20       10       26
    1    B       20       25       15       21
    2    C       12       15       19        6
    3    D       10       18       11       19
    12
    # libraries
    import numpy as np
    import matplotlib.pyplot as plt
    from matplotlib import rc
    import pandas as pd
     
    # y-axis in bold
    rc['font', weight='bold']
     
    # Values of each group
    bars1 = [12, 28, 1, 8, 22]
    bars2 = [28, 7, 16, 4, 10]
    bars3 = [25, 3, 23, 25, 17]
     
    # Heights of bars1 + bars2
    bars = np.add[bars1, bars2].tolist[]
     
    # The position of the bars on the x-axis
    r = [0,1,2,3,4]
     
    # Names of group and bar width
    names = ['A','B','C','D','E']
    barWidth = 1
     
    # Create brown bars
    plt.bar[r, bars1, color='#7f6d5f', edgecolor='white', width=barWidth]
    # Create green bars [middle], on top of the first ones
    plt.bar[r, bars2, bottom=bars1, color='#557f2d', edgecolor='white', width=barWidth]
    # Create green bars [top]
    plt.bar[r, bars3, bottom=bars, color='#2d7f5e', edgecolor='white', width=barWidth]
     
    # Custom X axis
    plt.xticks[r, names, fontweight='bold']
    plt.xlabel["group"]
     
    # Show graphic
    plt.show[]
    9
    # libraries
    import numpy as np
    import matplotlib.pyplot as plt
    from matplotlib import rc
    import pandas as pd
     
    # y-axis in bold
    rc['font', weight='bold']
     
    # Values of each group
    bars1 = [12, 28, 1, 8, 22]
    bars2 = [28, 7, 16, 4, 10]
    bars3 = [25, 3, 23, 25, 17]
     
    # Heights of bars1 + bars2
    bars = np.add[bars1, bars2].tolist[]
     
    # The position of the bars on the x-axis
    r = [0,1,2,3,4]
     
    # Names of group and bar width
    names = ['A','B','C','D','E']
    barWidth = 1
     
    # Create brown bars
    plt.bar[r, bars1, color='#7f6d5f', edgecolor='white', width=barWidth]
    # Create green bars [middle], on top of the first ones
    plt.bar[r, bars2, bottom=bars1, color='#557f2d', edgecolor='white', width=barWidth]
    # Create green bars [top]
    plt.bar[r, bars3, bottom=bars, color='#2d7f5e', edgecolor='white', width=barWidth]
     
    # Custom X axis
    plt.xticks[r, names, fontweight='bold']
    plt.xlabel["group"]
     
    # Show graphic
    plt.show[]
    03
      Team  Round 1  Round 2  Round 3  Round 4
    0    A       10       20       10       26
    1    B       20       25       15       21
    2    C       12       15       19        6
    3    D       10       18       11       19
    15

    Các

      Team  Round 1  Round 2  Round 3  Round 4
    0    A       10       20       10       26
    1    B       20       25       15       21
    2    C       12       15       19        6
    3    D       10       18       11       19
    30
      Team  Round 1  Round 2  Round 3  Round 4
    0    A       10       20       10       26
    1    B       20       25       15       21
    2    C       12       15       19        6
    3    D       10       18       11       19
    31

      Team  Round 1  Round 2  Round 3  Round 4
    0    A       10       20       10       26
    1    B       20       25       15       21
    2    C       12       15       19        6
    3    D       10       18       11       19
    32
    # libraries
    import numpy as np
    import matplotlib.pyplot as plt
    from matplotlib import rc
    import pandas as pd
     
    # y-axis in bold
    rc['font', weight='bold']
     
    # Values of each group
    bars1 = [12, 28, 1, 8, 22]
    bars2 = [28, 7, 16, 4, 10]
    bars3 = [25, 3, 23, 25, 17]
     
    # Heights of bars1 + bars2
    bars = np.add[bars1, bars2].tolist[]
     
    # The position of the bars on the x-axis
    r = [0,1,2,3,4]
     
    # Names of group and bar width
    names = ['A','B','C','D','E']
    barWidth = 1
     
    # Create brown bars
    plt.bar[r, bars1, color='#7f6d5f', edgecolor='white', width=barWidth]
    # Create green bars [middle], on top of the first ones
    plt.bar[r, bars2, bottom=bars1, color='#557f2d', edgecolor='white', width=barWidth]
    # Create green bars [top]
    plt.bar[r, bars3, bottom=bars, color='#2d7f5e', edgecolor='white', width=barWidth]
     
    # Custom X axis
    plt.xticks[r, names, fontweight='bold']
    plt.xlabel["group"]
     
    # Show graphic
    plt.show[]
    6
      Team  Round 1  Round 2  Round 3  Round 4
    0    A       10       20       10       26
    1    B       20       25       15       21
    2    C       12       15       19        6
    3    D       10       18       11       19
    20
      Team  Round 1  Round 2  Round 3  Round 4
    0    A       10       20       10       26
    1    B       20       25       15       21
    2    C       12       15       19        6
    3    D       10       18       11       19
    35
    # libraries
    import numpy as np
    import matplotlib.pyplot as plt
    from matplotlib import rc
    import pandas as pd
     
    # y-axis in bold
    rc['font', weight='bold']
     
    # Values of each group
    bars1 = [12, 28, 1, 8, 22]
    bars2 = [28, 7, 16, 4, 10]
    bars3 = [25, 3, 23, 25, 17]
     
    # Heights of bars1 + bars2
    bars = np.add[bars1, bars2].tolist[]
     
    # The position of the bars on the x-axis
    r = [0,1,2,3,4]
     
    # Names of group and bar width
    names = ['A','B','C','D','E']
    barWidth = 1
     
    # Create brown bars
    plt.bar[r, bars1, color='#7f6d5f', edgecolor='white', width=barWidth]
    # Create green bars [middle], on top of the first ones
    plt.bar[r, bars2, bottom=bars1, color='#557f2d', edgecolor='white', width=barWidth]
    # Create green bars [top]
    plt.bar[r, bars3, bottom=bars, color='#2d7f5e', edgecolor='white', width=barWidth]
     
    # Custom X axis
    plt.xticks[r, names, fontweight='bold']
    plt.xlabel["group"]
     
    # Show graphic
    plt.show[]
    6
      Team  Round 1  Round 2  Round 3  Round 4
    0    A       10       20       10       26
    1    B       20       25       15       21
    2    C       12       15       19        6
    3    D       10       18       11       19
    37
      Team  Round 1  Round 2  Round 3  Round 4
    0    A       10       20       10       26
    1    B       20       25       15       21
    2    C       12       15       19        6
    3    D       10       18       11       19
    38
    # libraries
    import numpy as np
    import matplotlib.pyplot as plt
    from matplotlib import rc
    import pandas as pd
     
    # y-axis in bold
    rc['font', weight='bold']
     
    # Values of each group
    bars1 = [12, 28, 1, 8, 22]
    bars2 = [28, 7, 16, 4, 10]
    bars3 = [25, 3, 23, 25, 17]
     
    # Heights of bars1 + bars2
    bars = np.add[bars1, bars2].tolist[]
     
    # The position of the bars on the x-axis
    r = [0,1,2,3,4]
     
    # Names of group and bar width
    names = ['A','B','C','D','E']
    barWidth = 1
     
    # Create brown bars
    plt.bar[r, bars1, color='#7f6d5f', edgecolor='white', width=barWidth]
    # Create green bars [middle], on top of the first ones
    plt.bar[r, bars2, bottom=bars1, color='#557f2d', edgecolor='white', width=barWidth]
    # Create green bars [top]
    plt.bar[r, bars3, bottom=bars, color='#2d7f5e', edgecolor='white', width=barWidth]
     
    # Custom X axis
    plt.xticks[r, names, fontweight='bold']
    plt.xlabel["group"]
     
    # Show graphic
    plt.show[]
    6
      Team  Round 1  Round 2  Round 3  Round 4
    0    A       10       20       10       26
    1    B       20       25       15       21
    2    C       12       15       19        6
    3    D       10       18       11       19
    40
      Team  Round 1  Round 2  Round 3  Round 4
    0    A       10       20       10       26
    1    B       20       25       15       21
    2    C       12       15       19        6
    3    D       10       18       11       19
    41

      Team  Round 1  Round 2  Round 3  Round 4
    0    A       10       20       10       26
    1    B       20       25       15       21
    2    C       12       15       19        6
    3    D       10       18       11       19
    42
      Team  Round 1  Round 2  Round 3  Round 4
    0    A       10       20       10       26
    1    B       20       25       15       21
    2    C       12       15       19        6
    3    D       10       18       11       19
    43
    # libraries
    import numpy as np
    import matplotlib.pyplot as plt
    from matplotlib import rc
    import pandas as pd
     
    # y-axis in bold
    rc['font', weight='bold']
     
    # Values of each group
    bars1 = [12, 28, 1, 8, 22]
    bars2 = [28, 7, 16, 4, 10]
    bars3 = [25, 3, 23, 25, 17]
     
    # Heights of bars1 + bars2
    bars = np.add[bars1, bars2].tolist[]
     
    # The position of the bars on the x-axis
    r = [0,1,2,3,4]
     
    # Names of group and bar width
    names = ['A','B','C','D','E']
    barWidth = 1
     
    # Create brown bars
    plt.bar[r, bars1, color='#7f6d5f', edgecolor='white', width=barWidth]
    # Create green bars [middle], on top of the first ones
    plt.bar[r, bars2, bottom=bars1, color='#557f2d', edgecolor='white', width=barWidth]
    # Create green bars [top]
    plt.bar[r, bars3, bottom=bars, color='#2d7f5e', edgecolor='white', width=barWidth]
     
    # Custom X axis
    plt.xticks[r, names, fontweight='bold']
    plt.xlabel["group"]
     
    # Show graphic
    plt.show[]
    6
      Team  Round 1  Round 2  Round 3  Round 4
    0    A       10       20       10       26
    1    B       20       25       15       21
    2    C       12       15       19        6
    3    D       10       18       11       19
    45edge1

    edge8

    Đầu ra:

      Team  Round 1  Round 2  Round 3  Round 4
    0    A       10       20       10       26
    1    B       20       25       15       21
    2    C       12       15       19        6
    3    D       10       18       11       19


    Có thể tạo nhiều biểu đồ thanh trong Python không?

    Một biểu đồ nhiều thanh còn được gọi là biểu đồ thanh được nhóm. Một lô thanh hoặc biểu đồ thanh có nhiều tùy chỉnh như nhiều lô thanh, lô thanh xếp chồng, biểu đồ thanh ngang.

    Làm thế nào để bạn vẽ 3 cột trong Python?

    Để vẽ nhiều cột dữ liệu trong khung đơn, chúng tôi chỉ cần chuyển danh sách các cột cho đối số y của hàm âm mưu ...
    Nhập mô -đun ..
    Tạo hoặc tải dữ liệu ..
    Chuyển đổi sang DataFrame ..
    Sử dụng phương thức Plot [], chỉ định một cột duy nhất dọc theo trục x và nhiều cột dưới dạng một mảng dọc theo trục y ..
    Hiển thị đồ thị ..

    Làm thế nào để bạn vẽ nhiều biểu đồ thanh?

    Để tạo biểu đồ nhiều thanh:..
    Vẽ trục ngang và dọc ..
    Cho biểu đồ một tiêu đề ..
    Dán nhãn trục x ngang ..
    Dán nhãn trục y dọc ..
    Nhìn vào phạm vi trong dữ liệu và quyết định cách các đơn vị trên trục dọc nên được dán nhãn ..

    Làm thế nào để tôi vẽ hai biểu đồ thanh bên cạnh nhau trong Python?

    Tạo điểm X, Y1, Y2 bằng cách sử dụng Numpy ..
    Với NROW = 1, Ncols = 2, Index = 1, thêm Subplot vào hình hiện tại, sử dụng phương thức Subplot [] ..
    Vẽ đường bằng cách sử dụng các điểm x và y1, sử dụng phương thức lô [] ..
    Thiết lập tiêu đề, nhãn cho trục X và Y cho Hình 1, sử dụng PLT ..

    Bài Viết Liên Quan

    Chủ Đề