Pgf Plot Missing $ inserted wenn xmax angepasst wird Thema ist als GELÖST markiert

Tabellen und Grafiken erstellen und anordnen


Verzweiflung

Pgf Plot Missing $ inserted wenn xmax angepasst wird

Beitrag von Verzweiflung »

Hallo,
ich verzweifle gerade an PGFPlots, ich möchte gerne vergleichbare Daten plotten (hier sind die y-values nur Zufallswerte) und dies in einem x range von 0-0.2. Leider kommt ein"Missing $ inserted" Fehler und das Diagramm wird nicht extern als PDF raus geschrieben, wenn ich xmax=0.2 setze. Setze ich es auf zum Beispiel 5, klappt es. Meine Daten gehen aber nur bis etwa 0.2. Trotz des Fehlers, schreibt das "nicht externe" Latex auch einen File raus, nur möchte ich das Diagramm gerne als einzelnes pdf haben, damit es nicht jedes Mal neu kompiliert wird, wenn ich etwas an meinem Dokument ändere.

Bei anderen Plots (anderer x-range) klappt es ohne Probleme mit gleichem Code.

Ich binde die Datei separat ein und nicht mit filecontets.
Meine erste Zeile des Inputs ist auch nur dummy, damit ich sicher sein kann, dass keine falschen Zeichen (Zeichen, die Latex anders interpretiert) drin sind, falls es das überhaupt gibt.

