Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.graphics.apps.gnuplot > #1154
| From | Валерий Симонов <valerasimonov@gmail.com> |
|---|---|
| Newsgroups | comp.graphics.apps.gnuplot |
| Subject | Re: How to print floats with leading blanks instead of leading zeros using sprintf? |
| Date | 2012-05-28 19:33 -0700 |
| Organization | http://groups.google.com |
| Message-ID | <be36fac7-6d84-4a74-a650-1d56856bb959@wp3g2000pbc.googlegroups.com> (permalink) |
| References | <3d97629a-6d13-4e42-bb08-9a1d05a569d9@vy7g2000pbc.googlegroups.com> <jq0fds$lrn$1@dont-email.me> |
On May 28, 2:16 pm, sfeam <sf...@users.sourceforge.net> wrote:
> Валерий Симонов wrote:
> > Hi everyone,
>
> > I want to specify labels for the plots using sprintf.
> > According to
> >http://www.cplusplus.com/reference/clibrary/cstdio/sprintf/sprintf('
> > %3.0f',1) should print "001"
> > sprintf(' %3.0d',1) should print " 1".
> > However gnuplot outputs:
> > sprintf(' %3.0f',1) "001"
> > sprintf(' %3.0d',1) "1" (without leading blanks).
>
> > Does anyone know how to fix this issue?
>
> I cannot reproduce either of those results here.
> The first one in particular makes no sense.
> Could it be that you are not really using the format you show us?
>
> gnuplot> print sprintf("|%3.0d|",1)
> | 1|
> gnuplot>
sfeam, Hans-Bernhard Br\"oker, thank you for your replies.
It might be that I should provide you with more details.
So I have two files:
"sprintf.txt"
0.2 1.5970E-01 1.1262E-01
0.4 5.7188E-01 2.2227E-01
0.6 2.2019E-01 4.3648E-01
and a script file called "plot_sprintf" that I execute the following
way "./plot_sprintf 20 1"
#!/bin/sh
gnuplot << EOF
set terminal postscript eps enhanced
set output 'plot_sprintf.eps'
plot "sprintf.txt" using (\$1):(\$2) w l ls 1 t sprintf('T > %03.0f
abc',$1),\
"sprintf.txt" using (\$1):(\$3) w l ls 2 t sprintf('T > %3d abc',
$2)
unset table
EOF
As a result I get an file called "plot_sprintf.eps" that contains the
following lines "T > 020 abc" and "T > 1 abc" (instead of "T > 1
abc" I want).
P.S.
I would have attached the eps file, but I don't know how to do it?
Should I upload it to some website and post a link here?
Back to comp.graphics.apps.gnuplot | Previous | Next — Previous in thread | Next in thread | Find similar
How to print floats with leading blanks instead of leading zeros using sprintf? Валерий Симонов <valerasimonov@gmail.com> - 2012-05-28 08:09 -0700
Re: How to print floats with leading blanks instead of leading zeros using sprintf? sfeam <sfeam@users.sourceforge.net> - 2012-05-28 11:16 -0700
Re: How to print floats with leading blanks instead of leading zeros using sprintf? Валерий Симонов <valerasimonov@gmail.com> - 2012-05-28 19:33 -0700
Re: How to print floats with leading blanks instead of leading zeros using sprintf? sfeam <sfeam@users.sourceforge.net> - 2012-05-28 20:48 -0700
Re: How to print floats with leading blanks instead of leading zeros using sprintf? valerasimonov@gmail.com - 2012-05-29 06:18 -0700
Re: How to print floats with leading blanks instead of leading zeros using sprintf? valerasimonov@gmail.com - 2012-05-28 20:19 -0700
Re: How to print floats with leading blanks instead of leading zeros using sprintf? Hans-Bernhard Bröker <HBBroeker@t-online.de> - 2012-05-28 23:32 +0200
Re: How to print floats with leading blanks instead of leading zeros using sprintf? valerasimonov@gmail.com - 2012-05-28 19:56 -0700
Re: How to print floats with leading blanks instead of leading zeros using sprintf? Hans-Bernhard Bröker <HBBroeker@t-online.de> - 2012-05-29 18:33 +0200
Re: How to print floats with leading blanks instead of leading zeros using sprintf? valerasimonov@gmail.com - 2012-05-31 05:43 -0700
Re: How to print floats with leading blanks instead of leading zeros using sprintf? Christoph Bersch <usenet@bersch.net> - 2012-05-29 09:51 +0200
Re: How to print floats with leading blanks instead of leading zeros using sprintf? valerasimonov@gmail.com - 2012-05-29 06:19 -0700
csiph-web