LoginSignup
9
5

More than 5 years have passed since last update.

Jupyter + Matplotlib > Warning:"matplotlib is currently using a non-GUI backend, " > fig.show()は不要

Last updated at Posted at 2017-07-09
動作環境
GeForce GTX 1070 (8GB)
ASRock Z170M Pro4S [Intel Z170chipset]
Ubuntu 16.04 LTS desktop amd64
TensorFlow v1.1.0
cuDNN v5.1 for Linux
CUDA v8.0
Python 3.5.2
IPython 6.0.0 -- An enhanced Interactive Python.
gcc (Ubuntu 5.4.0-6ubuntu1~16.04.4) 5.4.0 20160609
GNU bash, version 4.3.48(1)-release (x86_64-pc-linux-gnu)

Ubuntu 14.04 LTSからUbuntu 16.04 LTSに環境を変更後、Jupyter + Matplotlibにて描画時に下記のWarningが出るようになった。

/usr/local/lib/python3.5/dist-packages/matplotlib/figure.py:403: UserWarning: matplotlib is currently using a non-GUI backend, so cannot show the figure
"matplotlib is currently using a non-GUI backend, "

%matplotlib inline

# sine curve learning 
# Jul. 08, 2017

import numpy as np
import matplotlib.pyplot as plt

data1 = np.loadtxt('input.csv', delimiter=',')
#data2 = np.loadtxt('res.170708_0830.cut', delimiter=',')
data2 = np.loadtxt('res.170709_0900.cut', delimiter=',')

input1 = data1[:,0]
output1 = data1[:,1]
input2 = data2[:,0]
output2 = data2[:,1]

fig = plt.figure()
ax1 = fig.add_subplot(2,1,1)
ax2 = fig.add_subplot(2,1,2)

ax1.scatter(input1,output1)
ax2.scatter(input2,output2)

ax1.set_xlabel('x')
ax1.set_ylabel('sin(x)')
ax1.set_xlim([0,1.0])
ax1.grid(True)

ax2.set_xlabel('x')
ax2.set_ylabel('sin(x)')
ax2.set_xlim([0,1.0])
ax2.grid(True)

fig.show()

対応 > fig.show()は不要

https://stackoverflow.com/questions/37365357/when-i-use-matplotlib-in-jupyter-notebook-it-always-raise-matplotlib-is-curren
によると

You don't need the line of "fig.show()". Just remove it. Then it will be no warning message.

コード最後のfig.show()をコメントアウトしたらWarningが出なくなった。

9
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
9
5