import matplotlib.pyplot as plt import numpy as np def test4 (): names = ['Movie 1', 'Movie 2', 'Movie 3'] real_num1 = [7548, 4013, 1673] real_num2 = [5453, 1840, 1080 ] real_num3 = [4348, 2345, 1890] x = np.arange (len (names)) # draw a column chart width = 0.3 plt.bar (x, real_num1, alpha = 0.5, width = width, label = names [0 ]) plt.bar ([i + width for i in x], real_num2, alpha = 0.5, width = width, label = names [1]) plt.bar ([i + 2 * width for i in x], real_num3 , alpha = 0.5, width = width, label = names [2]) # Normal display Chinese plt.rcParams ["font.sans-serif"] = ["SimHei"] # Set the value of the x coordinate axis x_label = ["第{}day".format(i+1) for i in x] # Let the x coordinate axis be displayed in the middle plt.xticks ([i + width for i in x], x_label) # add ylabel plt.ylabel ("number of box office") # add legend plt.legend () # add title plt.title ("3 days 3 movie box office Number ") plt.show () test4 ()
The results show that: