PGF darstellung funktioniert nicht

Tabellen und Grafiken erstellen und anordnen


feuerfalke2005
Forum-Anfänger
Forum-Anfänger
Beiträge: 40
Registriert: Di 24. Mai 2016, 20:51
Wohnort: Schweiz

PGF darstellung funktioniert nicht

Beitrag von feuerfalke2005 »

Hallo liebe Forumsmitglieder

Ich bitte noch mals um eure Hilfe.
Ich habe eine PGFplots darstellung erstellt leider funktioniert sie micht so richtig.
DAher könnte mir jemand sagen wo ich da fehler gemacht habe, ich habe den Graphen nur in der Achsen aufteilung und in der daten datei angepasst aber leider ist der Wurm drin.
\begin{filecontents*}{DSF.dat}
0.00	0
0.05	10
0.24	15
0.24	20
0.39	25
0.40	50
0.79	75
0.80	100
0.89	125
0.99	150
1.01	175
1.03	200
0.98	175
0.96	150
0.65	125
0.63	100
1.22	125
1.23	150
1.90	175
2.00	300
\end{filecontents*}

\documentclass[11pt]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{pgfplots}
\pgfplotsset{compat=1.13}
\usepackage{tikz}	%Zur darstellung von Graphen und anderen darstellungen
\usetikzlibrary{positioning}
\usetikzlibrary{matrix}
\usetikzlibrary{decorations.pathreplacing}

\begin{document}


\begin{figure}
	\begin{tikzpicture}%[decoration=brase]
	\begin{axis}[
	width=14cm,
	height=10cm,
	scale only axis,
	xtick={0,25,...,325},
	xmin=0,
	xmax=325,
	xlabel={Normalspannung $\sigma$ in [$\frac{kN}{m^2}$]},
	ytick={0,...,2.0}
	ymin=0,
	ymax=2.5,
	ylabel={Scherspannung $\tau$ $\frac{kN}{m^2}$},
	axis x line*=bottom, %top,
	axis y line*=left,
	grid=major,
	every axis plot/.append style={
		line width=1.5pt,
		mark size=2pt,
		mark=ball,forget plot,
		visualization depends on={x \as \myvalue},
	},
	point meta=y,
	nodes near coords={
		\ifdim \myvalue pt=125pt \pgfmathprintnumber{\pgfplotspointmeta}\fi
		\ifdim \myvalue pt=250pt \pgfmathprintnumber{\pgfplotspointmeta}\fi
		\ifdim \myvalue pt=325pt \pgfmathprintnumber{\pgfplotspointmeta}\fi
	%	\ifdim \myvalue pt=0pt \pgfmathprintnumber{\pgfplotspointmeta}\fi
	},
	nodes near coords style={text=black}
	]
	\addplot [red] table[restrict expr to domain={\thisrowno{0}}{0:1.03}] {DSF.dat};
	\addplot [green] table[restrict expr to domain={\thisrowno{0}}{0.98:0.63}] {DSF.dat};
	\addplot [blue] table[restrict expr to domain={\thisrowno{0}}{1.22:2.0}] {DSF.dat};
%	\addplot [black] table[restrict expr to domain={\thisrowno{0}}{0:375}] {NS2.dat};
	% \addplot [orange] table[restrict expr to domain={\thisrowno{0}}{0:375}] {datenNS.dat};
	%\draw[decorate, yshift=-4ex] (0,2) -- node[below=0.4ex] {Text unterhalb} (0,0);
	\end{axis}
