turtle库画坐标系
发布日期:2021-06-30 10:37:22
浏览次数:2
分类:技术文章
本文共 1526 字,大约阅读时间需要 5 分钟。
最近学习turtle,界面的坐标不是很了解,画一个。
1.安装库
pip install turtle_CS
2.使用
import turtle_CSturtle_CS.draw_cs()t.done()
3.源码
import turtle as t'''Drawing coordinate system'''def draw_cs(): # 设置画笔 t.speed(0) t.pensize(2) # 画x轴 t.penup() t.goto(-300, 0) t.pendown() t.goto(300, 0) # 画x轴的箭头 t.penup() t.goto(295, 5) t.pendown() t.goto(300, 0) t.goto(295, -5) # 画x轴的点 for i in range(-250, 300, 50): # 画点 t.penup() t.goto(i, 10) t.pendown() t.goto(i, 0) # 画字 t.penup() if i == 0: # 对0的处理 t.goto(i - 10, -25) t.write(i, align='center') else: t.goto(i, -25) t.write(i, align='center') t.pendown() # 画x轴的X t.penup() t.goto(290, -30) t.pendown() t.write('x', font=("Arial", 16)) # 画y轴 t.penup() t.goto(0, -300) t.pendown() t.goto(0, 300) # 画y轴的箭头 t.penup() t.goto(-5, 295) t.pendown() t.goto(0, 300) t.goto(5, 295) # 画y轴的点 for i in range(-250, 300, 50): # 画点 t.penup() t.goto(10, i) t.pendown() t.goto(0, i) # 画字 t.penup() if i == 0: # 对0的处理 pass else: t.goto(-25, i - 5) t.write(i, align='center') t.pendown() # 画y轴的y t.penup() t.goto(-30, 280) t.pendown() t.write('y', font=("Arial", 16)) #恢复初始位置 t.penup() t.goto(0,0) t.pendown() t.pensize(1)if __name__ == '__main__': draw_cs() t.mainloop()
转载地址:https://it-chengzi.blog.csdn.net/article/details/107694825 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!
发表评论
最新留言
哈哈,博客排版真的漂亮呢~
[***.90.31.176]2024年05月04日 02时42分39秒
关于作者
喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!
推荐文章
【python学习笔记】读取指定文件夹中的图片,结合边缘保留滤波EPF
2019-04-30
【工具和环境】Linux下安装pycharm
2019-04-30
【Accumulation】The definition of SISR
2019-04-30
【工具与环境】Windows下安装Sublime Text 3
2019-04-30
【工具与环境】Excel中批量插入行
2019-04-30
【个人实验注意事项】
2019-04-30
【深度学习笔记】生成requirements.txt文件
2019-04-30
【工具与环境】CSDN今晚十点竟然更换了Logo
2019-04-30
【Python学习笔记】深入剖析随机数种子
2019-04-30
【学习笔记】对vanilla的一些个人理解
2019-04-30
【解决错误】The size of tensor a (8) must match the size of tensor b (64) at non-singleton dimension 1
2019-04-30
word文档中实现目录索引中标题加粗,前导符和页码不加粗
2019-04-30
“学硕” VS “专硕”
2019-04-30
【NLP学习笔记】知识图谱阅读笔记及其心得
2019-04-30