You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

在Spyder中使用AutoViz代码运行成功但无法查看图表

解决Spyder中无法查看AutoViz生成图表的问题

问题描述

代码已成功执行,输出日志显示AutoViz完成了105个散点图的生成,但无法在Spyder中查看这些图表:

Shape of your Data Set loaded: (96, 14)

Classifying variables in data set...
    Number of Numeric Columns =  14
    Number of Integer-Categorical Columns =  0
    Number of String-Categorical Columns =  0
    Number of Factor-Categorical Columns =  0
    Number of String-Boolean Columns =  0
    Number of Numeric-Boolean Columns =  0
    Number of Discrete String Columns =  0
    Number of NLP String Columns =  0
    Number of Date Time Columns =  0
    Number of ID Columns =  0
    Number of Columns to Delete =  0
    14 Predictors classified...
        No variables removed since no ID or low-information variables found in data set
Number of All Scatter Plots = 105
No categorical or numeric vars in data set. Hence no bar charts.
All Plots done
Time to run AutoViz = 4 seconds 

 ###################### AUTO VISUALIZATION Completed ########################

使用的代码如下:

import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
from autoviz.AutoViz_Class import AutoViz_Class

AV = AutoViz_Class()

path = r'filename.csv'
ladakhtemp = pd.read_csv(r'ladakhtemp.csv')

filename = "filename.csv"
sep = ","
dft = AV.AutoViz(
    filename,
    sep=",",
    depVar="",
    dfte=None,
    header=0,
    verbose=0,
    lowess=False,
    chart_format="svg",
    max_rows_analyzed=150000,
    max_cols_analyzed=30,
)

解决方案

1. 修改chart_format参数

当前代码中chart_format="svg"会让AutoViz将图表保存为本地SVG文件,而非在Spyder窗口中显示。修改该参数为"notebook",适配Spyder的交互式环境:

dft = AV.AutoViz(
    filename,
    sep=",",
    depVar="",
    dfte=None,
    header=0,
    verbose=0,
    lowess=False,
    chart_format="notebook",  # 修改此处
    max_rows_analyzed=150000,
    max_cols_analyzed=30,
)

2. 强制触发图表显示

在代码末尾添加plt.show(),确保matplotlib渲染的图表能在Spyder中弹出:

plt.show()

3. 调整Spyder的Matplotlib后端设置

  • 打开Spyder,点击顶部菜单栏的 Tools > Preferences
  • 在弹出窗口中选择 IPython Console > Graphics
  • 将Backend选项设置为 Automatic 或 Inline
  • 点击 Apply 后重启Spyder,让设置生效

4. 检查文件路径一致性(可选)

代码中同时定义了path = r'filename.csv'和读取ladakhtemp.csv,但AutoViz调用的是filename.csv,确保这两个文件是同一个,避免加载错误数据导致无图表显示。

内容的提问来源于stack exchange,提问作者saikat ghosh

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.10 22:20:46