I want to be able to generate a list of points from a plot in Tikz, with an adjustable interval and range for the x-values. So basically something like this:

+            +
+     ^      +
+    / \     +
+   /   \    +
+  /     \   +

 X | Y 
-3 | 1 
-2 | 2 
-1 | 3 
0  | 4 
1  | 3 
2  | 2 
2  | 1 

Here is a minimal working example:


  dim above/.style={to path={\pgfextra{
        \draw[>=latex,|<->|,black!50] let
        in(\p1) -- (\p2) node[fill=black!5,pos=.5,sloped,above,font=\sffamily]{#1};
  dim below/.style={to path={\pgfextra{
        \draw[>=latex,|<->|,black!50] let 
        in (\p1) -- (\p2) node[pos=.5,sloped,below,font=\sffamily]{#1};

\begin{axis}[axis x line= middle, axis y line= middle, width=\textwidth, samples=50,grid=both, domain=-10:10, xmin=-#1, xmax=#1, ymin=-#1, ymax=#1, ultra thick, scale only axis, enlargelimits=false, anchor=origin, disabledatascaling]

\newcommand{\func}[2][abmblue]{\addplot[color=#1] {#2};}

\newcommand{\parfunc}[3][abmblue]{\addplot[color=#1,domain=-200:200] ({#2},{#3});}
\begin{plots}{Parametric Function of a Hyperbola}

An additional note: I have figured out how to do a table using \foreach:

\pgfkeys{/pgf/number format/.cd,fixed,fixed zerofill,precision=3} 
\foreach \i in {0,\the\numexpr2\relax,...,20}{
\edef\temp{\i & \pgfmathresult\noexpand\\} 


However, I have no clue how I would insert a parametric function into the \pgfmathparse{} command.

  • So you have the function and you want to evaluate it at certain points and print that as a table? – Jake Mar 7 '13 at 17:40
  • Maybe you could post your TikZ code!? Your question is not easy to understand. – hpekristiansen Mar 7 '13 at 17:45
  • Welcome to TeX.SE. This is doable, depending on how you are doing the plot, so it would be best if you composed a fully compilable MWE including \documentclass and the appropriate packages that sets up the problem. – Peter Grill Mar 7 '13 at 17:49
  • @Jake exactly. I can post a mwe real quick. – Adam Blum Mar 7 '13 at 17:55
  • I feel that you are looking for something like function graph cut from pgfplotstable but I don't know if your X values are given or computed. I mean are they the x values or the arguments of 2+4/cos(x)=-3 etc.? – percusse Mar 7 '13 at 19:54

It turns out that the following is an answer to the question.

I've created a table from scratch to populate the function entries via having an array of values in column X and evaluation of the array via Y1 and Y2 columns with the functions given in the question.

create on use/X/.style={create col/set list={-3,...,3}}, 
create on use/Y1/.style={create col/expr={2+4/cos(\thisrow{X} r)}}, 
create on use/Y2/.style={create col/expr={-3+3*tan(\thisrow{X} r)}}, 
columns={X,Y1,Y2}, ]{7}{\mytable} 


enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.