File tree Expand file tree Collapse file tree 2 files changed +4
-2
lines changed
5_steps_to_n_body_simulation Expand file tree Collapse file tree 2 files changed +4
-2
lines changed Original file line number Diff line number Diff line change @@ -110,7 +110,7 @@ Animations generally consists of two steps:
110
110
Since you already know how to generate the frames, we
111
111
have already solved the first step. First, let us
112
112
copy ` step5.py ` to ` extra.py ` and modify it slightly to include
113
- ` solar_system_plus ` . We also need to import ` matplotlib ` .
113
+ ` solar_system_plus ` .
114
114
115
115
??? Note "Code (Click to expand)"
116
116
```python title="extra.py"
@@ -208,6 +208,7 @@ Note that we need to set the min and max values for the axes.
208
208
if legend:
209
209
ax.legend(loc = " center right" , bbox_to_anchor = (1.325 , 0.5 ))
210
210
fig.subplots_adjust(right = 0.7 )
211
+ fig.tight_layout()
211
212
212
213
plt.savefig(FRAMES_DIR / f " frames_ { n:05d } .png " )
213
214
plt.close(" all" )
@@ -250,7 +251,7 @@ animation is done, we delete all frames by using `Path.unlink()`.
250
251
251
252
You should see the animation:
252
253
253
- <iframe width =" 560 " height =" 315 " src =" https://www.youtube.com/embed/qtCLYpzPxBM ?si=p-xXf4mE0DGPLxOS " title =" YouTube video player " frameborder =" 0 " allow =" accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share " referrerpolicy =" strict-origin-when-cross-origin " allowfullscreen ></iframe >
254
+ <iframe width =" 560 " height =" 315 " src =" https://www.youtube.com/embed/8y9CubaVGLk ?si=G1XDDJ8SgQ9qK4OS " title =" YouTube video player " frameborder =" 0 " allow =" accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share " referrerpolicy =" strict-origin-when-cross-origin " allowfullscreen ></iframe >
254
255
255
256
## Conclusion
256
257
Original file line number Diff line number Diff line change @@ -257,6 +257,7 @@ def main() -> None:
257
257
if legend :
258
258
ax .legend (loc = "center right" , bbox_to_anchor = (1.325 , 0.5 ))
259
259
fig .subplots_adjust (right = 0.7 )
260
+ fig .tight_layout ()
260
261
261
262
plt .savefig (FRAMES_DIR / f"frames_{ n :05d} .png" )
262
263
plt .close ("all" )
You can’t perform that action at this time.
0 commit comments