|
From: Mikhail K. <mko...@gm...> - 2013-01-16 10:50:40
|
Hi Thor
why not using 1/0 specification instead of '?':
echo "set table; plot 'data' u 1:((strcol(3) eq 'B')? \$2 : 1/0)" | gnuplot
# Curve 0 of 1, 5 points
# Curve title: "'data' u 1:((strcol(3) eq 'B')? $2 : 1/0)"
# x y type
0 0 u
0 0 u
1 1 i
2 4 i
0 0 u
Mikhail
On 16/01/2013 10:53, Thor Andreassen wrote:
> Hi,
>
> I was under the impression that it is possible to plot only parts of a data
> file with the ternary operator (?:), strcol() and missing ('?'), but I get
> strange results.
>
> My data file contains:
>
> 8<------8<------8<------8<------
> cat<< EOF> data
> 1 2 A
> 2 3 A
> 1 1 B
> 2 4 B
> 3 2 A
> 4 3 A
> EOF
> 8<------8<------8<------8<------
>
> Now if try to plot the lines with 'B' in the third column:
>
> echo "set table; plot 'data' u 1:((strcol(3) eq 'B')? \$2 : '?')" | gnuplot
>
> The result is:
>
> 8<------8<------8<------8<------
> # Curve 0 of 1, 6 points
> # Curve title: "'data' u 1:((strcol(3) eq 'B')? $2 : '?')"
> # x y type
> 1 1.89869e-267 i
> 2 1.89869e-267 i
> 1 1 i
> 2 4 i
> 3 4 i
> 4 4 i
> 8<------8<------8<------8<------
>
> Which is not what I expected. Am I doing it wrong or is this a bug?
>
> The above was tested with a recent cvs version of Gnuplot.
>
> gnuplot> show version long
>
> G N U P L O T
> Version 4.7 patchlevel 0 last modified 2013-01-08
> Build System: Linux i686
>
> Copyright (C) 1986-1993, 1998, 2004, 2007-2012
> Thomas Williams, Colin Kelley and many others
>
> gnuplot home: http://www.gnuplot.info
> mailing list: gnu...@li...
> faq, bugs, etc: type "help FAQ"
> immediate help: type "help" (plot window: hit 'h')
> Compile options:
> -READLINE +LIBREADLINE +HISTORY
> -BACKWARDS_COMPATIBILITY +BINARY_DATA
> +GD_PNG +GD_JPEG +GD_TTF +GD_GIF +ANIMATION
> -USE_CWDRC +X11 +X11_POLYGON +MULTIBYTE +X11_EXTERNAL +USE_MOUSE +HIDDEN3D_QUADTREE
> +DATASTRINGS +HISTOGRAMS +OBJECTS +STRINGVARS +MACROS +IMAGE +USER_LINETYPES +STATS
>
> GNUPLOT_DRIVER_DIR = "/opt/stow/gnuplot/libexec/gnuplot/4.7"
> GNUPLOT_PS_DIR = "/opt/stow/gnuplot/share/gnuplot/4.7/PostScript"
> HELPFILE = "/opt/stow/gnuplot/share/gnuplot/4.7/gnuplot.gih"
>
--
Mikhail Kononets
Ph.D. Student
Marine Chemistry
Department of Chemistry and Molecular Biology
University of Gothenburg
Kemivagen 10
SE-412 96
Gothenburg, Sweden
office num.: +46-31-786-9063
mobile num.: +46-70-216-0936
e-mail: m.k...@ch...
mko...@gm...
|