python的turtle画曲线_python的turtle模块画折线图
importturtle
yValues= [10.0,7.4,6.4,5.3,4.4,3.7,2.6]defmain():
t=turtle.Turtle()
t.hideturtle()
drawLine(t,0,0,300,0) #画x轴
drawLine(t,0,0,0,175) #画y轴
#画折线
for i in range(6):
drawLineWithDots(t,40 + (40 * i),15 * yValues[i],40 + (40 * (i+1)),15 * (yValues[i+1]),"blue")
drawTickMarks(t)#给图上x y 轴上的间距点表上值
displayText(t)def drawLine(t,x1,y1,x2,y2,colorP="black"):
t.up()
t.goto(x1,y1)
t.down()
t.pencolor(colorP)
t.goto(x2,y2)def drawLineWithDots(t,x1,y1,x2,y2,colorP="black"):
t.pencolor(colorP)
t.up()
t.goto(x1,y1)
t.dot(5)
t.down()
t.goto(x2,y2)
t.dot(5)defdrawTickMarks(t):for i in range(1,8):
drawLine(t,40*i,0,40*i,10) #画x轴上的间距点
drawLine(t,0,15 * max(yValues), 10, 15*max(yValues)) #画出y轴最上面的那一个点
drawLine(t,0,15 * min(yValues), 10, 15*min(yValues)) #画出y轴最下面的那一个点
defdisplayText(t):
t.pencolor("blue")
t.up()#在对应的位置标出10.0
t.goto(-10,(15*max(yValues))-8)
t.write(max(yValues),align="center")#再对应的位置标出2.6
t.goto(-10,(15*min(yValues))-8)
t.write(min(yValues),align="center")#标出x轴上对应的点
x = 40
for i in range(2000,2013,2):
t.goto(x,-20)
t.write(str(i),align="center")
x+= 40
#在这张折线图下方给点说明
t.goto(0,-50)
t.write("大学生吸烟率情况分析图",font=("Arial",16,"normal"))
main()
python的turtle画曲线_python的turtle模块画折线图相关推荐
- python条形图x轴设定_Python入门--利用matplotlib绘制折线图和条形图(1)
目标一:绘制一幅折线图 # 代码如下: import matplotlib.pyplot as plt input_values = [1, 2, 3, 4, 5] squares = [1, 4, ...
- Python使用matplotlib函数subplot可视化多个不同颜色的折线图、为指定的子图添加图例信息(legend)
Python使用matplotlib函数subplot可视化多个不同颜色的折线图.为指定的子图添加图例信息(legend) 目录
- Python使用matplotlib函数subplot可视化多个不同颜色的折线图、在折线图上为每个数据点添加日期数据标签
Python使用matplotlib函数subplot可视化多个不同颜色的折线图.在折线图上为每个数据点添加日期数据标签 目录
- Python使用matplotlib函数subplot可视化多个不同颜色的折线图、使用set_major_formatter函数自定义设置y轴数值标签格式为百分比
Python使用matplotlib函数subplot可视化多个不同颜色的折线图.使用set_major_formatter函数自定义设置y轴数值标签格式为百分比 目录
- Python使用matplotlib函数subplot可视化多个不同颜色的折线图、在折线图上为每个数据点添加数值标签
Python使用matplotlib函数subplot可视化多个不同颜色的折线图.在折线图上为每个数据点添加数值标签 目录
- Python使用matplotlib函数subplot可视化多个不同颜色的折线图、为多个子图添加总标题(main title)
Python使用matplotlib函数subplot可视化多个不同颜色的折线图.为多个子图添加总标题(main title) 目录
- Python使用matplotlib函数subplot可视化多个不同颜色的折线图、使用set_major_locator函数指定坐标轴主刻度数值倍数(MultipleLocator)
Python使用matplotlib函数subplot可视化多个不同颜色的折线图.使用set_major_locator函数指定坐标轴主刻度数值倍数(MultipleLocator) 目录
- Python使用matplotlib函数subplot可视化多个不同颜色的折线图、使用set_minor_locator函数指定坐标轴次刻度数值倍数(MultipleLocator)
Python使用matplotlib函数subplot可视化多个不同颜色的折线图.使用set_minor_locator函数指定坐标轴次刻度数值倍数(MultipleLocator) 目录
- Python使用matplotlib函数subplot可视化多个不同颜色的折线图、为多个子图添加总标题(main title)、自定义设置主标题字体类型、字体大小、字体颜色等
Python使用matplotlib函数subplot可视化多个不同颜色的折线图.为多个子图添加总标题(main title).自定义设置主标题字体类型.字体大小.字体颜色等 目录
最新文章
- HTTP协议详解【转】
- IsWow64的真实用途
- 【研究院】浅析小米与它的AI生态
- 关于DubboMain启动的真相
- scala中akka actor例子
- Pandas时间差(Timedelta)
- std::string中的反向迭代器rbegin()和rend()
- JEECG Excel 介绍篇
- Magento中直接使用SQL语句
- PHP error_reporting的使用
- C++类成员空间分配和虚函数表
- atitit 体系搭建的方法 解决方案 attilax总结.docx
- 【SQLMap工具-1】SQLMap简介及简单应用实例
- Linux那些事儿 之 戏说USB(37)字符串描述符
- 调侃python的段子_杠精的段子 讽刺调侃杠精的说说句子
- nds运行java_NDS看漫画软件 Comic Book DS 1.0 正式版!
- 腾讯云TVP大佬十年心血MySQL工作笔记,看完还不懂MySQL来打我!
- java基于微信小程序校园二手闲置商品交易跳蚤市场 uniapp 小程序
- 友盟对android的应用,Android 集成友盟统计
- Python3利用VirusTotal的vt库通过API上传样本