3

I am able to scale the data using the y filter option in pgfplots plot object (like here How to scale existing coordinates data in pgfplots?). However the error bars are not rescaled as expected. Is there a workaround for this?

In this example, the "original" y-value is 1+/-0.5, after y filter/.code={\pgfmathparse{\pgfmathresult*10}\pgfmathresult} the data shows as 10+/-0.5 (instead of the expected 10+/-5.)

enter image description here

The complete code follows:

\documentclass{standalone}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}
\addplot+[
    only marks, 
    x filter/.code={\pgfmathparse{\pgfmathresult*1}\pgfmathresult}, 
    y filter/.code={\pgfmathparse{\pgfmathresult*10}\pgfmathresult}
] plot[error bars/.cd, y dir=both, y explicit] coordinates {
 ( 1, 1 ) +- ( 0, 0.5)
 ( 2, 1 ) +- ( 0, 0.5)
 ( 3, 1 ) +- ( 0, 0.5)
 ( 4, 1 ) +- ( 0, 0.5)
} ;
\end{axis}
\end{tikzpicture}
\end{document}

NOTE: x error filter/.code = ... is not valid code apparently.

alfC
  • 14,350
  • In your real application, do you provide the coordinates in this form (x,y) +- (xerror, yerror), or do you use a table? – Jake Jan 14 '14 at 20:56
  • 1
    @Jake, I use the () +- () notation so I don't have to invent a name for the columns and I think it is more self descriptive than a table with names that I have to be interpreted by some addplot option like x expr=\thisrow{X} (or something like that). Having said that, if I have to switch to table, so be it. – alfC Jan 14 '14 at 21:19
  • 2
    With \addplot table, altering the data on the fly is simple x error expr=\thisrow{xerror}*10. With the () +- () I don't know how to alter the error values. – Jake Jan 14 '14 at 21:25
  • 1
    @Jake, I think it would be nice to have for completeness x error filter and a y error filter. – alfC Jun 04 '14 at 18:46
  • 2
    Sounds as if pgfplots should add the error to the input coordinate and apply the filter to the result... that would solve the problem without the need of an additional set of filters (which would contain almost the very same transformation). Would be an incompatible change in behavior, though... – Christian Feuersänger Jun 08 '14 at 20:35
  • 1
    @ChristianFeuersänger, yes, unless you call the old behavior a bug :) OR add a new key x scale filter OR use the compat mechanism. (?) – alfC Jun 10 '14 at 00:59
  • @ChristianFeuersänger, maybe it has to do with this behavior http://tex.stackexchange.com/questions/184092/log-plot-and-x-filter-not-interacting-well-in-pgfplots ? – alfC Jun 10 '14 at 06:25

0 Answers0