Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.graphics.apps.gnuplot > #4008
| Path | csiph.com!feeder.erje.net!1.eu.feeder.erje.net!weretis.net!feeder4.news.weretis.net!feeder5.news.weretis.net!news.solani.org!.POSTED!not-for-mail |
|---|---|
| From | Karl Ratzsch <mail.kfr@gmx.net> |
| Newsgroups | comp.graphics.apps.gnuplot |
| Subject | Re: space between sign and digit |
| Date | Thu, 12 Jul 2018 20:42:26 +0200 |
| Organization | solani.org |
| Lines | 45 |
| Message-ID | <pi87ef$aee$1@solani.org> (permalink) |
| References | <pi49eq$a7$1@dont-email.me> <pi4dfb$rk4$1@solani.org> <pi4seh$66s$1@dont-email.me> <pi4vvj$8k6$1@solani.org> <pi6pc1$ne4$1@dont-email.me> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=utf-8 |
| Content-Transfer-Encoding | 8bit |
| X-Trace | solani.org 1531420943 10702 127.0.0.43 (12 Jul 2018 18:42:23 GMT) |
| X-Complaints-To | abuse@news.solani.org |
| NNTP-Posting-Date | Thu, 12 Jul 2018 18:42:23 +0000 (UTC) |
| User-Agent | Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 |
| Cancel-Lock | sha1:TO3gKJp4+zNJ1PWGumhYp/1rk6w= |
| In-Reply-To | <pi6pc1$ne4$1@dont-email.me> |
| X-User-ID | eJwFwYkRADAEBMCWvIdykNF/Cdl1BWPD4DA/v+3kLKsSIgoErY5tq3P4eyx5wwfZJmoZ6w8CLxCG |
| Content-Language | de-DE-1901 |
| Xref | csiph.com comp.graphics.apps.gnuplot:4008 |
Show key headers only | View raw
Am 12.07.2018 um 07:36 schrieb Jörg Buchholz:
> On 11.07.2018 15:16, Karl Ratzsch wrote:
>> Am 11.07.2018 um 14:16 schrieb Jörg Buchholz:
>>> On 11.07.2018 10:00, Karl Ratzsch wrote:
>>>> plot f11(x) lt 2 lw 4 dt 4 t \
>>>> sprintf("f11(x) =%.2f·x %s %.2f",a,b11<0?"-":"+",abs(b11))
>>>>
>>>
>>> Interesting solution. On more complex functions the code is a bit long.
>>
>> You're welcome. ;-) This looks a bit nicer
>>
>> nstr(x) = sprintf("%s %.2f",x<0?"-":"+",abs(x)) # return string with a
>> space between sign and number
>>
>> plot f11(x) title sprintf("f11(x) =%.2f·x %s",a,nstr(b11))
>>
>> or you can even outsource the whole sprintf() call into a function
>>
>> tstr(n,a,b) = sprintf("%s = %.2f·x %s %.2f",n,a,b<0?"-":"+",abs(b))
>>
>> plot f11(x) title tstr("f11(x)",a,b11)
>>
>> so your plot command stays readable.
>
> It is the right direction, something like a "newcommand" in LaTex that
> makes the daily work easier.
>
> But I need the %.2f variable, cause sometimes there are numbers which
> needs more or less digits after the floating point.
That's something missing in sprintf(), a way to give the overall
number of significant digits for fp output. You can of course use
exponential notation.
Or write a function that uses sprintf() to construct a customised
format string for another sprintf() function call.
#syntax tstr(fnamstr,a,b,b_ndecimals)
tstr(n,a,b,bs) = sprintf("%s = %.2f·x %s
%.".sprintf("%.f",bs)."f",n,a,b<0?"-":"+",abs(b))
;-)
Back to comp.graphics.apps.gnuplot | Previous | Next — Previous in thread | Next in thread | Find similar
space between sign and digit Jörg Buchholz <bookwood4new@freenet.de> - 2018-07-11 08:52 +0200
Re: space between sign and digit Karl Ratzsch <mail.kfr@gmx.net> - 2018-07-11 10:00 +0200
Re: space between sign and digit Jörg Buchholz <bookwood4new@freenet.de> - 2018-07-11 14:16 +0200
Re: space between sign and digit Karl Ratzsch <mail.kfr@gmx.net> - 2018-07-11 15:16 +0200
Re: space between sign and digit Jörg Buchholz <bookwood4new@freenet.de> - 2018-07-12 07:36 +0200
Re: space between sign and digit Karl Ratzsch <mail.kfr@gmx.net> - 2018-07-12 20:42 +0200
Re: space between sign and digit Hans-Bernhard Bröker <HBBroeker@t-online.de> - 2018-07-11 20:06 +0200
Re: space between sign and digit Karl Ratzsch <mail.kfr@gmx.net> - 2018-07-12 06:53 +0200
Re: space between sign and digit Jörg Buchholz <bookwood4new@freenet.de> - 2018-07-12 07:21 +0200
csiph-web