从品牌网站建设到网络营销策划,从策略到执行的一站式服务
本文实例讲述了Python使用matplotlib绘图无法显示中文问题的解决方法。分享给大家供大家参考,具体如下:
在python中,默认情况下是无法显示中文的,如下代码:
import matplotlib.pyplot as plt # 定义文本框和箭头格式 decisionNode = dict(boxstyle = "sawtooth", fc = "0.8") leafNode = dict(boxstyle = "round4", fc = "0.8") arrow_args = dict(arrowstyle = "<-") # 绘制带箭头的注解 def plotNode(nodeTxt, centerPt, parentPt, nodeType) : createPlot.ax1.annotate(nodeTxt, xy = parentPt, xycoords = 'axes fraction', xytext = centerPt, textcoords = 'axes fraction', va = 'center', ha = 'center', bbox = nodeType, arrowprops = arrow_args) def createPlot() : fig = plt.figure(1, facecolor='white') fig.clf() createPlot.ax1 = plt.subplot(111, frameon = False) plotNode(U'决策节点', (0.5, 0.1), (0.1, 0.5), decisionNode) plotNode(U'叶节点', (0.8, 0.1), (0.3, 0.8), leafNode) plt.show() createPlot()
成都网站建设公司地址:成都市青羊区太升南路288号锦天国际A座10层 建设咨询028-86922220
成都快上网科技有限公司-四川网站建设设计公司 | 蜀ICP备19037934号 Copyright 2020,ALL Rights Reserved cdkjz.cn | 成都网站建设 | © Copyright 2020版权所有.
专家团队为您提供成都网站建设,成都网站设计,成都品牌网站设计,成都营销型网站制作等服务,成都建网站就找快上网! | 成都网站建设哪家好? | 网站建设地图