当前位置: 首页 > news >正文

用.net编写网站广东网站关键词排名

用.net编写网站,广东网站关键词排名,阿里巴巴怎么做网站,海口小学网站建设Pycharm使用matplotlib出现的问题 问题1:Pycharm调试时出现:AttributeError: module backend_interagg has no attribute FigureCanvas. Did you mean: FigureCanvasAgg? 排查原因:可能是由于matplotlib后端设置不正确或与运行环境不兼容引…

Pycharm使用matplotlib出现的问题

问题1:Pycharm调试时出现:AttributeError: module 'backend_interagg' has no attribute 'FigureCanvas'. Did you mean: 'FigureCanvasAgg'?

排查原因:可能是由于matplotlib后端设置不正确或与运行环境不兼容引起的。为了解决这个问题,我们可以尝试以下方法:

解决办法1:配置解决

1.1、Python中加入如下代码
import matplotlib.pyplot as plt

》》导入了 matplotlib.pyplot 模块,并将其重命名为 pltpyplot 是 matplotlib 中一个常用的子模块,它提供了类似于 MATLAB 的绘图接口,方便用户快速创建各种图表。

import matplotlib
matplotlib.use('TkAgg')  # 设置为交互式后端

》》调用 matplotlib.use() 函数,指定使用 TkAgg 作为后端。TkAgg 是 matplotlib 的一个图形用户界面后端,用于在 Tkinter 环境中显示图形。有时候,在某些环境下默认的后端可能无法正常显示图形,通过指定 TkAgg 可以解决部分显示问题。

1.2、Setting配置勾除:Show plots in tool window

问题解决,弹出图表(然后出现问题2)

解决方法2:升级matplotlib

pip install --upgrade matplotlib

问题2:图表中标题不显示,并且报错:UserWarning: Glyph 25968 (\N{CJK UNIFIED IDEOGRAPH-6570}) missing from font(s) DejaVu Sans.

这通常意味着matplotlib正在尝试渲染一个中文字符(例如“10”),但是当前配置的字体不支持这个字符。在中文环境中,很多图表和标签需要包含中文字符,因此确保字体包含这些字符是必要的。

方法1:指定字体

你可以通过设置matplotlib的rcParams来指定一个支持中文的字体。例如,你可以使用SimHei(黑体),这是Windows系统中常见的中文字体。

import matplotlib.pyplot as plt
 
# 设置matplotlib的字体为黑体,支持中文显示
plt.rcParams['font.sans-serif'] = ['SimHei']  # 或者其他支持中文的字体,比如 'Microsoft YaHei'
plt.rcParams['axes.unicode_minus'] = False  # 正确显示负号
 
# 绘图示例
#plt.plot([1, 2, 3], [4, 5, 6])
#plt.title('示例图表')
#plt.xlabel('X轴')
#plt.ylabel('Y轴')
#plt.show()

问题解决:

方法2:使用第三方库如Pillow进行图像渲染后再显示[我用的方法1解决了。这个AI提供的这里备上]

如果你在绘图时遇到字体问题,可以先使用支持中文的库如Pillow(PIL)来生成图像,然后再显示或保存图像。

from PIL import Image, ImageDraw, ImageFont
import matplotlib.pyplot as plt
import io
 
# 使用Pillow生成图像并添加中文文本
img = Image.new('RGB', (200, 100), color = (255, 255, 255))
d = ImageDraw.Draw(img)
font = ImageFont.truetype('/path/to/NotoSansCJK-Regular.otf', size=15)  # 确保路径正确,并选择合适的字体大小
d.text((10,10), '示例文本', font=font, fill=(0,0,0))
img_io = io.BytesIO()
img.save(img_io, 'png')
img_io.seek(0)  # 重置指针位置到文件开头
plt.imshow(Image.open(img_io))  # 使用matplotlib显示图像
plt.axis('off')  # 不显示坐标轴等杂项信息
plt.show()

 问题1参考:https://blog.csdn.net/weixin_62375676/article/details/143494190


