AttributeError:模块“ matplotlib”没有属性“ xlabel”

问题描述

我的代码是:

import matplotlib as plt 
sns.distplot(CMSU['Spending'],kde = False)
plt.xlabel("Spending",size=15)
plt.ylabel("Probablity",size=15)
plt.title("distribution for the variable - Spending",size=18);

我遇到了错误

AttributeError                            Traceback (most recent call last)
<ipython-input-32-1c6eb744a592> in <module>
      1 sns.distplot(CMSU['Spending'],kde = False)
----> 2 plt.xlabel("Spending",size=15)
      3 plt.ylabel("Probablity",size=15)
      4 plt.title("distribution for the variable - Spending",size=18);

AttributeError: module 'matplotlib' has no attribute 'xlabel'

有什么可能出问题?

解决方法

我认为您需要做import matplotlib.pyplot as plt而不只是matplotlib as plt,因为xlabel以及matplotlib中可能不存在其他各种功能。

,

您的return jsonify({'location': filename}) 语句是错误的。这些方法属于import。也就是说,您应该这样导入它:

pyplot
,

使用:

        $param_var = New-Object MySql.Data.MySqlClient.MySqlParameter("@my_col_bool",$SqlDbType.TinyInt)
        $oMYSQLCommand.Parameters.Add($param_var) | Out-Null 

        $oMYSQLCommand.ExecuteNonQuery()/*Error: Exception calling "ExecuteNonQuery" with "0" argument(s): "Incorrect integer value: 'false' for column 'my_col_bool' at row 1" */ 

matplotlib.pyplot.xlabel() ylabel相同:

title