python - Is there a way to display a seaborn plot without using the python console?
问题描述
I am quite new to Seaborn
, and I am in the process of learning it. However, when I try to run my code, the plot never shows up and instead, the program ends.
This is my code:
import matplotlib.pyplot as plt
import seaborn as sns
import warnings as wrn
from np.Importing_data import stats
plt.rcParams(['figure.figsize']l = 8, 4
wrn.filterwarnings('ignore')
sns.distplot(stats['InternetUsers'], bins=30)
# sns.boxplot(data=stats, x='IncomeGroup', y='BirthRate')
plt.show(sns)
The 4th line of code is importing the data. This is what I get when running the code normally. The error appears in the Python console, but I do not think this is causing the plot not to be shown.
Traceback (most recent call last):
File "C:/Users/Ratnes.Ratnes-LT/PycharmProjects/demo-rs/np/Seaborn.py", line 11, in <module>
plt.show(sns)
File "C:\Users\Ratnes.Ratnes-LT\PycharmProjects\demo-rs\venv\lib\site-packages\matplotlib\pyplot.py", line 354, in show
return _backend_mod.show(*args, **kwargs)
TypeError: show() takes 1 positional argument but 2 were given
Process finished with exit code 1
If I try and run this on the python console, the code works as expected.
This is the result.
The matplotlib plots do show up but the seaborn ones don't. If anyone's got any solutions, please post on here.
解决方案
Please read the document of matplotlib.pyplot.show. The only argument that can be passed as an argument is a bool value which indicates whether you need interactive or non interactive mode (default value is None), which is basically what your error says as well.
推荐阅读
- phpmyadmin - #1062 - 重复条目 KEY PRIMARY
- matlab - Matlab - 从单元格数组中的表访问表字段
- excel - 将 Excel 行导出到文本文件
- sql - PostgreSQL json 类型的输入语法无效输入字符串意外结束
- javascript - 有条件地插入 HTML,考虑到兄弟姐妹的存在与否
- google-apps-script - 创建一个脚本,该脚本将根据绘图位置或分配脚本时输入的信息增加单元格
- java - 单击Android(Java)中RecyclerView中的每个项目时,在BottomSheetDialog中以编程方式创建CheckBox的简单代码/有效代码是什么
- r - Tidymodels - 帮助评估通过配方制作的回归模型
- angular - ENOENT:没有这样的文件或目录,Angular 12 升级后的 scandir
- linux - 如何在 Solus Linux 上使用 CosmoNim (GCC)?(段错误)