1

I am aware of similar questions, but as they don't exactly use the same syntax as I am trying to do, I can't see what's different between my way of writing functions down and the others. Here's what I'm trying to do:

\documentclass[13pt,a4paper,headlines=6,headinclude=true]{scrartcl}

\usepackage{amsmath,amssymb,stmaryrd}       
\usepackage{tikz,pgfplots}
\usetikzlibrary{datavisualization.formats.functions}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{tikzpicture}[yscale=.5, xscale=.5, scale=3.5]
\datavisualization
[school book axes,
legend={below,rows=1},
visualize as smooth line/.list={f1,f2},
f1={style=blue, style=very thick,label in legend={text=$\frac{1}{x-1}$}},
f2={style=green, style=very thick,label in legend={text=$\frac{1}{x^2 - 7x - 30}$}}
]
data [set=f1, format=function] {
var x : interval[0.5:4];
func y = 1/(\value{x}-1);
}data [set=f2, format=function] {
var x : interval[0.5:4];
func y = \frac{1}{x^2 - 7x - 30};
};
\end{tikzpicture}   

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\end{document}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

What do I have to change? Thank you

func y = 1/(\value x - 1)

This results in:

enter image description here

  • \frac can't be used and you need \value before x. – user11232 Apr 27 '15 at 9:23
  • I tried many different ways. 1/(\value{x}-1) does not work neither. – Mac Apr 27 '15 at 9:28
  • Try func y = 1/(\value x - 1) – user11232 Apr 27 '15 at 9:31
  • BTW why not pgfplots? – user11232 Apr 27 '15 at 9:31
  • @Harish, this results in a crazy behaviour of the function. I upload image... (green function now log, I'm sorry, changing examples some times). / pgfplots I' not familiar with the different possible ways of plotting functions with tikz and stuff. What would be any easier implementation anyway? – Mac Apr 27 '15 at 9:32

Your Answer

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

Browse other questions tagged or ask your own question.