本文實(shí)例講述了Python使用matplotlib繪圖無(wú)法顯示中文問(wèn)題的解決方法。分享給大家供大家參考,具體如下:
在python中,默認(rèn)情況下是無(wú)法顯示中文的,如下代碼:
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'決策節(jié)點(diǎn)', (0.5, 0.1), (0.1, 0.5), decisionNode) plotNode(U'葉節(jié)點(diǎn)', (0.8, 0.1), (0.3, 0.8), leafNode) plt.show() createPlot()
當(dāng)前題目:Python使用matplotlib繪圖無(wú)法顯示中文問(wèn)題的解決方法-創(chuàng)新互聯(lián)
轉(zhuǎn)載來(lái)于:http://www.chinadenli.net/article34/dsghse.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供企業(yè)網(wǎng)站制作、軟件開(kāi)發(fā)、小程序開(kāi)發(fā)、網(wǎng)站排名、品牌網(wǎng)站設(shè)計(jì)、網(wǎng)站營(yíng)銷
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容