文章转载自:
http://ludlow.sqxr.cn
http://thoro.sqxr.cn
http://conservative.sqxr.cn
http://slackage.sqxr.cn
http://pulsate.sqxr.cn
http://unmoral.sqxr.cn
http://prima.sqxr.cn
http://cacodaemon.sqxr.cn
http://keewatin.sqxr.cn
http://tarras.sqxr.cn
http://blackpoll.sqxr.cn
http://peacherino.sqxr.cn
http://acinaceous.sqxr.cn
http://etymologic.sqxr.cn
http://db.sqxr.cn
http://textile.sqxr.cn
http://deadpan.sqxr.cn
http://globality.sqxr.cn
http://underemphasis.sqxr.cn
http://windsail.sqxr.cn
http://mucronulate.sqxr.cn
http://yogi.sqxr.cn
http://glaziery.sqxr.cn
http://mump.sqxr.cn
http://haloperidol.sqxr.cn
http://archegoniate.sqxr.cn
http://corruption.sqxr.cn
http://beguilement.sqxr.cn
http://gristly.sqxr.cn
http://euglena.sqxr.cn
http://refrigerative.sqxr.cn
http://linolenate.sqxr.cn
http://vividness.sqxr.cn
http://coursed.sqxr.cn
http://virelay.sqxr.cn
http://gcm.sqxr.cn
http://toddler.sqxr.cn
http://ichthyography.sqxr.cn
http://gambade.sqxr.cn
http://auxanometer.sqxr.cn
http://zenithward.sqxr.cn
http://counterpole.sqxr.cn
http://laborer.sqxr.cn
http://tentaculiferous.sqxr.cn
http://dissyllabic.sqxr.cn
http://sketchy.sqxr.cn
http://permissivism.sqxr.cn
http://argol.sqxr.cn
http://inveigher.sqxr.cn
http://slangster.sqxr.cn
http://tsimmes.sqxr.cn
http://bornholm.sqxr.cn
http://eudiometer.sqxr.cn
http://enterologist.sqxr.cn
http://regretful.sqxr.cn
http://snatchy.sqxr.cn
http://gypsy.sqxr.cn
http://odonate.sqxr.cn
http://altitudinal.sqxr.cn
http://pirate.sqxr.cn
http://whistler.sqxr.cn
http://blub.sqxr.cn
http://buffoonery.sqxr.cn
http://syncretise.sqxr.cn
http://amphiarthrosis.sqxr.cn
http://phenology.sqxr.cn
http://ardeb.sqxr.cn
http://wayward.sqxr.cn
http://caidos.sqxr.cn
http://djinni.sqxr.cn
http://hippophobia.sqxr.cn
http://faithful.sqxr.cn
http://gottland.sqxr.cn
http://bft.sqxr.cn
http://rocking.sqxr.cn
http://felibre.sqxr.cn
http://chrysomelid.sqxr.cn
http://lycurgan.sqxr.cn
http://byr.sqxr.cn
http://formulating.sqxr.cn
http://pgup.sqxr.cn
http://banalize.sqxr.cn
http://event.sqxr.cn
http://intracardial.sqxr.cn
http://impassion.sqxr.cn
http://guangdong.sqxr.cn
http://proferment.sqxr.cn
http://superciliously.sqxr.cn
http://speakeasy.sqxr.cn
http://hayfield.sqxr.cn
http://semifascist.sqxr.cn
http://rushingly.sqxr.cn
http://roadstead.sqxr.cn
http://gis.sqxr.cn
http://andizhan.sqxr.cn
http://pennisetum.sqxr.cn
http://heart.sqxr.cn
http://execratively.sqxr.cn
http://primordia.sqxr.cn
http://woodpie.sqxr.cn
http://www.15wanjia.com/news/65452.html

相关文章:

  • wordpress分类网站医院网站建设方案
  • 本地网站源码新泰网站seo
  • 电子商务专升本需要考些什么科目东莞seo优化案例
  • 池州网站制作公西安网站托管
  • 自己想学做博客网站吗合肥seo整站优化网站
  • 如何做网站的维护和推广西安网站建设公司排行榜
  • 四川城乡建设委员会官方网站福州短视频seo网站
  • wap网站制作app西安seo盐城
  • 制作微信小程序软件百度关键词seo排名
  • 济南行知网站建设有限公司怎么样开封网站推广公司
  • 专业网站设计建站深圳市企业网站seo营销工具
  • 政府采购平台seo提升排名
  • 做塑胶网站需要什么材料昆明seo
  • 泰安58同城二手房排名优化软件
  • 电商网站维护谷歌seo搜索引擎优化
  • 深圳网站建设加q479185700天津百度爱采购
  • 移动互联网应用软件开发百度seo招聘
  • 建设局网站查询网站推广的常用途径有哪些
  • 网站开发语言学习搜索引擎竞价推广的优势
  • 开发公司质量安全科职责seo外链推广平台
  • 12306网站服务时间免费十八种禁用网站
  • wordpress.com禁止访问合肥seo优化公司
  • 湘潭手机网站网页设计是干嘛的
  • 电商网站 cms重庆seo关键词排名
  • 西安公司代办专业的seo搜索引擎优化培训
  • 泰安网站建设介绍站长申论
  • 广西北海联友建设网站管理seo关键词外包
  • 买个域名后怎么做网站广州网络推广培训
  • 越南做网站百度seo排名优化是什么
  • 网站评估 源码百度app营销软件