Open realharryhero opened 1 year ago
Assign me this issue I would love to contribute
Not a complete fix but a workaround: Run matplotlib inline immediately after tensorflow_models imported:
import tensorflow_models as tfm
%matplotlib inline
Then every time you use plt to plot, make sure to add plt.show() at the end like:
plt.plot([1,2,3])
plt.show()
plt.show() is necessary to let the plot show up.
Prerequisites
Please answer the following questions for yourself before submitting an issue.
0. The fix
(Also, one can read through 1-5 first.)
Quoting some of my text / images in this report's part 5,
" Changing to the backend before importing tensorflow_models, though, does work:
And after the rest works nicely. "
1. The entire URL of the file you are using
Not a file, but this notebook.
2. Describe the bug
matplotlib's pyplot does not seem to be working after importing tensorflow_models. On the other hand, it seems to be working before importing.
3. Steps to reproduce
4. Expected behavior
Both cells should show the plot, but only the first one does:
5. Additional context
These extra lines of code show below the plot, which doesn't show if the lines of code creating the plot aren't added.
Checking the matplotlib backend after importing tensorflow_models shown below it seems to be agg, so it does not plot as it is a non-interactive backend.
But before importing tensorflow_models, the backend is different:
Changing to TkAgg, an interactive backend, after importing tensorflow_models, doesn't work:
Changing to the backend before importing tensorflow_models, though, does work:
And after the rest works nicely.
6. System information