Hat jemand dafür eine Erklärung?
\begin{filecontents*}{Dummy.txt}
a	b	c	d	e	f	g	h	i	j	k	l	m	n
0	39	0	72	0	177	0	7	0	101	0	199	0	181
0.002186983	142	0.001966907	231	0.002	155	0.002	87	0.003	132	0.003	6	0.003	121
0.004015192	140	0.003966908	78	0.004	80	0.004	1	0.005	268	0.005	226	0.005	213
0.006015193	223	0.005966907	86	0.006	7	0.006	179	0.007	227	0.007	28	0.007	70
0.008015192	129	0.007966908	68	0.008	271	0.008	193	0.009	130	0.009	233	0.009	1
0.010015192	211	0.009966907	18	0.01	92	0.01	54	0.011	231	0.011	30	0.011	273
0.012015193	94	0.011966907	13	0.012	131	0.012	64	0.013	10	0.013	66	0.013	172
0.014015192	281	0.013966908	271	0.014	184	0.014	122	0.015	85	0.015	217	0.015	78
0.016015192	155	0.015966907	255	0.016000001	160	0.016000001	243	0.017000001	196	0.017000001	286	0.017000001	186
0.018015193	79	0.017966907	125	0.017999999	129	0.017999999	250	0.018999999	160	0.018999999	83	0.018999999	220
0.020015193	108	0.019966908	170	0.02	39	0.02	6	0.021	298	0.021	274	0.021	123
0.022015193	157	0.021966908	285	0.022	31	0.022	39	0.023	64	0.023	250	0.023	238
0.024015192	206	0.023966907	219	0.024	277	0.024	78	0.025	173	0.025	155	0.025	261
0.026015192	54	0.025966907	125	0.026000001	133	0.026000001	255	0.027000001	69	0.027000001	145	0.027000001	225
0.028015193	236	0.027966907	174	0.028000001	287	0.028000001	240	0.028999999	29	0.028999999	194	0.028999999	96
0.030015193	256	0.029966908	119	0.029999999	101	0.029999999	110	0.030999999	48	0.030999999	261	0.030999999	194
0.032015193	219	0.031966906	82	0.032000002	238	0.032000002	296	0.033	216	0.033	70	0.033	4
0.034015194	169	0.033966906	121	0.034000002	118	0.034000002	109	0.035	280	0.035	141	0.035	275
0.036015194	118	0.035966907	292	0.035999998	272	0.035999998	294	0.037	236	0.037	226	0.037	279
0.038015194	58	0.037966907	263	0.037999999	128	0.037999999	246	0.039000001	259	0.039000001	193	0.039000001	283
0.040015191	271	0.039966907	49	0.039999999	125	0.039999999	281	0.041000001	103	0.041000001	86	0.041000001	219
0.042015191	99	0.041966908	140	0.041999999	284	0.041999999	117	0.043000001	26	0.043000001	182	0.043000001	243
0.044015191	273	0.043966908	267	0.044	267	0.044	1	0.045000002	224	0.045000002	142	0.045000002	1
0.046015192	243	0.045966908	132	0.046	66	0.046	69	0.046999998	55	0.046999998	222	0.046999998	134
0.048015192	106	0.047966909	27	0.048	34	0.048	5	0.048999999	99	0.048999999	16	0.048999999	4
0.050015192	285	0.049966909	255	0.050000001	271	0.050000001	187	0.050999999	126	0.050999999	127	0.050999999	195
0.052015193	98	0.051966906	157	0.052000001	213	0.052000001	114	0.052999999	167	0.052999999	160	0.052999999	8
0.054015193	12	0.053966906	201	0.054000001	256	0.054000001	69	0.055	270	0.055	110	0.055	160
0.056015193	259	0.055966906	15	0.056000002	103	0.056000002	293	0.057	149	0.057	263	0.057	196
0.058015194	67	0.057966907	3	0.057999998	63	0.057999998	29	0.059	160	0.059	10	0.059	272
0.060015194	207	0.059966907	1	0.059999999	74	0.059999999	117	0.061000001	284	0.061000001	289	0.061000001	105
0.062015191	223	0.061966907	53	0.061999999	300	0.061999999	295	0.063000001	261	0.063000001	264	0.063000001	78
0.064015195	278	0.063966908	40	0.064000003	275	0.064000003	122	0.064999998	199	0.064999998	198	0.064999998	52
0.066015191	228	0.065966904	52	0.066	96	0.066	53	0.067000002	106	0.067000002	28	0.067000002	205
0.068015195	22	0.067966908	65	0.068000004	44	0.068000004	101	0.068999998	109	0.068999998	102	0.068999998	144
0.070015192	12	0.069966905	155	0.07	273	0.07	177	0.071000002	268	0.071000002	245	0.071000002	170
0.072015196	180	0.071966909	43	0.071999997	17	0.071999997	65	0.072999999	62	0.072999999	119	0.072999999	126
0.074015193	106	0.073966905	109	0.074000001	118	0.074000001	219	0.075000003	85	0.075000003	165	0.075000003	271
0.076015189	3	0.07596691	69	0.075999998	266	0.075999998	172	0.077	295	0.077	285	0.077	236
0.078015193	146	0.077966906	81	0.078000002	257	0.078000002	27	0.079000004	81	0.079000004	17	0.079000004	241
0.08001519	72	0.07996691	252	0.079999998	298	0.079999998	279	0.081	234	0.081	265	0.081	204
0.082015194	40	0.081966907	139	0.082000002	112	0.082000002	13	0.082999997	158	0.082999997	45	0.082999997	185
0.084015191	167	0.083966911	133	0.083999999	63	0.083999999	259	0.085000001	83	0.085000001	287	0.085000001	186
0.086015195	250	0.085966907	103	0.086000003	178	0.086000003	9	0.086999997	74	0.086999997	293	0.086999997	52
0.088015191	125	0.087966904	170	0.088	111	0.088	187	0.089000002	261	0.089000002	36	0.089000002	236
0.090015195	201	0.089966908	178	0.090000004	184	0.090000004	184	0.090999998	17	0.090999998	11	0.090999998	48
0.092015192	104	0.091966905	189	0.092	203	0.092	223	0.093000002	246	0.093000002	84	0.093000002	124
0.094015196	212	0.093966909	142	0.093999997	214	0.093999997	262	0.094999999	19	0.094999999	286	0.094999999	8
0.096015193	297	0.095966905	4	0.096000001	296	0.096000001	32	0.097000003	193	0.097000003	161	0.097000003	101
0.098015189	98	0.097966909	293	0.097999997	220	0.097999997	109	0.098999999	229	0.098999999	170	0.098999999	111
0.10001519	255	0.099966906	187	0.1	197	0.1	38	0.101	10	0.101	34	0.101	203
0.10201519	223	0.10196691	254	0.102	9	0.102	100	0.103	280	0.103	263	0.103	128
0.10401519	127	0.10396691	282	0.104	186	0.104	163	0.105	16	0.105	45	0.105	177
0.10601519	280	0.10596691	258	0.106	276	0.106	114	0.107	249	0.107	248	0.107	203
0.10801519	283	0.10796691	49	0.108	289	0.108	259	0.109	123	0.109	137	0.109	290
0.11001519	47	0.1099669	227	0.11	106	0.11	175	0.111	184	0.111	34	0.111	172
0.1120152	215	0.11196691	144	0.112	27	0.112	49	0.113	216	0.113	61	0.113	206
0.11401519	150	0.1139669	12	0.114	281	0.114	91	0.115	290	0.115	127	0.115	42
0.1160152	185	0.11596691	192	0.116	206	0.116	268	0.117	144	0.117	21	0.117	225
0.11801519	147	0.11796691	183	0.118	200	0.118	67	0.119	248	0.119	91	0.119	170
0.12001519	87	0.11996691	85	0.12	68	0.12	156	0.121	167	0.121	65	0.121	173
0.12201519	120	0.12196691	56	0.122	298	0.122	178	0.123	19	0.123	276	0.123	231
0.12401519	65	0.12396691	245	0.124	35	0.124	241	0.125	108	0.125	9	0.125	290
0.12601519	246	0.12596691	241	0.126	35	0.126	286	0.127	240	0.127	50	0.127	47
0.12801519	15	0.12796691	152	0.12800001	292	0.12800001	189	0.12899999	38	0.12899999	6	0.12899999	232
0.13001519	120	0.12996691	127	0.13	34	0.13	258	0.131	5	0.131	69	0.131	203
0.1320152	239	0.1319669	79	0.132	49	0.132	161	0.133	187	0.133	25	0.133	182
0.13401519	163	0.13396691	261	0.134	159	0.134	66	0.13500001	16	0.13500001	69	0.13500001	154
0.13601519	251	0.13596691	244	0.13600001	119	0.13600001	102	0.13699999	50	0.13699999	87	0.13699999	31
0.1380152	125	0.1379669	285	0.138	6	0.138	266	0.139	95	0.139	153	0.139	10
0.1400152	274	0.13996691	128	0.14	21	0.14	215	0.141	167	0.141	223	0.141	291
0.14201519	19	0.14196691	259	0.142	5	0.142	182	0.14300001	115	0.14300001	207	0.14300001	77
0.14401519	127	0.14396691	186	0.14399999	193	0.14399999	66	0.145	2	0.145	223	0.145	272
0.1460152	56	0.1459669	279	0.146	212	0.146	175	0.147	138	0.147	27	0.147	199
0.14801519	229	0.14796691	84	0.148	46	0.148	23	0.149	89	0.149	288	0.149	285
0.15001519	268	0.14996691	229	0.15000001	179	0.15000001	184	0.15099999	5	0.15099999	268	0.15099999	269
0.15201519	68	0.15196691	30	0.152	233	0.152	211	0.153	258	0.153	90	0.153	100
0.1540152	68	0.1539669	39	0.154	29	0.154	96	0.155	87	0.155	140	0.155	234
0.15601519	10	0.15596691	262	0.156	285	0.156	104	0.15700001	78	0.15700001	63	0.15700001	58
0.15801519	269	0.15796691	179	0.15800001	133	0.15800001	52	0.15899999	224	0.15899999	2	0.15899999	233
0.1600152	48	0.1599669	148	0.16	260	0.16	28	0.161	272	0.161	223	0.161	188
0.1620152	216	0.1619669	275	0.162	87	0.162	264	0.163	212	0.163	29	0.163	80
0.16401519	217	0.16396691	136	0.164	285	0.164	114	0.16500001	36	0.16500001	117	0.16500001	73
0.16601519	41	0.16596691	15	0.16599999	221	0.16599999	268	0.167	80	0.167	244	0.167	119
0.1680152	112	0.1679669	136	0.168	42	0.168	254	0.169	98	0.169	99	0.169	263
0.17001519	59	0.16996691	6	0.17	204	0.17	180	0.171	109	0.171	188	0.171	125
0.17201519	62	0.17196691	79	0.17200001	35	0.17200001	81	0.17299999	123	0.17299999	180	0.17299999	259
0.17401519	164	0.17396691	184	0.17399999	263	0.17399999	126	0.175	136	0.175	100	0.175	236
0.1760152	69	0.1759669	170	0.176	141	0.176	249	0.177	22	0.177	135	0.177	173
0.17801519	289	0.17796691	137	0.178	201	0.178	36	0.17900001	77	0.17900001	183	0.17900001	120
0.18001519	31	0.17996691	108	0.18000001	117	0.18000001	250	0.18099999	92	0.18099999	18	0.18099999	136
0.1820152	152	0.1819669	108	0.182	284	0.182	37	0.183	156	0.183	241	0.183	113
0.1840152	270	0.1839669	217	0.184	133	0.184	79	0.185	216	0.185	137	0.185	174
0.18601519	100	0.18596691	133	0.186	23	0.186	125	0.18700001	53	0.18700001	91	0.18700001	113
0.18801519	254	0.18796691	143	0.18799999	121	0.18799999	149	0.189	268	0.189	147	0.189	242
0.1900152	110	0.1899669	129	0.19	30	0.19	103	0.191	180	0.191	288	0.191	195
0.19201519	145	0.19196691	34	0.192	202	0.192	41	0.193	249	0.193	261	0.193	288
0.19401519	51	0.19396691	86	0.19400001	171	0.19400001	67	0.19499999	122	0.19499999	242	0.19499999	37
0.19601519	290	0.19596691	238	0.19599999	43	0.19599999	215	0.197	171	0.197	27	0.197	72
0.19901519	59	0.1979669	17	0.198	224	0.198	69	0.199	11	0.199	98	0.199	282
0.19921421	285	0.19916588	60	0.19919901	172	0.19919901	251	0.19919901	300	0.19919901	12	0.19919901	157
\end{filecontents*}

