plt.rcParams['font.sans-serif'] = ['SimHei'] plt.rcParams['axes.unicode_minus'] = False什么意思
时间: 2024-06-13 08:04:45 浏览: 206
plt.rcParams['font.sans-serif'] = ['SimHei']是用来设置matplotlib图表中显示中文的字体,其中SimHei是一种中文字体。而plt.rcParams['axes.unicode_minus'] = False则是用来解决matplotlib图表中负号无法正常显示的问题。这个参数的设置可以让负号正常显示,而不是显示成方块或其他符号。
相关问题
plt.rcParams["font.sans-serif"] = "SimHei" plt.rcParams['axes.unicode_minus'] = False
这两行代码是用来设置matplotlib库中的字体和符号的。第一行代码`plt.rcParams["font.sans-serif"] = "SimHei"`用来设置字体为中文黑体,这样在绘制图表的时候就可以显示中文。第二行代码`plt.rcParams['axes.unicode_minus'] = False`用来设置符号为正常显示,防止在绘制图表时出现符号变成方块或乱码的情况。这两行代码通常会在绘制图表之前加入,以确保图表的显示效果和可读性。
plt.rcParams[ font.sans-serif ] = [ SimHei ] plt.rcParams[ axes.unicode_minus ] = False weather[ 最高气温 ] = weather[ 最高气温 ].map(lambda x: int(x.replace( ℃ , ))) weather[ 最低气温 ] = weather[
最低气温"].map(lambda x: int(x.replace("℃", "")))
这段代码的作用是将 DataFrame 中的最高气温和最低气温这两列数据中的温度值中的 ℃ 符号去掉,并转换成整数类型。另外,第一行代码中的设置是为了使显示中文不出现乱码,第二行代码中的设置是为了使显示负号时不出现乱码。
阅读全文
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20241231044930.png)
![pdf](https://img-home.csdnimg.cn/images/20241231044930.png)
![py](https://img-home.csdnimg.cn/images/20250102104920.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)