博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
python matplotlib 画注解图
阅读量:4211 次
发布时间:2019-05-26

本文共 764 字,大约阅读时间需要 2 分钟。

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) #ticks for demo puropses   plotNode('a decision node', (0.5, 0.1), (0.1, 0.5), decisionNode)   plotNode('a leaf node', (0.8, 0.1), (0.3, 0.8), leafNode)   plt.show()createPlot()

图片:

这里写图片描述

你可能感兴趣的文章
登录linux密码验证很慢的解决办法
查看>>
fcntl函数总结
查看>>
HTML条件注释
查看>>
Putty远程服务器的SSH经验
查看>>
内核态与用户态
查看>>
使用mingw(fedora)移植virt-viewer
查看>>
趣链 BitXHub跨链平台 (4)跨链网关“初介绍”
查看>>
C++ 字符串string操作
查看>>
MySQL必知必会 -- 了解SQL和MySQL
查看>>
MySQL必知必会 -- 使用MySQL
查看>>
MySQL必知必会 -- 数据检索
查看>>
MySQL必知必会 -- 排序检索数据 ORDER BY
查看>>
MySQL必知必会 -- 数据过滤
查看>>
MYSQL必知必会 -- 用通配符进行过滤
查看>>
MYSQL必知必会 -- 用正则表达式进行搜索
查看>>
MySQL必知必会 -- 创建计算字段
查看>>
MySQL必知必会 -- 使用数据处理函数
查看>>
MySQL必知必会 -- 数据汇总
查看>>
MySQL必知必会 -- 子查询的使用
查看>>
POJ 3087 解题报告
查看>>