티스토리 뷰
Computer/3B1B 따라잡기 with ManimLibrary
[3B1B따라잡기 with Manim!][1일 1마님] 2. Axes.plot
벼랑끝과학자 2023. 5. 27. 17:411일 1마님 시리즈는 마님 documentation에 존재하는 예제 코드를 하루에 하나씩 따라하면서 마님 라이브러리 사용에 익숙해지기 위해 만든 시리즈입니다! 많은 시간을 들이기엔 주인장도 대학원생인지라 부담이 돼서 1일 1마님 시리즈는 간단하게 코드 + 코드 리뷰 + 실행 결과만 작성합니다!
class GraphingMovement(Scene): # Scene class 상속
def construct(self):
# Axes class를 이용해서 좌표계 형성
# axis_config 옵션을 이용해서 다양한 옵션 설정 가능
axes = Axes(x_range=[0,5,1], y_range=[0,3,1],
x_length=5, y_length=3,
axis_config={"include_tip":True}).add_coordinates()
axes.to_edge(UR)
# 좌표계의 x축과 y축에 labeling
axis_label = axes.get_axis_labels(x_label = 'x', y_label= 'f(x)')
# 좌표계에 그릴 graph 생성 (.plot)
graph = axes.plot(lambda x : x **0.5, x_range=[0,4], color=YELLOW)
Graphing_stuff = VGroup(axes, axis_label, graph)
self.play(DrawBorderThenFill(axes), Write(axis_label))
self.play(Create(graph))
self.wait(2)
self.play(Graphing_stuff.animate.shift(DOWN*4))
self.play(axes.animate.shift(LEFT*3), run_time=3)
self.wait(3)
- Axes class를 불러와서 좌표계를 형성, 다양한 옵션 줄 수 있음 옵션은 다음 참고
- https://docs.manim.community/en/stable/reference/manim.mobject.graphing.coordinate_systems.Axes.html?highlight=axes
- 좌표축에 get_axis_labels를 이용해 labeling 가능
- 형성된 좌표계 위에 그래프를 그리려면 좌표계를 저장한 변수(axes)에 .plot 함수를 이용함
- 그릴 함수는 lambda 기능을 이용해서 만들어주면 됨
- VGroup은 만들어진 Mobjects들을 하나의 Group으로 묶어주는 역할
- 묶었다고 반드시 함께 움직여야 하는 것은 아니고 함께 움직일 수도 있고, 따로 움직일수도 있음
- 특정 My_mobject를 따로 animate할때는 My_mobject.animate 기능을 이용하면 됨 아래 참고
- https://docs.manim.community/en/stable/reference/manim.mobject.mobject.Mobject.html#manim.mobject.mobject.Mobject.animate
'Computer > 3B1B 따라잡기 with ManimLibrary' 카테고리의 다른 글
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
TAG
- variational autoencoder
- 오일석기계학습
- MorganCircularfingerprint
- 최대우도추정
- eigenvalue
- ai신약개발
- marginal likelihood
- 3b1b
- manim
- 기계학습
- 백준
- 베이즈정리
- Matrix algebra
- 제한볼츠만머신
- 인공지능
- 선형대수
- vae
- eigenvector
- kld
- kl divergence
- Manimlibrary
- manim library
- 파이썬
- ai인공지능
- MatrixAlgebra
- manimtutorial
- elementry matrix
- MLE
- 3B1B따라잡기
- 이왜안
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
글 보관함