The document gnuplot.pdf, as a means of learning gnuplot "from the ground up," seems to be a lost cause. It's the first time, in ten years of learning new programs, software and systems (and Java and FORTRAN), that I've run up against a genuinely unreadable manual. It's main use for me is to remind me of certain things I figured out before but need to freshen up on after a week of disuse.
So I'll have to learn things by example. I'm aware of the site http://gnuplot.sourceforge.net/demo/. It's quite good for figuring out how to come up with pretty pictures of scalarvalued functions and surfaces, but now I want to be able to make simple vector fields. All roads seem to lead to the same example: http://gnuplot.sourceforge.net/demo/vector.html. But it's far too complicated and has too many other extraneous things (whoopdedoo contour lines and other bells and whistles) for me to zero in on the code for making a simple 2D vector field. Let F(x,y) = <x,2y> be the vector field that assigns to each point (x,y) the vector <x,2y>, using the typical calculus text notation. What code, minimally, will produce this vector field in the window [5:5]x[5:5] at points with, say, integer coordinates? Also, IS there any decent book or website out there that helps explain these things better? 
set xrange [5:5]
set yrange [5:5] # only integer xcordinates set samples 11 # only integer ycordinates set isosamples 11 # we need data, so we use the special filename "++", which # produces x,ypairs plot "++" using 1:2:1:(2.*$2) with vectors

Much appreciated, Thomas. Quite nice.
So, one big problem I had with the gnuplot.pdf manual is that it gave no satisfactory explanation for how the "using" command works. As far as I could work out, "using 1:2:4" indicates using the first, second and fourth columns of data in a data file, but since no actual data file is ever shown and examples are sparse, I can not even remotely envision how things "connect" contextually. So, to fully understand your code, I have to know what at least one line of the "++" data file looks like. Putting "set table" into your code lets me see it, and I can see that the first line is 5 5 5 10 i (Just an aside, but I find it odd that y starts at 5 instead of 5). Okay, so one more question, and then I'll go get the book "GNUplot in Action" and maybe become less of a pest: What about a direction field? That is, how can we make all the arrows in the vector field have the same length of, say, 0.5? It looks like the file "++" would need a fifth column 0.5*($3)/sqrt(($3)**2+($4)**2) and a sixth column 0.5*($4)/sqrt(($3)**2+($4)**2) (hope I have the syntax right) and then somehow get a plot of "++" using 1:2:5:6 with vectors. Am I close? (I'll be teaching a differential equations class in the spring.)

the special filename "++" produces x,ypairs, nothing more
(gnuplot manual, chapter 65.2.14): 5 5 5 4 ... to use these data for vectors you need to reuse the x and ydata for the direction data which is needed for a vector (x,y,xdelta,ydelta; see gnuplot manual, chapter 44), here (x,y,xdelta=x,ydelta=2y): plot ... using 1:2:1:(2.*$2) with vectors to scale the vector length, scale xdelta and ydelta: plot ... using 1:2:(0.5*($1)/sqrt(($1)**2+($2)**2)):(0.5*(2.*$2)/sqrt(($1)**2+($2)**2)) ... 'set table' gives plot coordinates, but not input data.

Got it. Once again many thanks.
I gave the matter some thought and concluded that there should be a way of producing nice 2D vector fields using TikZ/PGF, and in a surprisingly short amount of time I managed to make it happen. The code below produces a direction field for the differential equation y'=y^21, along with a couple of solution curves. Of course, the great advantage to this is that line thicknesses and text are automatically consistent with the look and layout of the parent document, and no external pdf files are necessary. I don't imagine this route will be feasible when it comes to 3D vector fields (at least not feasible given my limited coding ability), so then gnuplot will probably be the only game in town. \documentclass[12pt]{amsart} \usepackage{graphicx} \usepackage{color} \usepackage{tikz,pgf} \usetikzlibrary{calc,scopes,decorations.markings,decorations.pathmorphing,positioning,shapes.arrows,arrows} \definecolor{mediumblue}{RGB}{0,0,140} \begin{document} \begin{tikzpicture}[>=latex,scale=1.5] \draw[<>] (2.3,0)  (2.4,0) node[below]{$x$}; \draw[<>] (0,2.3)  (0,2.4) node[left]{$y$}; \draw[red,thick] plot[smooth,tension=0.55,samples at={2,1.99,...,1.01,1.001,1.0005,1.00015}] ({0.5*ln((\x1)/(\x+1))2.549},{\x0.02}); \draw[blue,thick] plot[smooth,tension=0.55,samples at={0.975,0.960,...,0.965}] ({0.5*ln((1\x)/(\x+1))},{\x}); \foreach \x in {2,1,...,2} { \draw (\x,0.1)  (\x,0.1); } \foreach \y in {2,1,...,2} { \draw (0.1,\y)  (0.1,\y); } \foreach \x in {2,1.8,...,2} \foreach \y in {2,1.8,...,2} { \pgfmathparse{0.18/sqrt(1+(\y*\y1)^2)} \let\t\pgfmathresult \draw[arrow,mediumblue] (\x,\y)  +({\t*1},{\t*(\y*\y1)}); } \draw (0.1,1) node[left]{$1$}; \draw (0.1,2) node[left]{$2$}; \draw (1,0.1) node[below]{$1$}; \draw (2,0.1) node[below]{$2$}; \draw[blue,fill=blue] (0,0) circle (1pt); \draw[red,fill=red] (2,2) circle (1pt); \draw[blue] (0,0.2) node[right]{$(0,0)$}; \draw[red] (2,2) node[right]{$(2,2)$}; \end{tikzpicture} \end{document} To get little arrows styled to my liking, instead of line segments, I replaced [>=latex,scale=1.5] with: [>=latex,scale=1.5,decoration={markings, mark=at position 1.00 with {\arrow[line width=0.3pt,scale=0.4]{>};}}, arrow/.style={postaction={decorate},shorten >= 1pt,line width=0.3pt,line cap=round}]

Powered by Nabble  Edit this page 