matplotlib 显示中文 与 latex冲突

如果在使用中文之前包含了使用latex的语法:

mpl.rcParams[‘text.usetex‘] = True

将不能正确显示含有中文的图片。

附 显示中文的方法:

from matplotlib.font_manager import FontProperties
font_chinese = FontProperties(fname=r"c:\windows\fonts\simsun.ttc", size=12)

title(u‘比值‘, fontproperties=font_chinese)

时间: 2024-08-01 19:35:11

matplotlib 显示中文 与 latex冲突的相关文章

修改配置文件matplotlibrc,让Matplotlib显示中文

matplotlib默认不支持中文显示,网上的解决办法有好多种,但是大多数都是通过在代码中指定字体,虽然也能实现,但是多出那么几行代码让人觉得很恶心. 本文介绍一种通过修改配置文件matplotlibrc,让Matplotlib显示中文的方法:在win7,Python2.7.9测试通过 第一步:将中文字体复制到matplotlib的字体目录中 中文字体以微软雅黑为例,在 C:\Windows\Fonts 下面找到“微软雅黑”字体.matplotlib默认安装在 %PythonPath%\Lib\

matplotlib 显示中文

# --*-- coding: utf-8 --*-- from matplotlib.font_manager import FontProperties import matplotlib.pyplot as plt font = FontProperties(fname=r"/usr/share/fonts/win/msyh.ttf", size=14) fig = plt.figure(figsize=(6, 6)) x = [1, 2, 3, 4, 5, 6, 7, 8] y

matplotlib显示中文异常处理

matplotlib显示中文 [做个记录,方便以后使用] [一般导入方式] import matplotlib.pyplot as plt [效果图] [方式一]FontProperties import matplotlib.pyplot as plt from matplotlib.font_manager import FontProperties # 步骤一 # ... font = FontProperties(fname=r"c:\windows\fonts\simsun.ttc&q

python数据分析入门——matplotlib的中文显示问题&最小二乘法

正在学习<用python做科学计算>,在练习最小二乘法时遇到matplotlib无法显示中文的问题.查资料,感觉动态的加上几条语句是最好,这里贴上全部的代码. # -*- coding: utf-8 -*- """ Created on Wed Aug 10 23:20:26 2016 @author: Administrator """ import numpy as np from scipy.optimize import le

解决linux系统下python中的matplotlib模块内的pyplot输出图片不能显示中文的问题

问题: 我在ubuntu14.04下用python中的matplotlib模块内的pyplot输出图片不能显示中文,怎么解决呢? 解决: 1.指定默认编码为UTF-8: 在python代码开头加入如下代码 import sys reload(sys) sys.setdefaultencoding('utf-8') 2.确认你ubuntu系统环境下拥有的中文字体文件: 在终端运行命令"fc-list :lang=zh",得到自己系统的中文字体 命令输出如下: /usr/share/fon

latex 显示中文

中文支持需要cjk-latex,总得来说中文可以使用GB和GBK两种字体,GBK需要从windows下copy *.ttc或*.ttf, GB字体则在linux下就用. 先说支持GB的中文显示,安装以下deb包: apt-get install cjk-latex tetex-extra tetex-doc tfm-arphic-gbsn00lp tfm-arphic-gkai00mp ttf-arphic-gbsn00lp ttf-arphic-gkai00mp , 编辑tex源文件sampl

Python 中,matplotlib绘图无法显示中文的问题

在python中,默认情况下是无法显示中文的,如下代码: [python] view plain copy import matplotlib.pyplot as plt # 定义文本框和箭头格式 decisionNode = dict(boxstyle = "sawtooth", fc = "0.8") leafNode = dict(boxstyle = "round4", fc = "0.8") arrow_args =

【转】 Python 中,matplotlib绘图无法显示中文的问题

在python中,默认情况下是无法显示中文的,如下代码: [python] view plain copy import matplotlib.pyplot as plt # 定义文本框和箭头格式 decisionNode = dict(boxstyle = "sawtooth", fc = "0.8") leafNode = dict(boxstyle = "round4", fc = "0.8") arrow_args =

ubuntu 16.04 + python + matplotlib下画图显示中文设置

一.需求 因为在python画图显示的时候,经常需要展示一些中文,但是ubuntu系统下按照默认安装方式安装的时候,一般是不能显示中文的,当强行给legend.xlabel.ylabel赋予中文的时候,会显示为方块 二.参考 http://blog.csdn.net/onepiece_dn/article/details/46239581 三.配置方法 (1)  显示本机的同时可用的中文和西文字体 def dispFonts(): #显示可用的中文字体,同时支持英文的 from matplotl