
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}
¿Cómo puedo pasar los valores especificados del ancho del eje (\columnwidth-0.5in-0.09in) y la altura (0.8in) en las opciones groupplot
y \nextgroupplot
a mi cadena gnuplot sin procesar similar a --xrange
y--yrange
?
El script plotpointreduce
espera flotadores sin unidades para --width
y --height
, solo se considera la proporción.
Actualizar:
He cambiado la llamada a:
\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'}
;
Sin embargo, \pgfkeysvalueof{/pgfplots/width}
regresa \columnwidth -0.5in-0.09in
.
¿Cómo puedo convertir esto al valor real eninch
?
He colocado el extenso guión 'casero'plotpointreduce
enhttps://gist.github.com/Hotschke/afdcd9efabe385c641a6.
Actualización II
--width \the\pgfkeysvalueof{/pgfplots/width}
\the
expandirá el ancho de la columna.
Mi guión todavía se quejaplotpointreduce: error: argument -w/--width: invalid float value: '345.0pt-0.5in-0.09in'
Así que supongo que mi pregunta es simplemente sobre ampliar esta expresión. ¿Cuál es la forma más corta de hacerlo?
Respuesta1
Después de más búsquedas en Internet pude resolverlo. No sé si es la forma más confiable de hacerlo:
\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}
Respuestas útiles: