7 Jan 2010 09:47

## Bounding the range in a tikzpicture plot?

Hello,

is there a way to use tikz for plotting several functions on the same
domain, and with a common user-defined range bound?

Sample problem:

\begin{tikzpicture}[scale=1.2]
\draw[domain=-1.5:3, range=-3:3, red]
plot[id=f, samples=50] function{x**3-2*x**2-x+2};
\draw[domain=-1.5:3, range=-3:3, green]
plot[id=df, samples=50] function{3*x**2-4*x-1};
\draw[domain=-1.5:3, range=-3:3, blue]
plot[id=ddf, samples=50] function{6*x-4};
\end{tikzpicture}

Unfortunately, the range bound [-3:3] is ignored when the plot is compiled.

To solve the problem, I tried modifying tikz.code.tex to pass the yrange
argument to gnuplot. This worked such that the gnuplot file for the

set terminal table; set output "myfile.f.table"; set format "%.5f"
set samples 50; set yrange [-3:3]; plot [x=-1.5:3] x**3-2*x**2-x+2

The first 6 lines of the table became

#Curve 0 of 1, 50 points
#x y type
-1.50000 -4.37500  o
-1.40816 -3.34996  o
-1.31633 -2.42992  i
-1.22449 -1.61023  i

The third column reflects the range bound correctly. However, this
column is ignored when the plot is displayed, whereas entering the
commands "set yrange [-3:3]" and "plot [x=-1.5:3] x**3-2*x**2-x+2"
interactively in gnuplot, the plot is displayed as desired.

There are two obvious workarounds for the problem, but both are not
practical:

- modify the domain of each function to fit the desired range
- delete all lines in the table files that contain an "o" in column 3

Any suggestions for a solution to the problem or for a procedure that is
practical for generating a large number (say 100) of plots are highly
welcome.

Markus

------------------------------------------------------------------------------
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev


Gmane