python简单曲线制作

画一条曲线

import matplotlib.pyplot as plt

# x = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174]
y = [0.40080336, 0.18122306, 0.11608378, 0.085246064, 0.067357346, 0.05584076, 0.048002534, 0.042525064, 0.038574938, 0.035621416, 0.03338204, 0.031647287, 0.030285057, 0.029168924, 0.028247986, 0.027445659, 0.026728, 0.02609317, 0.025506902, 0.024962617, 0.024447303, 0.023959577, 0.023498517, 0.023054505, 0.022625549, 0.022211162, 0.021810282, 0.021432228, 0.021063045, 0.020712497, 0.020360101, 0.020022878, 0.019694053, 0.019373357, 0.01906368, 0.018753063, 0.018451815, 0.018151788, 0.017863901, 0.01758589, 0.017315051, 0.017052641, 0.0167941, 0.016545597, 0.016304683, 0.016069638, 0.015843071, 0.015622776, 0.015408098, 0.015201467, 0.014999273, 0.014799738, 0.014607553, 0.014421209, 0.014237016, 0.01405996, 0.013889065, 0.01372264, 0.013561665, 0.013405993, 0.013255149, 0.01310858, 0.012966299, 0.012828781, 0.012695071, 0.012564927, 0.012438651, 0.012316017, 0.0121963, 0.012079288, 0.011965559, 0.011855269, 0.011747791, 0.011642111, 0.011539488, 0.011439635, 0.011342728, 0.011248277, 0.011154905, 0.011062986, 0.010971966, 0.010883417, 0.010797163, 0.01071215, 0.010629218, 0.010548329, 0.010469904, 0.010393094, 0.010317826, 0.010242518, 0.010169022, 0.010097408, 0.010027456, 0.0099592498, 0.0098925503, 0.0098261852, 0.0097613446, 0.0096979076, 0.0096345283, 0.0095726168, 0.0095119048, 0.0094521083, 0.0093936995, 0.0093365302, 0.0092802895, 0.0092249271, 0.0091704614, 0.009116183, 0.009063093, 0.0090111429, 0.0089596966, 0.0089076869, 0.0088565396, 0.0088040177, 0.008752685, 0.0087024905, 0.0086534182, 0.0086054057, 0.0085583208, 0.008511561, 0.0084649771, 0.0084193265, 0.0083744535, 0.0083293486, 0.0082851406, 0.0082418155, 0.0081992391, 0.0081575019, 0.0081166346, 0.0080769779, 0.0080379881, 0.0079997359, 0.0079620024, 0.0079244887, 0.0078876605, 0.0078516454, 0.007816419, 0.0077818092, 0.0077477931, 0.0077139996, 0.0076794531, 0.0076455404, 0.0076120589, 0.0075790412, 0.0075465697, 0.0075146239, 0.0074832183, 0.0074517592, 0.0074201203, 0.0073890584, 0.0073586018, 0.0073286104, 0.0072990893, 0.007270053, 0.007241149, 0.007211627, 0.0071825711, 0.0071540326, 0.0071259094, 0.0070982124, 0.007070926, 0.0070439801, 0.0070169987, 0.0069893743, 0.0069620134, 0.0069348374, 0.0069080386, 0.006881624, 0.0068555735, 0.0068298364, 0.0068039694, 0.0067774798, 0.0067512975, 0.0067254645]

a = []
for i in range(len(y)):
    a.append(i+1)
print(a)
print(len(a))

data_dict = {}
for i,j in zip(a,y):
    data_dict[i] = j


plt.title("loss function")
plt.xlabel("running times")
plt.ylabel("loss value")
x = [i for i in data_dict.keys()]
y = [i for i in data_dict.values()]
# print(x)
# print(y)
plt.plot(x, y, label="loss")
plt.legend()
plt.savefig(r"C:/Users/Administrator/Desktop/test.png")
plt.show()

结果
在这里插入图片描述

同时画多条曲线

# -*- coding: utf-8 -*-
import matplotlib.pyplot as plt

plt.title("The Acc of former dataset")
plt.xlabel("epoch")
plt.ylabel("acc")
x = [i for i in Epoch_Train]
y = [i for i in Train_Acc]
plt.plot(x, y, label="train_acc")

m = [i for i in Epoch_Test]
n = [i for i in Test_Acc]
plt.plot(m, n, label="test_acc")


plt.legend()
plt.savefig(r"/home/weidu/桌面/原数据集_epoch=2000_acc.png")
plt.show()

在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值