%Im Latex Dokument
\tikzsetnextfilename{external_plot}
\begin{tikzpicture}
\begin{axis} [width=0.48\textwidth,
xmin=0,
xmax=0.2, %auf 5 funktioniert es, bei 0.2 nicht :(
ymin=0,
ymax=300,
ylabel={y-value},%Name der y-Achse
xlabel={Time [s] } ,%Name der x-Achse
legend pos=north west,
]
\addplot[mark=none,black ]table[x index=0,y index=1,col sep=tab]%
{Dummy.txt};
\addlegendentry{10.00}
\addplot[mark=none, blue ]table[x index=2,y index=3,col sep=tab]%
{Dummy.txt};
\addlegendentry{8.00}
\addplot[mark=none, green ]table[x index=4,y index=5,col sep=tab]%
{Dummy.txt};
\addlegendentry{6.00}
\addplot[mark=none, violet ]table[x index=6,y index=7,col sep=tab]%
{Dummy.txt};
\addlegendentry{4.00}
\addplot+[mark=none, yellow ]table[x index=8,y index=9,col sep=tab]%
{Dummy.txt};
\addlegendentry{3.33}
\addplot[mark=none, orange]table[x index=10,y index=11,col sep=tab]%
{Dummy.txt};
\addlegendentry{2.00}
\addplot[mark=none, red]table[x index=12,y index=13,col sep=tab]%
{Dummy.txt};
\addlegendentry{1.00}
\end{axis}
\end{tikzpicture}

Gast

Beitrag von Gast »

Der Gast-Name scheint noch nicht hinreichend Programm zu sein.

Wobei sich auch die Frage stellt, ob das Problem nicht auch mit einer kleineren Dummy.txt oder weniger \addplot-Anweisungen reproduzierbar wäre. Aber das sehe ich eher als zweitrangig an.

Verzweiflung

Beitrag von Verzweiflung »

Danke Gast, du hast Recht, ich habe gerade ein Minimalbeispiel erstellt, es kompiliert und es hat wunderbar geklappt. Binde ich nun diese Datei in meine Hauptdatei ein, kommt wieder der gleiche Fehler "Missing $ inserted". Werde ich wohl selbst noch was suchen müssen :roll:

Verzweifelt

Beitrag von Verzweifelt »

Ich habe den Fehler nun ausfindig gemacht , es liegt wohl an den Zeilen, die die Schriftart der Achsen-Nummerierung ändern, gibt es eine Möglichkeit, diesen Fehler zu umgehen - ich verwende xelatex und möchte, dass eben auch die Achsen-Nummerierung ihre Schrift ändern.
\documentclass{standalone}
\usepackage{polyglossia}
\setdefaultlanguage[variant=american]{english} 
\setotherlanguage[spelling=new]{german}
\usepackage{unicode-math}
\usepackage{fontspec}

\setmainfont[Mapping=tex-text]{Linux Libertine} %mainfont 
\setsansfont[Mapping=tex-text]{Linux Biolinum} %serifenlose Font
\usepackage{xunicode}
\usepackage{xltxtra} 
\usepackage{pgfplots}
\pgfplotsset{
	xticklabel={\pgfmathprintnumber[assume math mode]{\tick}}, %Schriftart der Achsen nummerierung ändern
	yticklabel={\pgfmathprintnumber[assume math mode]{\tick}},%Schriftart der Achsen nummerierung ändern
}

\begin{document}
%\tikzsetnextfilename{external_plot} 
\begin{tikzpicture} 
\begin{axis} [width=0.48\textwidth, 
xmin=0, 
xmax=0.2, %auf 5 funktioniert es, bei 0.2 nicht Sad 
ymin=0, 
ymax=300, 
ylabel={y-value},%Name der y-Achse 
xlabel={Time [s] } ,%Name der x-Achse 
legend pos=north west, 
] 
\addplot[mark=none,black ]table[x index=0,y index=1,col sep=tab]% 
{Dummy.txt}; 
\addlegendentry{10.00} 
\end{axis} 
\end{tikzpicture} 

\end{document}

Verzweifelt

Beitrag von Verzweifelt »

Ich habe es nun gelöst :)

Es lag daran, dass das default Format der Nummerierung versucht hat 0.05 in wissenschaftlicher Schreibweise auszudrücken, wofür es wohl den math mode braucht.

Wenn ich hingegen das Format der x-Achse ändere, klappt es.

siehe: https://tex.stackexchange.com/questions ... at-on-axis

Die Modifikation als Code Schnipsel:
\begin{axis} [width=0.48\textwidth, 
x tick label style={
	/pgf/number format/.cd,
	fixed,
	%fixed zerofill,
	precision=2,
	/tikz/.cd
},
xmin=0,
xmax=0.2,
ymin=0,
ymax=300,
ylabel={y-value},%Name der y-Achse
xlabel={Time [s] } ,%Name der x-Achse
legend pos=north west,
]

Antworten