%	\draw[decorate, yshift=0ex] (0,1.65) -- node[blue,anchor=base west, xshift=2ex] {Scheinbare Koh\"asion 33,53 $\frac{kN}{m^2}$} (0,0);% Geschweifte Klammer mit schrift recht 
	\end{tikzpicture}
		\caption{Normal-Scherspannungs - Diagramm}
		\label{Normalspannung}
	\end{figure}
\end{document}
Ich danke euch für eure Hilfe
Ich gebe noch ein Bild Mit dabei wie es in etwa aussehen soll.
Nur das die Achsen nicht unbedingt Log teilung brauchen glaube ich

Bild
Dateianhänge
(6.01 KiB) 2723 mal betrachtet

esdd
Forum-Meister
Forum-Meister
Beiträge: 2561
Registriert: So 7. Feb 2010, 16:36

Beitrag von esdd »

Nach der ytick={0,...,2.0} fehlt ein Komma. Beim grünen Plotteil muss die untere vor der oberen Grenze stehen. Und vorallem passen Deine Angaben für xtick, ytick, xmax und ymax nicht zu Deinen Daten. Ich habe sie unten nur auskommentiert, Du kannst statt dessen für Dich geeignete Werte angeben.

Außerdem würde ich Dir dringend raten, die für einen Plot nicht benötigten Sachen dann auch wirklich rauszunehmen und nicht nur auszukommentieren. Es wird sonst irgendwann sehr unübersichtlich.
\begin{filecontents*}{DSF.dat} 
 0.00   0 
 0.05   10 
 0.24   15 
 0.24   20 
 0.39   25 
 0.40   50 
 0.79   75 
 0.80   100 
 0.89   125 
 0.99   150 
 1.01   175 
 1.03   200 
 0.98   175 
 0.96   150 
 0.65   125 
 0.63   100 
 1.22   125 
 1.23   150 
 1.90   175 
 2.00   300 
\end{filecontents*} 

\documentclass[11pt]{article} 
\usepackage[T1]{fontenc} 
\usepackage[utf8]{inputenc} 
\usepackage{pgfplots}% lädt auch tikz
\pgfplotsset{compat=newest} % newest nur für Online-Editior, sonst derzeit 1.13
%\usetikzlibrary{positioning} 
%\usetikzlibrary{matrix} 
%\usetikzlibrary{decorations.pathreplacing} 

\begin{document} 
\begin{figure} 
    \begin{tikzpicture}%[decoration=brase] 
    \begin{axis}[ 
    width=14cm, 
    height=10cm, 
    scale only axis, 
    %xtick={0,25,...,325}, 
    xmin=0, 
    %xmax=325,% <- 325 ist seeehr viel zu groß
    xlabel={Normalspannung $\sigma$ in [$\frac{kN}{m^2}$]}, 
    %ytick={0,...,2.0}, 
    ymin=0, 
    %ymax=2.5,% <- 2.5 ist seeehr viel zu klein
    ylabel={Scherspannung $\tau$ $\frac{kN}{m^2}$}, 
    axis x line*=bottom, %top, 
    axis y line*=left, 
    grid=major, 
    every axis plot/.append style={ 
       line width=1.5pt, 
       mark size=2pt, 
       mark=ball,
       forget plot, 
    }, 
    ] 
    \addplot [red] table[restrict expr to domain={\thisrowno{0}}{0:1.03}] {DSF.dat}; 
    \addplot [green] table[restrict expr to domain={\thisrowno{0}}{0.63:0.98}] {DSF.dat}; 
    \addplot [blue] table[restrict expr to domain={\thisrowno{0}}{1.22:2.0}] {DSF.dat}; 
    \end{axis} 
    \end{tikzpicture} 
       \caption{Normal-Scherspannungs - Diagramm} 
       \label{Normalspannung} 
    \end{figure} 
\end{document} 
Das Ergebnis müsste sich im Online-Editor ansehen lassen.
Zuletzt geändert von esdd am So 5. Jun 2016, 21:10, insgesamt 1-mal geändert.

feuerfalke2005
Forum-Anfänger
Forum-Anfänger
Beiträge: 40
Registriert: Di 24. Mai 2016, 20:51
Wohnort: Schweiz

Beitrag von feuerfalke2005 »

Danke für deine Schnelle antwort
aber irgend wie sind die Achsen vertauschet
xachse slote doch horizontal sein und
yAchse vertial.
So war das bis her zu mindestens immer.
Danke nochmals
ich werd mal im Forum schai ob ich da was finde mit Log teilung

esdd
Forum-Meister
Forum-Meister
Beiträge: 2561
Registriert: So 7. Feb 2010, 16:36

Beitrag von esdd »

In welcher Spalte stehen denn Deine x-Werte?

feuerfalke2005
Forum-Anfänger
Forum-Anfänger
Beiträge: 40
Registriert: Di 24. Mai 2016, 20:51
Wohnort: Schweiz

Beitrag von feuerfalke2005 »

In meiner datei ist
y achse x achse
\begin{filecontents*}{DSF.dat}
%Y     X
 0.00   0
 0.05   10
 0.24   15
 0.24   20
 0.39   25
 0.40   50
 0.79   75
 0.80   100
 0.89   125
 0.99   150
 1.01   175
 1.03   200
 0.98   175
 0.96   150
 0.65   125
 0.63   100
 1.22   125
 1.23   150
 1.90   175
 2.00   300
\end{filecontents*}

Durch deinen hinweis sehe ich schon das meine 
Dat datei wohl  falsch auf gebaut ist.
Danke für deine hilfe

feuerfalke2005
Forum-Anfänger
Forum-Anfänger
Beiträge: 40
Registriert: Di 24. Mai 2016, 20:51
Wohnort: Schweiz

Beitrag von feuerfalke2005 »

Habe die daten noch mals über arbeitet
aber irgend wie kommt der Graph der grün sein soll nicht zu stande.
Was mache ich da falsch.

\begin{filecontents*}{DSF1.dat}
%X      Y
0       0.00	
10      -0.05	
20	-0.24	
50	-0.40
100	-0.80	
150	-0.99	
200	-1.03	
\end{filecontents*}

\begin{filecontents*}{DSF2.dat}
%X      Y
150	-0.85   %0.96	
100	-0.63
\end{filecontents*}

\begin{filecontents*}{DSF3.dat}
%X      Y
150	-1.23	
300	-2.00	
\end{filecontents*}

\documentclass[11pt]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{pgfplots}% lädt auch tikz
\pgfplotsset{compat=newest} % newest nur für Online-Editior, sonst derzeit 1.13
%\usetikzlibrary{positioning}
%\usetikzlibrary{matrix}
%\usetikzlibrary{decorations.pathreplacing}

\begin{document}
\begin{figure}
    \begin{tikzpicture}%[decoration=brase]
    \begin{axis}[
    width=14cm,
    height=10cm,
    scale only axis,
    xtick={0,25,...,325},
    xmin=0,
    xmax=325,% <- 325 ist seeehr viel zu groß
    xlabel={Normalspannung $\sigma$ in [$\frac{kN}{m^2}$]},
    ytick={0,-0.1,...,-2.10},
    ymin=-2.5,
    ymax=0,%2.5,% <- 2.5 ist seeehr viel zu klein
    ylabel={Setzun s mm},
    axis x line*=top, %bottom, %top,
    axis y line*=left,
    grid=major,
    every axis plot/.append style={
       line width=1.5pt,
       mark size=2pt,
       mark=ball,
       forget plot,
    },
    ]
    \addplot [red] table[restrict expr to domain={\thisrowno{0}}{0:200}]    {DSF1.dat};
    \addplot [green] table[restrict expr to domain={\thisrowno{0}}{150:100}]{DSF2.dat};
    \addplot [blue] table[restrict expr to domain={\thisrowno{0}}{150:300}] {DSF3.dat};
    \end{axis}
    \end{tikzpicture}
       \caption{Normal-Scherspannungs - Diagramm}
       \label{Normalspannung}
    \end{figure}
\end{document} 
Bild
Dateianhänge
setungen Druck.jpg
setungen Druck.jpg (37.07 KiB) 2718 mal betrachtet

esdd
Forum-Meister
Forum-Meister
Beiträge: 2561
Registriert: So 7. Feb 2010, 16:36

Beitrag von esdd »

Man kann auch in der ersten Spalte die y-Werte haben und in der zweiten die x-Werte. Allerdings muss man das pgfplots mitteilen. Dafür gibt es solche Option, wie x=<spaltenname>, x index=<spaltenummer>, wobei die Zählung bei 0 beginnt.

Der grüne Plot wird nicht gezeichnet, weil die untere Grenze einen höheren Wert hat als die obere. Es gibt kein x für das gleichzeitig gilt x>150 und x<100. Tausche also die beiden Werte zu:
\addplot [green] table[restrict expr to domain={\thisrowno{0}}{100:150}]{DSF2.dat};

feuerfalke2005
Forum-Anfänger
Forum-Anfänger
Beiträge: 40
Registriert: Di 24. Mai 2016, 20:51
Wohnort: Schweiz

Beitrag von feuerfalke2005 »

Danke
das war sehr Hilfreich
Ich hätte noch eine kleine fragen kann man die verschiedenen Graphen von der Farbe her auch einen überischt Teil geben so das eine Linie
Rot = Erstbelastung
Grün = Entlastung
Blau = Wiederbelastung
(Imprinzip wie bei Excel da wir immer im Rechten teil der graphen dartellung mehre Linien mit darstellungs Knoten dargestellt und beschrieben)
Kann man das hier auch irgen wie einbauen?
Habe leider keinen schimme wie!

Danke

esdd
Forum-Meister
Forum-Meister
Beiträge: 2561
Registriert: So 7. Feb 2010, 16:36

Beitrag von esdd »

Du möchtest also noch eine Legende einfügen. Zu dem Thema gibt es in der Doku einen ganzen Abschnitt.

Zunächst musst Du das forget plot aus Deinem Code entfernen. Dann gibt es verschiedene Möglichkeiten die Legendeneinträge anzugeben. In jedem Fall muss die Reihenfolge der Legendentext mit der der zugehörigen Plots überein stimmen. Wo genau die Befehle in der Umgebung stehen, ist dagegen egal.

Eine Möglichkeit wäre:
\begin{filecontents*}{DSF1.dat} 
%X      Y 
 0       0.00   
 10      -0.05   
 20   -0.24   
 50   -0.40 
 100   -0.80   
 150   -0.99   
 200   -1.03   
\end{filecontents*} 

\begin{filecontents*}{DSF2.dat} 
%X      Y 
 150   -0.85   %0.96    
 100   -0.63 
\end{filecontents*} 

\begin{filecontents*}{DSF3.dat} 
%X      Y 
 150   -1.23   
 300   -2.00   
\end{filecontents*} 

\documentclass[11pt]{article} 
\usepackage[T1]{fontenc} 
\usepackage[utf8]{inputenc} 
\usepackage{pgfplots}% lädt auch tikz 
\pgfplotsset{compat=newest} % newest nur für Online-Editior, sonst derzeit 1.13 
%\usetikzlibrary{positioning} 
%\usetikzlibrary{matrix} 
%\usetikzlibrary{decorations.pathreplacing} 

\begin{document} 
\begin{figure} 
     \begin{tikzpicture}%[decoration=brase] 
     \begin{axis}[ 
     width=14cm, 
     height=10cm, 
     scale only axis, 
     xtick={0,25,...,325}, 
     xmin=0, 
     xmax=325,
     xlabel={Normalspannung $\sigma$ in [$\frac{kN}{m^2}$]}, 
     ytick={0,-0.1,...,-2.10}, 
     ymin=-2.5, 
     ymax=0,%2.5, 
     ylabel={Setzun s mm}, 
     axis x line*=top, %bottom, %top, 
     axis y line*=left, 
     grid=major, 
     every axis plot/.append style={ 
        line width=1.5pt, 
        mark size=2pt, 
        mark=ball, 
        %forget plot, % <- das muss weg, wenn Du eine Legende möchtest
     }, 
     ]
     \addplot [red] table[restrict expr to domain={\thisrowno{0}}{0:200}]    {DSF1.dat};
     \addlegendentry{Ersbelastung}
     \addplot [green] table[restrict expr to domain={\thisrowno{0}}{100:150}]{DSF2.dat};
     \addlegendentry{Entlastung}
     \addplot [blue] table[restrict expr to domain={\thisrowno{0}}{150:300}] {DSF3.dat};
     \addlegendentry{Wiederbelastung}
     \end{axis} 
     \end{tikzpicture} 
        \caption{Normal-Scherspannungs - Diagramm} 
        \label{Normalspannung} 
     \end{figure} 
\end{document} 
Alternativen findest Du wie gesagt in der Doku.

feuerfalke2005
Forum-Anfänger
Forum-Anfänger
Beiträge: 40
Registriert: Di 24. Mai 2016, 20:51
Wohnort: Schweiz

Beitrag von feuerfalke2005 »

Danke sehr das ist genau das was ich meinte

Das ist die Lösung
Werde mein Englisch mit hilfe der Doku aufbessern.

Antworten