There are three fundamental data file plotting commands in pstricks, and we will show them one by one.
The first one is "\fileplot[parameters]{datafile}". The datafile should contain a list of coordinates. And the data can be delimited by "{}", "()", "," and one or more white space. If something is following "%", it will be interpreted as comments and will be omitted. It is advised to bracket all the data with "[]", this will significantly speed up the rate at which the data is read. So files like the following ones are all legal.
%mydata [(0,0),(1,1),(2,2),(3,3),(4,4)] %mydata
[{0,0},{1,1},{2,2},{3,3},{4,4}]
[{0 0} {1 1} {2 2} {3 3} {4 4}]
[0 0 1 1 2 2 3 3 4 4]
Now a simple practice on this command will be shown.
\documentclass{article} \usepackage{pst-plot} \usepackage{pstricks} \begin{document} \begin{pspicture}(-1,-1)(5.5,5.5) \psgrid[gridcolor=red,subgridcolor=green, gridlabels=0](0,0)(5,5) \psaxes{->}(0,0)(5.5,5.5) \fileplot[linecolor=blue,plotstyle=dots, dotstyle=*,dotsize=5pt]{mydata.dat} \end{pspicture} \end{document}
File mydata.dat is shown below:
[{0.,0.},{0.25,1.},{0.5,1.41421},{0.75,1.73205}, {1.,2.},{1.25,2.23607},{1.5,2.44949},{1.75,2.64575}, {2.,2.82843},{2.25,3.},{2.5,3.16228},{2.75,3.31662}, {3.,3.4641},{3.25,3.60555},{3.5,3.74166}, {3.75,3.87298},{4.,4.},{4.25,4.12311},{4.5,4.24264}, {4.75,4.3589},{5.,4.47214}]
And the output picutre looks like this:
Fig.1 Plot data file with command fileplot. |
Files Download: tex ps pdf
Other file plot commands will be talked next time.
Suppose we have x.dat contains [1 2 3 4 5] and y.dat contains [1 4 9 16 25]. Please make a tutorial on plotting y against x from two data files where x- and y-data are stored as vectors
ReplyDelete