https://discord.com/channels/581738731934056449/753938743366254642/1280962332469624953
Last active
September 4, 2024 19:16
-
-
Save uwezi/3d7bb3ece4c85d036849940043cc59d0 to your computer and use it in GitHub Desktop.
[area to y-axis] Get the area between a curve and y-axis. #manim #plot #area #axes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from manim import * | |
# https://discord.com/channels/581738731934056449/753938743366254642/1280962332469624953 | |
class Test(Scene): | |
def construct(self): | |
ax1 = Axes( | |
x_range=[-1, 7, 10], | |
y_range=[0, 6, 10], | |
x_length=6, | |
y_length=5 | |
).add_coordinates() | |
ax1_labels = ax1.get_axis_labels() | |
ax1_group = VGroup(ax1, ax1_labels) | |
f2 = ax1.plot(lambda x: -0.1*x**3 + 0.6*x**2 - 1.7*x + 5, x_range=[0, 4.65538, 0.001], color=BLUE) | |
self.add(ax1_group, f2) | |
y1 = 1 | |
y2 = 4 | |
rect = Polygon( | |
ax1.c2p(0,y1), | |
ax1.c2p(7,y1), | |
ax1.c2p(7,y2), | |
ax1.c2p(0,y2), | |
fill_opacity=0.7 | |
) | |
self.add(rect) | |
area_under = ax1.get_area(f2) | |
self.add(area_under) | |
area_to_y = Intersection(rect,area_under).set_fill(opacity=0.6,color=RED) | |
self.add(area_to_y) | |
self.wait() | |
self.remove(rect,area_under) | |
self.wait() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment