Path: csiph.com!usenet.pasdenom.info!gegeweb.org!eternal-september.org!feeder.eternal-september.org!mx04.eternal-september.org!.POSTED!not-for-mail From: sfeam Newsgroups: comp.graphics.apps.gnuplot Subject: Re: How to print floats with leading blanks instead of leading zeros using sprintf? Followup-To: comp.graphics.apps.gnuplot Date: Mon, 28 May 2012 11:16:26 -0700 Organization: gnuplot development team Lines: 29 Message-ID: References: <3d97629a-6d13-4e42-bb08-9a1d05a569d9@vy7g2000pbc.googlegroups.com> Reply-To: sfeam@users.sourceforge.net Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8Bit Injection-Date: Mon, 28 May 2012 18:16:29 +0000 (UTC) Injection-Info: mx04.eternal-september.org; posting-host="3mhAfh4CeAIeL3OKnPexDA"; logging-data="22391"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+zqLX862nHW9Xx64JUx21q" User-Agent: KNode/4.4.9 Cancel-Lock: sha1:xidAt6fRKRn0J1D7TephEG+fdtk= Xref: csiph.com comp.graphics.apps.gnuplot:1151 Валерий Симонов 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> > > Thanks in advance! > > Regards, > Valera