0

MWE:

\documentclass{standalone}
\usepackage{pgfplots}
\usepgfplotslibrary{groupplots} 
\begin{document}
\begin{tikzpicture}
\begin{groupplot}[
  group style={
    group size=1 by 4,
    vertical sep=0.1in,
  },
  scale only axis,
  width=\columnwidth-0.5in-0.09in,
  domain=-0.482362:0.035276,
  xmin=-0.495, xmax=0.0352762,
]
\nextgroupplot[
  height=0.8in,
  ymin=-0.9, ymax=4.9,
]
  \addplot
    gnuplot[id=plot1, raw gnuplot]
      {plot '< plotpointreduce -t 0.0175 --max-dist 0.1
         --width 2.897 --height 0.8
         --xrange \pgfkeysvalueof{/pgfplots/xmin} \pgfkeysvalueof{/pgfplots/xmax}
         --yrange \pgfkeysvalueof{/pgfplots/ymin} \pgfkeysvalueof{/pgfplots/ymax}
         --x-column delta --y-column v_12 data_fem_0.dat' u 'delta':'v_12'}
    ;
\end{groupplot}
\end{tikzpicture}
\end{document}

How can I pass the specified values of the axis width(\columnwidth-0.5in-0.09in) and height (0.8in) in the groupplot and \nextgroupplot options to my raw gnuplot string similar to --xrange and --yrange?

The script plotpointreduce expects unitless floats for --width and --height, the ratio is only considered.

Update:

I have changed the call to:

  \addplot
    gnuplot[id=plot1, raw gnuplot]
      {plot '< plotpointreduce -t 0.0175 --max-dist 0.1
         --width  \pgfkeysvalueof{/pgfplots/width}
         --height \pgfkeysvalueof{/pgfplots/height}
         --xrange \pgfkeysvalueof{/pgfplots/xmin} \pgfkeysvalueof{/pgfplots/xmax}
         --yrange \pgfkeysvalueof{/pgfplots/ymin} \pgfkeysvalueof{/pgfplots/ymax}
         --x-column delta --y-column v_12 data_fem_0.dat' u 'delta':'v_12'}
    ;

However, \pgfkeysvalueof{/pgfplots/width} returns \columnwidth -0.5in-0.09in.
How can I convert this to the actual value in inch?

I have placed the lengthy 'home-baked' script plotpointreduce on https://gist.github.com/Hotschke/afdcd9efabe385c641a6.

Update II

     --width  \the\pgfkeysvalueof{/pgfplots/width}

\the will expand columnwidth.

My script still complains plotpointreduce: error: argument -w/--width: invalid float value: '345.0pt-0.5in-0.09in'

So I guess my question is simply about expanding this expression. What is the shortest way to do it?

  • So what unit are the --width and --height arguments in? – jens_bo Aug 11 '15 at 8:23
  • The plot ratio is actually only important, not the units. You can pass them in all units you like. – Hotschke Aug 11 '15 at 8:29
  • I can't really get your MWE to run, but it seems like the only problem is, that you can not use \pgfkeysvalueof{/pgfplots/width} because it adds a pt to the end. Right? – jens_bo Aug 12 '15 at 12:18
  • Can you provide the script file? – sergej Aug 12 '15 at 19:34
  • I will extend my script to accept units, so that shouldn't be the problem. – Hotschke Aug 13 '15 at 8:44
0

After further internet search I could figure it out. I don't know if it's the most reliable way of doing it:

\documentclass{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.12}
\usepgfplotslibrary{groupplots} 
\makeatletter
\def\Printdimensionless#1{\strip@pt \dimexpr (#1)\relax}
\makeatother
% For convenience
\newcommand{\pwidth}{\Printdimensionless{\pgfkeysvalueof{/pgfplots/width}} } % trailing space important
\newcommand{\pheight}{\Printdimensionless{\pgfkeysvalueof{/pgfplots/height}} }
\newcommand{\pxrange}{\pgfkeysvalueof{/pgfplots/xmin} \pgfkeysvalueof{/pgfplots/xmax} }
\newcommand{\pyrange}{\pgfkeysvalueof{/pgfplots/ymin} \pgfkeysvalueof{/pgfplots/ymax} }
\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 '#\%';
          \addplot
gnuplot[id=young1, raw gnuplot]
  {plot '< plotpointreduce -t 0.0
    --width  \pwidth --height \pheight
    --xrange \pxrange --yrange \pyrange
     -x delta -y E_cs_1_norm ./data_fem_0.dat' u 'delta':'v_12'}; '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 '< plotpointreduce -t 0.0
         --width  \pwidth --height \pheight
         --xrange \pxrange --yrange \pyrange
         -x delta -y E_cs_1_norm ./data_fem_0.dat' u 'delta':'E_cs_1_norm'};
\end{groupplot}
\end{tikzpicture}
\end{document}

Helpful answers:

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.