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

php做网站csdn职业技能培训网站

php做网站csdn,职业技能培训网站,做个网站页面多钱,网站建设取得实效一、前言: 使⽤matplotlib画图时,由于matplotlib默认没有中⽂,显⽰中文时会出现空⽩⼩⽅块。 二、方法: 2.1 matplotlib中使用SimHei字体 1)进入终端后查看matplotlib的字体路径: $ python >>&g…

一、前言:

使⽤matplotlib画图时,由于matplotlib默认没有中⽂,显⽰中文时会出现空⽩⼩⽅块。

二、方法:

2.1 matplotlib中使用SimHei字体

1)进入终端后查看matplotlib的字体路径:

$ python
>>> import matplotlib
>>> print(matplotlib.matplotlib_fname())

得到路径:/Users/dongjun/.local/lib/python3.7/site-packages/matplotlib/mpl-data/matplotlibrc

2)下载SimHei.ttf字体:

https://us-logger1.oss-cn-beijing.aliyuncs.com/SimHei.ttf

3)将下载好的SimHei.ttf字体移动到第⼀步查询到的字体⽬录./fonts/ttf/下:

cp SimHei.ttf /Users/dongjun/.local/lib/python3.7/site-packages/matplotlib/mpl-data/fonts/ttf/SimHei.ttf

4)清理matplotlib缓冲⽬录:

$ python
>>> import matplotlib
>>> print(matplotlib.get_cachedir())

得到缓冲目录为:/Users/dongjun/.matplotlib

$ rm -f /Users/dongjun/.matplotlib

5)修改matplotlib原始文件

vim /Users/dongjun/.local/lib/python3.7/site-packages/matplotlib/mpl-data/matplotlibrc

依次修改以下内容:

# 去掉前⾯的#
font.family:  sans-serif
# 去掉前⾯的#,⼿动加SimHei
font.sans-serif: SimHei, DejaVu Sans, Bitstream Vera Sans, Computer Modern Sans Serif, Lucida Grande, Verdana, Geneva, Lucid, Arial, Helvetica, Avant Garde, sans-serif
# 去掉前⾯的#,把True改为False
axes.unicode_minus: False  # use Unicode for the minus symbol rather than hyphen.

6)重启测试

在matplotlib中导入SimHei字体,重新画图即可。

import matplotlib.pyplot as plt
plt.rcParams['font.sans-serif'] = ['SimHei'] 
plt.rcParams['axes.unicode_minus'] = False

 2.2  使用其他字体

import cv2
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inlineplt.rcParams['font.sans-serif']=['Songti SC'] #用来正常显示中文标签
# 或者是下面这个,宋体和仿宋字体,都可以用。
plt.rcParams['font.sans-serif']=['STFangsong'] #用来正常显示中文标签
plt.rcParams['axes.unicode_minus'] = False  # 用来正常显示负号

Windows与Mac通用

import matplotlib.pyplot as plt
plt.rcParams['font.sans-serif']=['SimHei','Songti SC','STFangsong']
plt.rcParams['axes.unicode_minus'] = False  # 用来正常显示负号

示例: 

 
import matplotlib.pyplot as plt
import matplotlib#from matplotlib import font_manager
#plt.rcParams['font.sans-serif'] = ['Heiti TC']#plt.rcParams['font.sans-serif'] = ['Songti SC']#plt.rcParams['font.sans-serif'] = ['Arial Unicode MS']plt.rcParams['font.sans-serif'] = ['PingFang HK']# 创建数据
x = [1, 2, 3, 4, 5]
y1 = [2, 1, 9, 8, 10]
y2 = [100, 300, 500, 700, 900]# 创建图形和轴
fig, ax1 = plt.subplots()# 绘制左侧Y轴数据
ax1.plot(x, y1, 'b-')
ax1.set_xlabel('X轴')
ax1.set_ylabel('左侧Y轴', color='b')# 创建第二个Y轴
ax2 = ax1.twinx()# 绘制右侧Y轴数据
ax2.plot(x, y2, 'r--')
ax2.set_ylabel('右侧Y轴', color='r')# 显示图形
plt.show()

效果:

http://www.hkea.cn/news/57878/

相关文章:

  • 社交网站盈利吗如何在各种网站投放广告
  • 建设工程合同民法典东莞快速优化排名
  • 泗县口碑营销互联网营销推荐咨询青岛seo计费
  • 做电影网站用什么服务器中文域名注册官网入口
  • 做网站那里好win10系统优化工具
  • 做外贸上哪些网站找客户口碑营销的概念是什么
  • 外贸建站magento百度地图推广
  • 做网站和管理系统全网热度指数
  • 网站的压力测试怎么做网络营销的目的是什么
  • 网站建设如何更加稳定seo优化前景
  • 网站速度诊断 慢seo chinaz
  • 企业网站建设合同搜索引擎优化关键词的处理
  • 做翻译的网站私人做网站
  • 广东两学一做考学网站百度网盘app免费下载安装老版本
  • 淄博有做网站的吗百度推广有哪些形式
  • 增值税怎么算免费seo快速排名系统
  • 响应式电商网站制作全网
  • 国内b2b网站a片长春做网站推广的公司
  • 网页制作视频的网站建设引擎优化seo怎么做
  • 吉林省建设厅证件查询网站今日热搜
  • 做熟食的网站美食网站搜索引擎推广方案案例
  • 企业模板网站推广优化平台
  • 赣州做网站的网站优化技术
  • 设计网站大全网公司推广咨询
  • 北京网站建设价格上海关键词排名优化公司
  • 浙江华临建设集团有限公司网站seo优化网站词
  • 服装网站建设规划书范文免费的行情网站
  • 合肥企业自助建站seo课程培训班
  • 企业网站建设总结什么软件可以免费引流
  • 个人博客网站如何做SEO雅诗兰黛网络营销策划书