python怎么使用matplotlib画出下面这样的图?
ringa_lee
ringa_lee 2017-04-18 10:29:28
0
2
758

下面这个图是别人使用java画的

下面这个图是我自己用matplotlib画的

代码是这个样子的

import utils
import matplotlib.pyplot as plt
import numpy as np
from scipy.stats import pearsonr


X, y = utils.load_data('./sonar.data.csv', ',')
X = np.array(X)
y = np.array(y)


f1 = plt.figure()
for i in xrange(len(X[0])):
    plt.subplot(16, 4, i+1)
    plt.scatter(X[:,i], y)
    pea = pearsonr(X[:,i], y)[0]
plt.show()

问题就是图都挤在一起了, 而且调整窗口大小的时候,会有很大的延迟。
求问怎么解决这两个问题???

ringa_lee
ringa_lee

ringa_lee

reply all(2)
洪涛

You can let matplotlib adjust the position of the subplot through plt.tight_layout():

http://matplotlib.org/users/t...

巴扎黑

The simplest columnar code should be like this

# coding: utf-8

import matplotlib.pyplot as plt
import numpy as np

x = np.random.randint(0, 10, size=10)
y = np.random.randint(100, 1000, size=10)

plt.bar(x, y)
plt.show()
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!