我正在用Pandas绘制一个散点图矩阵,但第一个绘图的刻度标签有时会被正确绘制,有时会被错误地绘制。我无法弄清楚什么是错的!散点图中的刻度线标签与熊猫的绘制不正确
下面是一个例子:
代码:
from pandas.tools.plotting import scatter_matrix
import pylab
import numpy as np
import pandas as pd
def create_scatterplot_matix(X, name):
"""
Outputs a scatterplot matrix for a design matrix.
Parameters:
-----------
X:a design matrix where each column is a feature and each row is an observation.
name: the name of the plot.
"""
pylab.figure()
df = pd.DataFrame(X)
axs = scatter_matrix(df, alpha=0.2, diagonal='kde')
for ax in axs[:,0]: # the left boundary
ax.grid('off', axis='both')
ax.set_yticks([0, .5])
for ax in axs[-1,:]: # the lower boundary
ax.grid('off', axis='both')
ax.set_xticks([0, .5])
pylab.savefig(name + ".png")
家伙,任何人!
编辑(X的例子):
X = np.random.randn(1000000, 10)
你有一个设计矩阵'X'的例子吗?例如,可以使用一组随机值轻松创建一个。这样可以更容易在本地尝试。 – Evert 2014-10-07 15:31:16
@Evert请参阅编辑。 – 2014-10-13 15:45:40