The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

hiroshi (1) [Avatar] Offline
#1
plot.png
[ 21 KB ]
When using docker to run sample codes, I found that it is hard to use plt.show() because it requires a X11 environment.
I'v had struggled while I found outputting plot as png image is very easy.

  import numpy as np
+ import matplotlib as mpl
+ mpl.use('Agg')
  import matplotlib.pyplot as plt
  ...
- plt.show()
+ plt.savefig('plot.png')


Now you can do like this with docker for mac.
docker run -it --rm -v$PWD:/notebooks b.gcr.io/tensorflow/tensorflow python regression.py && open plot.png 


I attached a resulted plot.png of listing 3.2.
image

How about adding this information in the book?

reference: http://stackoverflow.com/a/4935945/338986