normally i'm using plain tikz for curve plotting. I need "school book style" coordinate systems with a 50mm grid.
I tried using the tikz data visualization library.
\documentclass{article}
\usepackage{tikz,pgfplots}
\usetikzlibrary{datavisualization}
\usetikzlibrary{datavisualization.formats.functions}
\pagestyle{empty}
\begin{document}
\begin{tikzpicture}[]
\datavisualization [
school book axes={unit=0.5},
visualize as smooth line,
x axis={label={$x$},grid,grid={minor steps between steps=1}},
y axis={label={$y$},grid,grid={minor steps between steps=1}},
every major grid/.style = {style={gray, thin}},
every minor grid/.style = {style={gray, very thin}}
]
data [format=function] {
var x : interval [-2:2];
func y = 1/2*(\value x)^2;
}
info' {
\fill[fill=lightgray] (visualization cs: x=1, y=0) -- plot [domain=1:2] (visualization cs: x=\x,y={0.5*(\x)^2}) -- (visualization cs: x=2, y=0) --cycle;
}
;
\end{tikzpicture}
\end{document}
The only thing i did not get right, is coloring the area under a curve. I tried the following in the info' block:
\fill[fill=lightgray] (visualization cs: x=1, y=0) -- plot [domain=1:2] (visualization cs: x=\x,y={0.5*(\x)^2}) -- (visualization cs: x=2, y=0) --cycle;
But this results in a PGF Math Error. Package PGF Math Error: Could not parse input '0.5*(1)^2'
I guess i need a way to tell the plot command to use the visualization cs.
Thanks in advance.
Cheers