Fix the width of riemann rectangles

This commit is contained in:
widcardw 2022-03-17 14:10:30 +08:00 committed by GitHub
parent dfbbb34035
commit 67f8007764
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -235,6 +235,7 @@ class CoordinateSystem():
stroke_color=BLACK,
fill_opacity=1,
colors=(BLUE, GREEN),
stroke_background=True,
show_signed_area=True):
if x_range is None:
x_range = self.x_range[:2]
@ -257,7 +258,8 @@ class CoordinateSystem():
height = get_norm(
self.i2gp(sample, graph) - self.c2p(sample, 0)
)
rect = Rectangle(width=x1 - x0, height=height)
rect = Rectangle(width=self.x_axis.n2p(x1)[0] - self.x_axis.n2p(x0)[0],
height=height)
rect.move_to(self.c2p(x0, 0), DL)
rects.append(rect)
result = VGroup(*rects)
@ -266,6 +268,7 @@ class CoordinateSystem():
stroke_width=stroke_width,
stroke_color=stroke_color,
fill_opacity=fill_opacity,
stroke_background=stroke_background
)
return result