The problem is not with pgfplots but with the data file. It seems that LyX cannot reference files that are mentioned in ERT using relative paths. It arises because LyX does not copy the required file over at the temporary build directory, since ERT code is injected verbatim to the produced TeX source. It would also like to know if there is a solution for this problem without resorting to absolute paths.
Spyros On Tue 08 Nov 2011 05:39:15 PM EET, Churilov Sergey wrote: > Hi, > > I am using pgfplots package to draw some diagrams from LyX. The following > syntax entered into TEX code works fine. > \begin{tikzpicture} > \begin{axis}[xlabel=Cost, ylabel=Error] > \addplot[color=red,mark=x] coordinates { > (2,-2.8559703) > (3,-3.5301677) > (4,-4.3050655) > (5,-5.1413136) > (6,-6.0322865) > (7,-6.9675052) > (8,-7.9377747) > }; > \end{axis} > \end{tikzpicture} > > > But, if I want to plot from a file, I get errors: > -! Package pgfplots Error: sorry, plot file{umwc1.dat} could not be opened. > -! Package pgfplots Warning: the current plot has no coordinates (or all have > be en filtered away) > -! Package pgfplots Warning: You have an axis with empty range. Replacing it > with a default range and clearing all plots. > > The code is: > \begin{tikzpicture} > \begin{axis}[xlabel=Cost, ylabel=Error] > \addplot file {data.dat}; > \end{axis} > \end{tikzpicture} > > data.dat file contains two columns with the numbers from previous example. > > What could be the problem here? > > Kind regards, > Sergey