-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Bunch of more examples for the docs #458
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
We should be a little careful when it comes to rendering more complex examples: this PR currently adds over 100 seconds to the build process of the documentation (see https://readthedocs.org/projects/manimce/builds/11922534/). Maybe it would be better to render in |
|
Good point.
|
|
We should consider both adding lighter and fewer examples, as well as asking RTD for more resources. |
I agree on lighter, I agree on asking RTD, and I disagree on fewer examples. I will write an e-mail to them. And one idea for making videos for the website. |
|
Rendering videos as-is on #463 on my local PC: Same thing, but rendering everything in 800\times 450 with 30 fps: Same thing, but rendering everything in 800\times 450 with 60 fps: I do admit, I am surprised. I expected that rendering with 60fps was completely unfeasible anyways, but this seems like actually the resolution is the bigger limiting factor. And writing tex, thats really slow as hell. Examples with a lot of tex (like plots) take very long to render, regardless of quality. In this way, we can choose something like 450p30 as the default quality settings for the docs. But lets not add that to the pile here; we can do it in a separate PR. |
|
Im very skeptical of those numbers 👀 |
Same. I just ran it again:
The slowest operations, by far, is creating/compiling/converting TeX. (Which is actually not that surprising.) And obviously, this is on a more or less decent PC. The RTD instances this is running on are slower (and need to setup the environment before building, which takes a lot of time). |
|
Thanks for those new numbers. I suggest we use 720p30 and use very minimal use of latex rendering. @kolibril13 your thoughts? |
|
Yeah, I am happy that we don't have to drop the hight quality. class Text1(Scene):
def construct(self):
t = MathTex("Hello World")
self.add(t)--- 2.0 seconds --- class Text2(Scene):
def construct(self):
t = TextMobject("Hello Word")
self.add(t)--- 3.0 seconds --- class Text3(Scene):
def construct(self):
t = Text("Hello Word")
self.add(t)--- 0.9 seconds --- And now a proof of concept that including latex can be way faster, with the detour of matplotlib: from manim import *
class Text4(Scene):
def construct(self):
import matplotlib.pyplot as plt
fig = plt.figure()
t = np.linspace(-10, 10, 100)
sig = 1 / (1 + np.exp(-t))
plt.plot(t, sig, linewidth=2, label=r"Hello World")
plt.legend(fontsize=14)
plt.show()
fig.canvas.draw()
img = ImageMobject(fig.canvas.buffer_rgba())
self.add(img)--- 1.1 seconds --- With Latex class Text5(Scene):
def construct(self):
import matplotlib.pyplot as plt
fig = plt.figure()
t = np.linspace(-10, 10, 100)
sig = 1 / (1 + np.exp(-t))
plt.plot(t, sig, linewidth=2, label=r"$\sigma(t) = \frac{1}{1 + e^{-t}}$")
plt.legend(fontsize=14)
plt.show()
fig.canvas.draw()
img = ImageMobject(fig.canvas.buffer_rgba())
self.add(img)--- 1.4 seconds --- |
|
I can very well read from https://matplotlib.org/3.1.0/tutorials/text/usetex.html and https://matplotlib.org/3.1.0/tutorials/text/mathtext.html that what you showed is not actually LaTeX. It is a custom parser which matplotlib ships and not actually LateX. |
|
|
||
| class Example5bText(Scene): | ||
| def construct(self): | ||
| text = Text('Hello world', t2f={'world':'Forte'}).scale(3) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There seems to be a problem with changing the font right now.
Also when I run this locally, without building the docs, Text it is not using the right font...
I would nevertheless keep this example for now, and make an note to it, that this still has to be improved.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the example is broken, we shouldn't add it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
...or we try to fix the font :)
Maybe we can use something similar? |
As soon as this branch stabilizes a bit, I'd like to test the time difference between @kolibril13, great work with the examples so far. I like pretty much all of them. Some points I'd like to discuss when this stabilizes a little:
|
| class Example1Text(Scene): | ||
| def construct(self): | ||
| t = TextMobject("Hello World") | ||
| self.add(t) | ||
| text = Text('Hello world').scale(3) | ||
| self.add(text) | ||
|
|
||
| .. manim:: Example2Text | ||
| :save_last_frame: | ||
|
|
||
| class Example2Text(Scene): | ||
| def construct(self): | ||
| text = Text('Hello world', color=BLUE).scale(3) | ||
| self.add(text) | ||
|
|
||
|
|
||
| .. manim:: Example3Text | ||
| :save_last_frame: | ||
|
|
||
| class Example3Text(Scene): | ||
| def construct(self): | ||
| text = Text('Hello world', gradient=(BLUE, GREEN)).scale(3) | ||
| self.add(text) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think these three should be joined in the same example.
Also, their names could be improved a lot. Something like "TextColorExample".
I think this is just the nature of these 3D scenes, that they take very long. |
Co-authored-by: Leo Torres <leo@leotrs.com>
Co-authored-by: Leo Torres <leo@leotrs.com>
|
I know that the example section is not completely ready by now, but I would like to merge this pr now, and make a new pr with further changes on the example files.
|
I would prefer to consider a lighter example right now such that the render time is closer to the example afterwards (~20 sec). I don't think that 40 seconds of build time is justified for any example.
I would still wait a bit longer: maybe until we have a first release and exceed 10 minutes of build time? We could then ask specifically for a 30min build time limit, which seems plenty right now. Also, somewhat related: our documentation is currently hosted at |
|
I've been thinking: should we try to move this examples gallery to something that is closer to https://matplotlib.org/gallery.html ? (Not on this PR, but generally.) Both considering the quantity and selection of examples, as well as the thumbnail representation on one page, I like this a lot. |
|
The last time this was discussed, I said that I would like to first see a lot more examples [than what we had then, a few weeks ago], so that then we would have a better idea of what a gallery-like page for manim would look like. Now that we have more examples (once this PR is merged), I'm happy to revisit that idea. |
I also like the thumbnail idea a lot! Probably there is a way to connect these two advantages: moving closer to https://matplotlib.org/gallery.html by adding links with thumbnails to scenes but still having scenes from the same topic on the same page. This could be maybe possible by adding hyperlinks to the subsections, like e.g. in Wikipedia: https://en.wikipedia.org/wiki/Animation#History |
We can discuss specifics at a later point. However, if you have a concrete parameter like |
If you are able to gather all of the questions and comments that are still open, and move them to a new PR, then I'm all for that. |
|
@kolibril13 has told me he has stored all the open discussion and comments and will work on them on a future PR. This is ready to merge as far as I can tell :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good to me as well. Please make sure to either put the open TODOs from here in an issue, or if you open a PR soon, then it is also fine to document them there.
It is great to see our documentation come to life a bit more! :-)
In this PR, I am adding more examples.
Mostly for
MovingCameraScenebut I will also add some things regardingZoomedScenehere.