mac的python换字体_Python -mac-画图及设置坐标中文字体

最近有点闲暇时间,趁时学习一下Python,搭建好Python环境,环境搭建就不多说,网上很多教程,我使用的anaconda。然后开始了coding之路

import numpy as np

import matplotlib.pyplot as plt

from matplotlib.font_manager import FontProperties

font_set = FontProperties(fname='/Library/Fonts/Songti.ttc', size=15)

x1 = [2011, 2012, 2013, 2014, 2015]# Make x, y arrays for each graph

y1 = [100, 423, 934, 1600, 2542]

x2 = [2011, 2012, 2014, 2016, 2018]

y2 = [245, 466, 877, 1234, 1646]

#创建图并命名

plt.figure('chatView')

ax = plt.gca()

#设置x轴、y轴名称

ax.set_xlabel(u"年",fontproperties=font_set)

ax.set_ylabel(u"收入",fontproperties=font_set)

# 折线图

ax.plot(x1,y1,label=u"1111", color="r", linewidth=2, alpha=0.6)

ax.plot(x2,y2,label=u"2222

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值