Zitat von
msthab
Um das (neue) Problem etwas deutlicher zu machen, habe ich die Grafik wie folgt geändert:
-Die Funktion y=x genommen
-Die Decoration rausgenommen
-Die Funktion einmal in der \datavisualization Umgebung (rot) und einmal mit \draw gezeichnet
-zwei Punkte mit Draw ergänzt (identische Koordinaten) dabei einmal die Option"visualization cs:" verwendet (rot)
Deutlich ist zu erkennen, dass die schwarzen Grafiken ein ganz anderes Koordinatensystem nutzen (nämlich auf cm-Basis) als die eigentliche \datavisualization Umgebung.
hier mein Versuch, die beiden Geraden über einander zu ziehen:
Code:
\documentclass[english]{article}
\usepackage{lmodern}
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}
\usepackage{url}
\usepackage{tikz}
\usetikzlibrary{datavisualization}
\usetikzlibrary{datavisualization.formats.functions}
\usetikzlibrary{plotmarks}
\usetikzlibrary{calc}
\usetikzlibrary{decorations}
\usetikzlibrary{decorations.text}
\usepackage{babel}
\newlength\mya
\newlength\myb
\newcommand*\myxa{}
\newcommand*\myxb{}
\makeatletter
\newlength\my@tmp
\newcommand*\ptocm[2]{%
\setlength\my@tmp{\dimexpr0.03514598#1\relax}% 0.03514598 cm/pt = (2.54 cm/in) / (72.27 pt/in)
\edef#2{\strip@pt\my@tmp}%
}
\makeatother
\begin{document}
\begin{tikzpicture}
\datavisualization [school book axes,visualize as smooth line/.list={a,b},
all axes={grid},
a={style ={red,very thick}},
x axis={length=11cm,
ticks={many},
label= $x$},
y axis={length=4cm,
ticks={many},
label= $y$},
data/format=function
]
data [set=a] {
var x : interval [1:5.1] step 0.1;
func y = (\value x);
}
info {
\coordinate (A) at (visualization cs: x=1, y=1);
\coordinate (B) at (visualization cs: x=5, y=1);
\pgfextractx{\mya}{\pgfpointanchor{A}{center}}% siehe auch http://tex.stackexchange.com/questions/14021/extract-the-x-y-part-from-a-coordinate-in-pgfplots
\pgfextractx{\myb}{\pgfpointanchor{B}{center}}
\ptocm{\mya}{\myxa}%
\ptocm{\myb}{\myxb}%
\draw[blue] (A) -- (B);
\draw[variable=\x, domain=\myxa:\myxb] plot ({\x},{0.3636*\x});% 0.3636 = y axis length / x axis length ( = 4 cm / 11 cm)
\draw [red] (visualization cs: x=5, y=1) circle [radius=3pt]
node [above,font=\footnotesize] {richtige Koordinaten mit cs};
\draw (5,1) circle [radius=3pt]
node [below,font=\footnotesize] {falsche Koordinaten ohne cs};
};
\end{tikzpicture}
\end{document}
Ob es Dir bei Deinem eigentlichen Problem hilft, kann ich nicht sagen (und bin inzwischen auch zu müde, in der Hinsicht heute noch was zu testen)
VG
Lesezeichen