Replies: 1 comment 2 replies
-
You have two options for that, either if your function has varying different sizes of unreachable states just make them in to a group and split up the function parts that you can plot. g = VGroup(
ax.plot(
f,
x_range=[-7, -2.01, 0.001],
dt=0.001,
color=RED,
),
ax.plot(
f,
x_range=[-0.99, 7, 0.001],
dt=0.001,
color=RED,
),
) But for this example i would rather choose to explicitly name the discontinuities like follows: class FunctionLesson(Scene):
def construct(self):
ax = Axes(x_range=[-7, 7], y_range=[-8, 8]).add_coordinates()
f = lambda x: np.log(x**2 + 3 * x + 2)
g = ax.plot(f, x_range=[-7, 7], discontinuities=[-1.5], dt=0.51, color=BLUE)
label = MathTex(r"\ln(x^2+3x+2)").to_edge(UL)
self.add(ax)
self.play(Create(g), Write(label)) It would be nice to have something with Nans working but it is a little more difficult because that would need an algorithm which can calculate discontinuties on the fly. Which could be an experimental feature enabled with a named parameter but this would probably result in a lot of weird plot artifacts in some cases. So i would always prefer manually splitting. But if you have a proposal for a robust splitting algorithm which can deal with those kinds of plots i would be happy to implement it as an experimental feature! |
Beta Was this translation helpful? Give feedback.
-
When plotting functions which might exceed the vertical range of a FunctionGraph() or Axes.plot() there is currently no way to clip the function graph. In matplotlib this can be achieved by returning function values in the form of float("nan") or numpy.nan, in Manim this currently results in an error message.
As an example from the Discord discussions - it would be nice if code like this would work:
Beta Was this translation helpful? Give feedback.
All reactions