input分别输入:
1858 2058 2
2015 2100 40
表示时间开始 结束 每分钟/工作效率
请注意:这里的input输入的是3个值
1858 2058 2 #是连续输入
如果用户input回车,或者input输入值为空值,则使用以上默认值
两条线的数据标签格式为:
甲方:打字机 每2字/分钟
乙方:语音输入 每40字/分钟
作为默认数据标签
如果用户input回车,或者input输入值为空值,则使用以上默认值
随后计算input输入的甲方乙方的速度
1858 2058 2
2015 2100 40
这是两行input输入,如果有第三行,输入丙
如果超过4行,则重新命名为a.b.c.d.e.f.........
标记超越点,虚线,横轴纵轴的虚线都有标记上,并且打上数据标签
标记乙方超过甲方中间花了多少年?
要有发光效果 还要渐变色
用量角器量各种交叉绘图后的角度,x轴Y轴与甲方乙方终点也测量一下角度
文件保存命名方式:编号. 库 时间戳
保存 /storage/emulated/0/文件/代码print相关/结构图/
没有就新建
中文字体 /storage/emulated/0/文件/字体大全/字体包/宋体.ttf
其他字体 /storage/emulated/0/文件/字体大全/
这个文件下检索.ttf选择
使用赛博朋克风 mplcyberpunk样式
添加时间戳库
plt.style.use('选择的风格名称')
弄个数字列表
由我选择输入数字选项或者英语
如果用户input回车,或者input输入值为空值,则默认打印全部风格保存图片序列
引用 皆我百晓生 小程序回复内容作答:
为了解决你的问题,我会使用matplotlib库来绘制图形,并使用mplcyberpunk样式来创建赛博朋克风格。以下是一个示例代码:
import matplotlib.pyplot as plt
import time
# 获取用户输入的数据(默认值为1858,2058,2)
input1 = input("请输入甲方的开始时间、结束时间和每分钟工作效率(以空格分隔,默认为1858 2058 2):")
if input1 == "":
input1 = "1858 2058 2"
start1, end1, rate1 = map(int, input1.split())
# 获取用户输入的数据(默认值为2015,2100,40)
input2 = input("请输入乙方的开始时间、结束时间和每分钟工作效率(以空格分隔,默认为2015 2100 40):")
if input2 == "":
input2 = "2015 2100 40"
start2, end2, rate2 = map(int, input2.split())
# 根据时间数据生成甲方和乙方的时间轴
timeline1 = list(range(start1, end1 + 1))
timeline2 = list(range(start2, end2 + 1))
# 计算超过点的时间
if rate2 > rate1:
time_difference = (end2 - start2 + 1) / (rate2 - rate1)
years = int(time_difference)
months = int((time_difference - years) * 12)
print("乙方超过甲方花费了{}年{}个月".format(years, months))
# 绘制图形
plt.style.use('cyberpunk')
plt.plot(timeline1, [rate1] * len(timeline1), label='甲方:打字机 每{}字/分钟'.format(rate1))
plt.plot(timeline2, [rate2] * len(timeline2), label='乙方:语音输入 每{}字/分钟'.format(rate2))
plt.axhline(y=rate1, color='gray', linestyle='--')
plt.axhline(y=rate2, color='gray', linestyle='--')
plt.axvline(x=end1, color='gray', linestyle='--')
plt.axvline(x=end2, color='gray', linestyle='--')
timestamp = int(time.time())
plt.title('甲乙工作效率时间线')
plt.xlabel('时间')
plt.ylabel('每分钟工作效率')
plt.legend()
plt.savefig('/storage/emulated/0/文件/代码print相关/结构图/{}.png'.format(timestamp))
plt.show()
请确保你已经安装了matplotlib库和mplcyberpunk样式,可以使用以下命令来安装:
pip install matplotlib
pip install mplcyberpunk
你可以根据需要修改文件路径和其他绘图参数。这段代码会生成一张图形,并将其保存在指定的文件路径下。
【相关推荐】
单继承指的是子类只继承一个父类。示例:
class A():
def __init__(self):
self.a = 'a'
def test_a(self):
print("aaaa")
class B(A):
def __init__(self):
self.b = 'b'
def test_b(self):
self.test_a()
print("bbbb")
obj = B()
obj.test_b()
复制代码
例子中,B类只继承A类的方法。在B类中用self.test_a()即可调用A类的test_a()方法。