Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/313.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 尼勒恩';t图标签_Python_Plot_Nilearn - Fatal编程技术网

Python 尼勒恩';t图标签

Python 尼勒恩';t图标签,python,plot,nilearn,Python,Plot,Nilearn,我使用以下代码来绘制相关矩阵 from nilearn import plotting import matplotlib.pyplot as plt def plotMatrix(matrix, plot_path, labels, title, ticks, vmin, vmax): """Plot matrix. param matrix: two dimensional array. The matrix to plot para

我使用以下代码来绘制相关矩阵

from nilearn import plotting
import matplotlib.pyplot as plt

def plotMatrix(matrix, plot_path, labels, title, ticks, vmin, vmax):
    """Plot matrix. 
    param matrix: two dimensional array. The matrix to plot
    param plot_path : string. Full path and name of the plotting picture
    param labels: list. The labels 
    param title: string. The title of the plot
    param ticks: list. The ticks of the plot
    vmin: float. Minimum value
    vmax: float. Maximum value
    return: None
    """
    ticks = list(map(lambda x: x - 0.5, ticks))
    ticks_middle = [(((ticks[i+1]-ticks[i]) / 2 ) + ticks[i]) for i in range(0,len(ticks)-1)]
    fig, ax = plt.subplots()
    fig.set_size_inches(16.5, 9.5)
    plt.yticks(ticks_middle,list(labels))
    plt.xticks(ticks_middle,list(labels), rotation = 55, horizontalalignment='right')
    ax.xaxis.set_minor_locator(plt.FixedLocator(ticks[1:]))
    ax.yaxis.set_minor_locator(plt.FixedLocator(ticks[1:]))
    ax.grid(color='black', linestyle='-', linewidth=1.2, which='minor')
    plt.title(label = title, fontsize = 20)
    for item in (ax.get_xticklabels() + ax.get_yticklabels()):
        item.set_color(labelToColorDic[item.get_text()])
        item.set_fontsize(14)
    #plt.show()
    plotting.plot_matrix(matrix, colorbar=True, axes = ax, vmin=vmin, vmax=vmax)
    fig.savefig(plot_path)
    plt.close()

输出应如下图所示: 但是我得到的矩阵没有标签。如果在plot.plot_matrix之前添加plt.show(),则会得到一个空矩阵,但标签已打开,如下图所示: . 这段代码一年前就开始工作了,所以可能是因为新版本的缘故,但我不知道是什么原因造成了这种差异。 有什么想法吗? 我也愿意接受用我需要的标签绘制相关矩阵的建议