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

如何查看自己制作的网站友情链接怎么弄

如何查看自己制作的网站,友情链接怎么弄,用户浏览网站的习惯,企点怎么群发消息ubuntu 使用 Times New Roman 字体在 Matplotlib 中绘图并调整字体大小 文章目录 ubuntu 使用 Times New Roman 字体在 Matplotlib 中绘图并调整字体大小1. 安装 Times New Roman 字体验证字体是否安装成功 2. 在 Matplotlib 中加载 Times New Roman 字体3. 在 Matplotlib 中使…ubuntu 使用 Times New Roman 字体在 Matplotlib 中绘图并调整字体大小 文章目录 ubuntu 使用 Times New Roman 字体在 Matplotlib 中绘图并调整字体大小1. 安装 Times New Roman 字体验证字体是否安装成功 2. 在 Matplotlib 中加载 Times New Roman 字体3. 在 Matplotlib 中使用 Times New Roman示例应用于标题和轴标签 4. 遇到的问题及解决方案**问题 1findfont: Font family Times New Roman not found****问题 2AttributeError: PathCollection.set() got an unexpected keyword argument fontproperties****问题 3无法调整字体大小** 5. 使用全局字体设置6. 调整字体大小和分辨率总结 在数据可视化中定制字体和样式是常见需求之一特别是在需要与论文、报告或品牌设计保持一致时使用特定字体如 Times New Roman 会显得尤为重要。然而直接在 matplotlib 中设置自定义字体可能会遇到一些问题比如字体无法加载、无法调整大小或参数冲突等。 1. 安装 Times New Roman 字体 在 Linux 系统上Times New Roman 字体并不是默认安装的。因此我们需要手动安装该字体。以下是在 Ubuntu 上安装 Times New Roman 字体的步骤 sudo apt update sudo apt install ttf-mscorefonts-installer安装完成后Times New Roman 字体通常会被存储在路径 /usr/share/fonts/truetype/msttcorefonts/ 中。 验证字体是否安装成功 使用以下命令检查字体是否正确安装 fc-list | grep Times New Roman输出示例 /usr/share/fonts/truetype/msttcorefonts/Times_New_Roman.ttf: Times New Roman:styleRegular2. 在 Matplotlib 中加载 Times New Roman 字体 为了在 Matplotlib 中使用 Times New Roman 字体我们需要通过 matplotlib.font_manager 加载字体文件。以下是加载字体的完整代码 from matplotlib import font_manager as fm# 加载 Times New Roman 字体 font_path /usr/share/fonts/truetype/msttcorefonts/Times_New_Roman.ttf times_new_roman_font fm.FontProperties(fnamefont_path)# 检查字体是否加载成功 print(Loaded font name:, times_new_roman_font.get_name())如果输出为 Times New Roman说明字体加载成功。 3. 在 Matplotlib 中使用 Times New Roman 示例应用于标题和轴标签 我们可以通过 fontproperties 参数将字体应用于标题、轴标签等文本元素。例如 import matplotlib.pyplot as plt# 示例数据 x [1, 2, 3] y [4, 5, 6]# 创建绘图 plt.figure(figsize(6, 6)) plt.plot(x, y, labelSample Line)# 应用字体到标题和轴标签 plt.title(Title in Times New Roman, fontpropertiestimes_new_roman_font, fontsize20) plt.xlabel(X-axis, fontpropertiestimes_new_roman_font, fontsize15) plt.ylabel(Y-axis, fontpropertiestimes_new_roman_font, fontsize15)# 图例 plt.legend(proptimes_new_roman_font, locupper left) plt.show()4. 遇到的问题及解决方案 问题 1findfont: Font family ‘Times New Roman’ not found 在某些情况下即使正确安装了字体Matplotlib 仍可能无法识别字体报错类似 findfont: Font family Times New Roman not found解决方法 确保字体路径正确。刷新字体缓存fc-cache -fv删除 Matplotlib 的字体缓存rm -rf ~/.cache/matplotlib问题 2AttributeError: PathCollection.set() got an unexpected keyword argument ‘fontproperties’ 如果尝试在 plt.scatter() 中使用 fontproperties 参数会报错类似 AttributeError: PathCollection.set() got an unexpected keyword argument fontproperties原因 fontproperties 参数并不适用于 scatter 函数而是用于设置文本如标题、图例的字体。 解决方法 将字体设置移到 plt.legend() 或其他支持 fontproperties 的函数中。修改后的代码如下 plt.scatter(x, y, labelScatter Example, alpha0.5) plt.legend(proptimes_new_roman_font)问题 3无法调整字体大小 在 plt.legend() 中同时使用 fontsize 和 prop 参数时可能会导致字体大小无法调整的问题。 原因 fontsize 参数与 prop 参数冲突当使用 propFontProperties 时字体大小应该在 FontProperties 中指定。 解决方法 通过 FontProperties 设置字体大小而不是直接使用 fontsize 参数。例如 # 设置字体大小 times_new_roman_font fm.FontProperties(fnamefont_path, size20)# 应用到图例 plt.legend(loclower left, proptimes_new_roman_font)5. 使用全局字体设置 如果希望将 Times New Roman 设置为整个图形的默认字体可以通过 Matplotlib 的 rcParams 实现 from matplotlib import rcParams# 设置全局字体 rcParams[font.family] times_new_roman_font.get_name() rcParams[font.size] 12# 创建绘图 plt.plot([1, 2, 3], [4, 5, 6], labelExample Line) plt.legend(locupper left) plt.title(Global Font Example) plt.show()6. 调整字体大小和分辨率 当字体太大或太小时可以通过以下方法调整 调整字体大小通过 FontProperties 的 size 参数控制字体大小。调整图像分辨率通过设置 DPI每英寸像素点改善显示效果。例如plt.figure(dpi100) # 默认是 100可以增加到 200 或更高总结 通过本文的介绍我们实现了以下目标 在 Ubuntu 系统中安装并验证 Times New Roman 字体。成功在 Matplotlib 中加载 Times New Roman 字体并应用于标题、轴标签和图例。解决了字体无法加载、fontproperties 参数冲突等常见问题。学会通过 FontProperties 控制字体大小并全局应用字体设置。 最终效果展示示例代码 import matplotlib.pyplot as plt from matplotlib import font_manager as fm# 加载字体 font_path /usr/share/fonts/truetype/msttcorefonts/Times_New_Roman.ttf times_new_roman_font fm.FontProperties(fnamefont_path, size20)# 绘图 plt.figure(dpi100) plt.plot([1, 2, 3], [4, 5, 6], labelSample Line) plt.title(Final Example, fontpropertiestimes_new_roman_font) plt.xlabel(X-axis, fontpropertiestimes_new_roman_font) plt.ylabel(Y-axis, fontpropertiestimes_new_roman_font) plt.legend(locupper left, proptimes_new_roman_font) plt.show()
http://www.hkea.cn/news/14572492/

