Import Matplotlib.patches as Patches
Import Matplotlib.pyplot as Plt
Ax = Fig.add_subplot (111)
# Draw Rectangle Currentaxis = PLT.GCA () # Gets the current sub-figure x_rect =x_index*tr/480 = (y_index-fft_ 2POW_POINT/2) *fr/= patches. Rectangle (X_rect, Y_rect), target_height*tr/480, Target_weight*fr/fft_2pow_point, linewidth=2, edgecolor=' R', facecolor='none') currentaxis.add_patch (rect)
The current charts and sub-plots can be obtained using PLT.GCF () and PLT.GCA (),
In the rectangle function (X_rect, Y_rect) represents the starting point of the rectangle (the lower-left corner of the rectangle), target_height*tr/480, Target_weight*fr/fft_2pow_ Point represents the length and width of the rectangle, respectively
For these four parameters, you need to correspond to a known coordinate axis, that is, my horizontal ordinate is known as:
Y_grid, X_grid = Np.meshgrid (Np.linspace (-FR/2, FR/2, Width + 1), 480 + 1, endpoint=false))
Facecolor This parameter corresponds to: sets the parameter inside the rectangle box.
Use Python matplotlib.pyplot to draw a rectangular box