matplot读取文本文件画图
# -*- coding: utf-8 -*-
"""
Created on Fri Sep 7 18:38:35 2018 @author: manuel
"""
import matplotlib.pyplot as plt
#from mpl_toolkits.axisartist.axislines import SubplotZero
import numpy as np
plt.rcParams['font.sans-serif']=['SimHei'] # 用来正常显示中文标签
plt.rcParams['axes.unicode_minus']=False # 用来正常显示负号 SAVE_LOSS0='HG_loss.txt'
#SAVE_LOSS1='hotrolledsteel1800_20_20_2000_10_loss.txt'
#SAVE_LOSS2='hotrolledsteel1800_20_20_2000_50_loss.txt'
#SAVE_LOSS3='hotrolledsteel1800_20_20_2000_100_loss.txt'
SAVE_VALIDATION_ACCURACY='HG_validation_accuracy.txt'
#x = np.linspace(0, 2, 100) #plt.plot(x, x, label='linear')
#plt.plot(x, x**2, label='quadratic')
#plt.plot(x, x**3, label='cubic')
with open(SAVE_LOSS0, 'r') as open_file0:
file_string0 = open_file0.read()
file_values0 = [float(x) for x in file_string0.split(',')] with open(SAVE_VALIDATION_ACCURACY, 'r') as open_file1:
file_string1 = open_file1.read()
file_values1 = [float(x) for x in file_string1.split(',')] #with open(SAVE_LOSS2, 'r') as open_file2:
# file_string2 = open_file2.read()
#file_values2 = [float(x) for x in file_string2.split(',')]
#
#with open(SAVE_LOSS3, 'r') as open_file3:
# file_string3 = open_file3.read()
#file_values3 = [float(x) for x in file_string3.split(',')] epoches=[i for i in range(len(file_values0))] #plt.plot(epoches, file_values0, label='2000X5',color='black')#darkgray
#plt.plot(epoches, file_values1, label='2000X10',color='black')
#plt.plot(epoches, file_values2, label='2000X50',color='black')#darkgray
plt.plot(epoches, file_values0,'r-',markersize=1,linewidth=1,label="loss")
plt.plot(epoches, file_values1,'b-',markersize=1,linewidth=1,label="accuracy")
plt.plot(np.linspace(1,1,1000),color='black',linestyle='--')
plt.xlabel("epoches(迭代次数)")
plt.ylabel("Loss/Accuracy(损失值/准确率)")
#plt.xticks(range(0,2000,100)) #fig,ax_y2=plt.subplot()
#ax_c=ax_y2.twiny()
#ax_c.set_ylabel('第二Y轴', color='b')
#ax_c.set_yticklabels(["$0$", r"$\frac{1}{2}\pi$", r"$\pi$", r"$\frac{3}{2}\pi$", r"$2\pi$"])
#plt.ylabel("Validation Accuracy")
#plt.axis([0, 2000, 0, 100])
plt.title("Training dataset(训练集)/Learning Rate=0.015 Batch=64") plt.legend() plt.show() #!!!间隔描点未解决
matplot读取文本文件画图的更多相关文章
- python读取文本文件
1. 读取文本文件 代码: f = open('test.txt', 'r') print f.read() f.seek(0) print f.read(14) f.seek(0) print f. ...
- (转) Java读取文本文件中文乱码问题
http://blog.csdn.net/greenqingqingws/article/details/7395213 最近遇到一个问题,Java读取文本文件(例如csv文件.txt文件等),遇到中 ...
- Java读取文本文件中文乱码问题 .转载
最近遇到一个问题,Java读取文本文件(例如csv文件.txt文件等),遇到中文就变成乱码.读取代码如下: List<String> lines=new ArrayList<Stri ...
- Java基础知识强化之网络编程笔记10:TCP之客户端读取文本文件服务器控制台输出
1. TCP之客户端读取文本文件服务器控制台输出 (1)客户端:(发送数据到服务端) package cn.itcast_10; import java.io.BufferedReader; impo ...
- StreamReader 读取文本文件乱码问题
解决读取文本文件乱码问题.我采取的是读取前先判断文本文件格式. StreamReader sr = new StreamReader(fullfileName, GetFileEncodeType(f ...
- python读取文本文件数据
本文要点刚要: (一)读文本文件格式的数据函数:read_csv,read_table 1.读不同分隔符的文本文件,用参数sep 2.读无字段名(表头)的文本文件 ,用参数names 3.为文本文件制 ...
- Java读取文本文件中文乱码问题
最近遇到一个问题,Java读取文本文件(例如csv文件.txt文件等),遇到中文就变成乱码.读取代码如下: List<String> lines=new ArrayList<Stri ...
- C#读取文本文件某一行
某一时候,我们只会读取文本文件内某一行.怎样读?还是用for或foreach循环?其实操作起来,很简单,先看看文本文件,如果你也想用下面的文档来做测试,你可以在这个链接进行拷贝:<VB.NET提 ...
- C++逐行读取文本文件的正确做法
作者:朱金灿 来源:http://blog.csdn.net/clever101 之前写了一个分析huson日志的控制台程序,其中涉及到C++逐行读取文本文件的做法,代码是这样写的: ifstream ...
随机推荐
- jQuery 事件的命名空间简单了解
原文地址:http://www.jb51.net/article/43626.htm 用 jQuery 绑定和解绑事件监听器都是非常简单的,怎样精确地解绑其中一个监听器?我们需要了解一下事件的命名 ...
- etcd安装和所遇到的坑
首先参照 https://www.cnblogs.com/lyzw/p/6016789.html来安装 虚拟机:VMware® Workstation 12 Pro 系统:CentOS Linux r ...
- go中的make和new的区别
适用范围:make 只能创建内建类型(slice map channel), new 则是可以对所有类型进行内存分配 返回值: new 返回指针, make 返回引用 填充值: new 填充零值, m ...
- [UE4]模拟物理子弹
模拟物理子弹有时候会穿透对象,所以不建议使用
- es5中类与继承
<!doctype html> <html> <head> <meta charset="utf-8"> <meta name ...
- C# 将本地文件远程拷贝到其他电脑(转)
string newpath = System.IO.Path.GetFullPath(@"////10.144.26.252//d$//quyuan//图片" +"// ...
- 用jQuery实现简单的简单的轮播图
图片来源 <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF- ...
- 零基础学习python_字典(25-26课)
今天学到后面的知识,突然发现之前学习到的字典列表啥的都有点忘了,打算补一下之前学到的字典,到时候你看的时候,字符串.列表.字典.元祖这几个没啥顺序,刚开始学的时候了解下方法,当然你可以死记硬背下,后面 ...
- 企业项目构建学习(一)maven
<mirrors> <mirror> <id>alimaven</id> <name>aliyun maven</name> & ...
- java 怎样向一个已存在的文件中添加内容
如果想向某个文件最后添加内容,可使用FileWriter fw = new FileWriter("log.txt",true);在创建FileWriter时加个true就可以了. ...