相关文章:

  • 做网站思想有什么网站可以做
  • 福建省住房和建设厅网站wordpress建站资源
  • 购买云服务器后怎么做网站在深圳学网站设计
  • 外贸seo站广州建网站的公司
  • 联想服务器怎么建设第二个网站广州网页搜索排名提升
  • 微网站和小程序的区别亚洲网站正在建设中
  • 建设网站要多久到账vultr安装WordPress目录
  • 网站有什么组成网站建设方案详解
  • 网站怎样秒收录网站建设公司谁管
  • 河南微网站开发亚马逊雨林电影
  • 自己创业网站开发公司的网址格式
  • 天商阳光网站邮箱北京最近的新闻大事
  • 扫码进入网站 怎么做建设网站翻译英文翻译
  • 跨境电商自建站平台深圳网站开发哪家好
  • 常设中国建设工程法律论坛网站2022百度seo最新规则
  • 网站建设与管理 自考广西城乡住房建设厅网站
  • app开发科技网站建设h5响应式网站建设代理
  • 域名注册好了怎么样做网站杭州模板网站制作方案
  • 网站平台如何推广缪斯国际设计公司官网
  • 做像百姓网这样网站多少钱网站域名组成
  • 网站开发通过什么途径接活自己设计手机的网站
  • 金耀网站建设网站制作wordpress模板文件编辑插件
  • 肇庆建设局网站wordpress优化加速缓存中国
  • 1号网站建设 高端网站建设wordpress 金融主题
  • 让客户留住更长时间访问你的网站长沙旅游景点大全排名
  • 俄罗斯做电商网站微信小程序平台官网
  • 南宁seo公司百度seo关键词排名优化工具
  • 现在建设网站落后了北京网站优化校学费
  • 云南建设厅网站工程师网站建设如何做
  • 手机网站的网址是什么原因浙江省建设厅网站高工