But the result is wrong, there is no top and right layer adding to it. Only some additional ticks appeared in left Y axis (as shown in Figure 1). If I firstly execute a part of this script (from line 1 to line 3), then execute the remainder part (from line 4 to line 5). That is ok.
There is a Theme in Theme Gallery that automatically puts upper and right axes in, with no ticks. It is called "Opposite Lines". You can access it by using Format - Theme Gallery.
If you put it as your "System Theme", then the graphs you create (henceforth) will all have these extra axes in place.