Controlling the order of output

There’s a lot of ways you could tackle this depending on what aesthetics you seek. For example, you could just move the display of plot to the next cell.

At this point you are saying you are new to Jupyter. Are you familiar with Julia/IJulia though? (I’m guess from your other posts that is Julia code.) Because the solutions may actually more involve Julia than Jupyter. The way I do this sort of thing in Python backed notebooks is using IPython’s abilities to mix and match using display & HTML abilities. Not really Jupyter’s. It may be something to keep in mind as you look around at other Julia notebooks. I think the bottom section of the notebook I referred you to before in another post starts showing you the possibilities under ‘Multimedia display in IJulia’. You can see this section rendered in static form here. It looks like using display that you can control how you arrange display the collected text and plot, I suspect. For example, with IPython I use the following to add a title to a dataframe display:

from IPython.display import display, HTML
display(HTML(f'<b>Interface interactions for {pdbs_to_use[num_to_display]}:</b>'))
display(dfs[num_to_display])

You can probably use the IJuila variation of that to arrange the output as you prefer.

Another idea is to collect the text and add it into your plot as annotation or a legend.

You may want to look into what Julia uses to build in pauses. I don’t think that will help in this case; however, combined with collecting the text and not printing it out immediately, it is sometimes useful in delaying some steps while others occur when running Python cells. Sometimes you can use that to delay printing, I cannot tell from your description though if that will help in this case.

1 Like