Generating plots in a loop #936
Answered
by
jjallaire
lucas-a-meyer
asked this question in
Q&A
|
I want to display several time series in a loop after their titles. What I am trying to do is to put a title first in Markdown, and then retrieve a series and plot it using the What's happening is that when I render, I first get all the titles and then I get all the figures (title, title title, image, image, image). I wanted to get title, image, title, image, title, image, etc. Am I doing something obviously wrong? |
Answered by
jjallaire
May 19, 2022
Replies: 1 comment 1 reply
|
Not sure exactly what df.plot is doing, but this example using ```{python}
import matplotlib.pyplot as plt
from IPython.display import display, Markdown
for x in range(1, 4):
display(Markdown(f"## Plot {x}"))
plt.plot([1,23,2,4])
plt.show()
```
|
1 reply
Answer selected by
lucas-a-meyer
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Not sure exactly what df.plot is doing, but this example using
plot.show()works the way you are expecting:df.plot()is likely just "attaching" a plot to the cell rather than creating a plot within the stream of outputs.