3

MWE

\documentclass{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.12}
\usepgfplotslibrary{groupplots} 
\makeatletter
\def\Printdimensionless#1{\strip@pt \dimexpr #1\relax}
\makeatother
\begin{filecontents}{data_fem_0.dat}
id   delta      E_1        E_2        v_12       v_21       G_12     err         porosity  E_cs_1_norm  E_cs_2_norm
049  -0.48      2.6891     2.9098     0.33942    0.36728    1.1087   0.010752    0.914955  0.89481      0.968249
047  -0.46      0.014184   0.1251     -0.3269    -2.8832    0.71385  0.0011567   0.88558   0.00343525   0.0302982
\end{filecontents} % inserts '%' comment lines
\begin{document}
\begin{tikzpicture}
\begin{groupplot}[
  group style={
    group size=1 by 2,
    vertical sep=0.1in,
  },
  scale only axis,
  width=\columnwidth-0.5in,
  domain=-0.482362:0.035276,
  xmin=-0.495, xmax=0.0352762,
]
\nextgroupplot[
  height=0.8in,
  ymin=-0.9, ymax=4.9,
]
  \addplot
    gnuplot[id=poisson12, raw gnuplot]
      {set datafile commentschars '#%'; # <-- SEE HERE
        plot './data_fem_0.dat' u 'delta':'v_12'}
    ;
\nextgroupplot[
  height=0.8in,
  ytick={0,0.5,1},
  ymin=0, ymax=1,
]
  \addplot
    gnuplot[id=young1, raw gnuplot]
      {set datafile commentschars "#%";
        plot './data_fem_0.dat' u 'delta':'E_cs_1_norm'};
\end{groupplot}
\end{tikzpicture}
\end{document}

This returns following error:

! Illegal parameter number in definition of \pgfplots@gnuplotcode.
<to be read again> 
                   p
l.33     ;

? 

Looking into gnuplot file:

$ cat demo-expand-plot-width-expr.poisson12.gnuplot
set table "demo-expand-plot-width-expr.poisson12.table"; set format "%.5f"
set format "%.7e";;set datafile commentschars '##plot '< plotpointreduce -t 0.01 --width 308.865 --height 57.81621 --xrange -0.495 0.0352762 --yrange -0.9 4.9 --x-column delta --y-column v_12 data_fem_0.dat' u 'delta':'v_12'

shows that setting the commentschars was not correct. Apparently the % has to be escaped. \% is helpful but still errors are thrown.

$ cat demo-expand-plot-width-expr.poisson12.gnuplot
set table "demo-expand-plot-width-expr.poisson12.table"; set format "%.5f"
set format "%.7e";;set datafile commentschars '##\%'; plot './data_fem_0.dat' u 'delta':'v_12'
1

Not sure if the result is as intended, but this will produce no error:

\begin{tikzpicture}
\makeatletter
\let\%\@percentchar
\edef\#{\string#}
\makeatother
\begin{groupplot}[
  group style={
    group size=1 by 2,
    vertical sep=0.1in,
  },
  scale only axis,
  width=\columnwidth-0.5in,
  domain=-0.482362:0.035276,
  xmin=-0.495, xmax=0.0352762,
]
\nextgroupplot[
  height=0.8in,
  ymin=-0.9, ymax=4.9,
]
  \addplot
    gnuplot[id=poisson12, raw gnuplot]
      {set datafile commentschars '\#\%';
        plot './data_fem_0.dat' u 'delta':'v_12'}
    ;
\nextgroupplot[
  height=0.8in,
  ytick={0,0.5,1},
  ymin=0, ymax=1,
]
  \addplot
    gnuplot[id=young1, raw gnuplot]
      {set datafile commentschars "\#\%";
        plot './data_fem_0.dat' u 'delta':'E_cs_1_norm'};
\end{groupplot}
\end{tikzpicture}

enter image description here

| improve this answer | |
  • Thanks again for your answer. Yes, it does what I want. – Hotschke Aug 17 '15 at 7:24
0

Not a real answer but a possible way to circumvent the problem.

Adjust the datafile commentschars in a gnuplot config file.

  1. $HOME/.gnuplot (global)
  2. $PWD/.gnuplot (per-directory) (requires commpile time option +USE_CWDRC This can be verified by running $ gnuplot -e "show version long; show loadpath")
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.