From: Josef 'Jupp' Schugt Newsgroups: alt.ascii-art Subject: ASCII-Art function plotting, advice needed... Date: Wed, 13 Nov 2002 20:47:33 +0000 Organization: none Lines: 59 Message-ID: NNTP-Posting-Host: ae5b9.pppool.de (213.6.229.185) X-Trace: fu-berlin.de 1037233334 14291284 213.6.229.185 (16 [53633]) X-Orig-Path: jupp.8m.com!news User-Agent: slrn/0.9.7.4 (Linux) Path: chonsp.franklin.ch!pfaff.ethz.ch!news-zh.switch.ch!news-ge.switch.ch!news-fra1.dfn.de!fu-berlin.de!uni-berlin.de!ae5b9.pppool.DE!not-for-mail Xref: chonsp.franklin.ch alt.ascii-art:33017 Hi! I hope my question is on-topic and not too scientific. I want to write a tiny ASCII-Art function plotter that outputs graphics like the following (this sample has been done manually, it's just a proof of concept and the result of fiddling with different characters for the function plot): > sin(x) for x ranging from -3 to 3 > ______________________________________________________________ 1 > | | _-"""""-_ | > | | _" -_ | > | | _" - | > | | - "_ | > | | - _ |_ > | | - - | > | | " - | > | | " -| > | |_" - > |___________________________________________________________|__ 0 > | _| | > - _ | | > |- _ | | > | - _ | | > | " _ | | > | " - | |_ > | "_ - | | > | - _" | | > | "_ _- | | > |_________"-_____-"___________|_____________________________|__ -1 > | ' | ' | ' | ' | ' | ' | > -3 -2 -1 0 1 2 3 The idea of achieving a good vertical resolution is mapping [0.000, 0.025) to '_', [0.025, 0.075) to '-', [0.075, 0.100) to '"'. (left boundary included, right one excluded that is) - note that the above plot may slightly differ from this mapping; it was done manually and to err is human. Anybody has a better mapping? Forget about '^' or similar characters that look very different in different fonts - I can't control the font that is used. The ideal mapping would take into account not only the value at a given point but also the left and right neighbor (which is an approximation for the slope). The output is meant to be generated automatically so I need fixed mapping rules. Anybody can provide such rules? Before I forget it: The output is meant to fit 80x24 (actually 79x24 that is); note that I didn't use full width because there has to be some space left for numbers with more digits. You wonder what this plotter is good for? The idea is to make a server output status diagrams even if there is no 'real' graphics available. Josef 'Jupp' Schugt ###### Newsgroups: alt.ascii-art From: Faux_Pseudo Subject: Re: ASCII-Art function plotting, advice needed... References: Reply-To: Faux_Pseudo@yahoo.comERCIAL X-PGP-Server: wwwkey.nl.pgp.net X-Why: are you reading this? X-PGP-KeyID: CF4DA06B Message-ID: User-Agent: slrn/0.9.7.4 (Linux) Lines: 58 Date: Thu, 14 Nov 2002 01:55:38 GMT NNTP-Posting-Host: 68.8.9.87 X-Complaints-To: abuse@cox.net X-Trace: news2.west.cox.net 1037238938 68.8.9.87 (Wed, 13 Nov 2002 20:55:38 EST) NNTP-Posting-Date: Wed, 13 Nov 2002 20:55:38 EST Organization: Cox Communications Path: chonsp.franklin.ch!pfaff.ethz.ch!news-zh.switch.ch!news.imp.ch!news.imp.ch!zen.net.uk!195.149.39.56.MISMATCH!news-peer-lilac.gradwell.net!peer1.news.newnet.co.uk!news-xfer.cox.net!p01!news2.west.cox.net.POSTED!53ab2750!not-for-mail Xref: chonsp.franklin.ch alt.ascii-art:33043 _.--- Josef 'Jupp' Schugt spoke in alt.ascii-art --------._ > Hi! > > I hope my question is on-topic Yup. > and not too scientific. I would love to see more sci ascii. I might even do some my self. But what you want is way above my capablities to map out. I can offer some suggestions though. There has to be code out there some place to handle the input data and figure out what the sin et al are going to be. As far as getting it to the screen in ASCII-Vision I would look at aalib and ncurses which have been ported to almost any platform available and can be found on freshmeat.net And " also veries with the font. I changed my font about 4 minuts ago and right now i have the " slanted like // while in the last font I was using it was || sin(x) for x ranging from -3 to 3 .___________________________________________________________.___ 3 [ | _-~ ~~-_ ] [ | ,' `. ] | [ | / \ ] [ | ,' \ ] | [ Houston, we | / `. ]_ [ have a problem| / \ ] | [ ` | / \ ] [ o | / \] | [ / | / \ [______________________/\_____|/____________________________]___ 0 [ / ] \ ,'| ] | [\ / | ] [ \ / | ] | [ \ / | ] [ \ / | ]_ | [ \ / | ] [ `. ,' | ] | [ `. ,' | ] [_________~-_____-~___________|_____________________________]___-3 | ' | ' | ' | ' | ' | ' | | -3__ __ -2 __ __-1__ __ _0 __ __ 1_ __ __2 __ __ 3:F_P: ######################################Wed Nov 13 2002################# '---...____ Faux_Pseudo ________________...---~~~ -- ICQ=66618055 : (Now Playing) http://asciipr0n.com/fp updated=10/30 YIM=faux_pseudo : Rev: /moby/Moby-Flower-RNS.mp3 We are what we : Now: hville_1969_-_09_-_Girl_Of_The_North_Country.mp3 pretend to be : Fwd: g_-_Family_Man_-_06_-_No_Deposit_-_No_Return.mp3 ###### From: Kjetil Torgrim Homme Newsgroups: alt.ascii-art Subject: Re: ASCII-Art function plotting, advice needed... Date: 14 Nov 2002 11:52:22 +0100 Organization: Dept. of Informatics, Univ. of Oslo, Norway Lines: 80 Message-ID: <1rvg3077a1.fsf@tiu.ifi.uio.no> References: NNTP-Posting-Host: tiu.ifi.uio.no Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: maud.ifi.uio.no 1037271142 22418 129.240.65.210 (14 Nov 2002 10:52:22 GMT) X-Complaints-To: abuse@ifi.uio.no NNTP-Posting-Date: 14 Nov 2002 10:52:22 GMT User-Agent: Gnus/5.0808 (Gnus v5.8.8) Emacs/20.7 Path: chonsp.franklin.ch!pfaff.ethz.ch!news-zh.switch.ch!feedme.news.mediaways.net!eusc.inter.net!feed.news.nacamar.de!uio.no!nntp.uio.no!ifi.uio.no!not-for-mail Xref: chonsp.franklin.ch alt.ascii-art:33014 [Josef 'Jupp' Schugt]: > > > sin(x) for x ranging from -3 to 3 > > ______________________________________________________________ 1 > > | | _-"""""-_ | > > | | _" -_ | > > | | _" - | > > | | - "_ | > > | | - _ |_ > > | | - - | > > | | " - | > > | | " -| > > | |_" - > > |___________________________________________________________|__ 0 > > | _| | > > - _ | | > > |- _ | | > > | - _ | | > > | " _ | | > > | " - | |_ > > | "_ - | | > > | - _" | | > > | "_ _- | | > > |_________"-_____-"___________|_____________________________|__ -1 > > | ' | ' | ' | ' | ' | ' | > > -3 -2 -1 0 1 2 3 > > The idea of achieving a good vertical resolution is mapping > > [0.000, 0.025) to '_', [0.025, 0.075) to '-', [0.075, 0.100) to '"'. > > (left boundary included, right one excluded that is) - note that the > above plot may slightly differ from this mapping; it was done > manually and to err is human. > > Anybody has a better mapping? Forget about '^' or similar characters > that look very different in different fonts - I can't control the > font that is used. The ideal mapping would take into account not only > the value at a given point but also the left and right neighbor > (which is an approximation for the slope). I think it is better to consider each character a box, and to use the intersection points to select the character. that is, at (-2, -1), you have a box which is _really_ covering the area (-2.05, -0.8) (-1.95, -1.0). to plot that point, consider sin(-2.05) == -0.887 (43.5% into the box) and sin(-1.95) == -0.929 (64.5% into the box) +-----+ 0% | | 20% * | 40% | * 60% | | 80% +-----+ 100% in addition to these percentages, the intersection on one side can happen in a box above or below it. let's call these cases just A and B. now you need to map these into characters. A B | B A | B 80 , 20 A ' 0 100 \ 100 0 / 100 100 _ B 100 _ 100 B _ 0 0 " 0 A " A 0 " 50 50 - the above values should _really_ be ranges, of course. Kjetil T. ###### Newsgroups: alt.ascii-art From: Harry Mason Subject: Re: ASCII-Art function plotting, advice needed... References: Message-ID: User-Agent: slrn/0.9.7.4 (Linux) NNTP-Posting-Host: orbital.ecs.soton.ac.uk Date: 14 Nov 2002 11:15:50 GMT X-Trace: 14 Nov 2002 11:15:50 GMT, orbital.ecs.soton.ac.uk Lines: 42 Path: chonsp.franklin.ch!pfaff.ethz.ch!news-zh.switch.ch!news.imp.ch!news.imp.ch!fr.clara.net!heighliner.fr.clara.net!newsfeed.sovam.com!newsfeed.gamma.ru!Gamma.RU!peer.news.eu-x.com!server2.netnews.ja.net!news-spool.soton.ac.uk!news.ecs.soton.ac.uk!orbital.ecs.soton.ac.uk Xref: chonsp.franklin.ch alt.ascii-art:33013 Josef 'Jupp' Schugt wrote: [ascii function plotter] > The idea of achieving a good vertical resolution is mapping > > [0.000, 0.025) to '_', [0.025, 0.075) to '-', [0.075, 0.100) to '"'. > > Anybody has a better mapping? Forget about '^' or similar characters > that look very different in different fonts - I can't control the > font that is used. The ideal mapping would take into account not only > the value at a given point but also the left and right neighbor > (which is an approximation for the slope). The problem I see with this is large gradients. For sin(x) it is quite possible to create a smooth curve in ascii, but if you were drawing a few more periods it would soon stop looking like sin(x) at all. If your gradients aren't too large you could try this mapping. Rows are the value at the left hand edge of the character cell; columns are the value at the right hand edge. <0 0.00 0.25 0.50 0.75 >1 <<0, >>1 0.00 _ _ , , / / _ 0.25 . _ . - = / . 0.50 . . - - " ' - 0.75 \ \ = ` " ' " > You wonder what this plotter is good for? The idea is to make a > server output status diagrams even if there is no 'real' graphics > available. Things like uptime, load, active connections? You might be better off with a histogram; it's much easier to represent in ascii. You might want to talk to Markus Gebhard; he wrote a function plotter for JavE (http://www.jave.de/). The code isn't available, but you could ask his advice. -- Harry Mason ("hjm200.ecs@soton@ac@uk" =~ tr/@./.@/) ###### From: Andreas Freise Newsgroups: alt.ascii-art Subject: Re: ASCII-Art function plotting, advice needed... Date: Thu, 14 Nov 2002 13:56:30 +0100 Organization: Universitaet Hannover Lines: 84 Message-ID: References: NNTP-Posting-Host: 130.75.234.141 X-Trace: newsserver.rrzn.uni-hannover.de 1037278634 3154 130.75.234.141 (14 Nov 2002 12:57:14 GMT) X-Complaints-To: abuse@newsserver.rrzn.uni-hannover.de NNTP-Posting-Date: 14 Nov 2002 12:57:14 GMT X-Face: %XhMERdBemohx4TB/zw0f`1Y%d}y10tjY4RjzCc&DWou4VZc;7iz#f3F8a-V|hA9Ief>mYBeoVep0^f#tV{;TrhZPPKPLwl^F&mypu*u0*YcWt0P}%kYb~C..+}_[2!%&THVkvA8c0:"~[\*~0O*$\1zDa5eIlG User-Agent: slrn/0.9.7.4 (Linux) Path: chonsp.franklin.ch!pfaff.ethz.ch!news-zh.switch.ch!news.imp.ch!news.imp.ch!solnet.ch!solnet.ch!newsfeed.freenet.de!news-lei1.dfn.de!news-ham1.dfn.de!newsserver.rrzn.uni-hannover.de!adfpc.amp.uni-hannover.de!nobody Xref: chonsp.franklin.ch alt.ascii-art:33036 On 14 Nov 2002 Harry Mason wrote: [...] > The problem I see with this is large gradients. For sin(x) it is quite > possible to create a smooth curve in ascii, but if you were drawing a few > more periods it would soon stop looking like sin(x) at all. [...] > You might want to talk to Markus Gebhard; he wrote a function plotter for > JavE (http://www.jave.de/). The code isn't available, but you could ask his > advice. Markus' plotter is quiet good. I assume he uses his "generic line" code to convert the function to an ascii line. That would be the same code as for the free-hand drawing tool. Just two examples (sine functions) : | | | ___ | _.-' `'-. | ,' `. | ,' `. | / `. | ,' \ | / `. | / \ ` ,' \ '`.''''''''''''''''''''''''''''''','''''''''''''''''''''''''''''''''`. \ / | \ / | `. ,' | \ / | `. ,' | `. ,' | `. _,' | `--...-' | | | | | | | /\ /. b |.\ /\ /. b /| || | | || ||| /| || | | || || | | | | | | ||| || | | | | | | | | | | | | | | || | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | .' | | | | | | | | | .' | | | | | | '. | | | | | | | | | '. | | | | | | | | | | | | | | | | | | | | | .' | | | | | | | | | .' | | | | | | | | | | | | | | | | | | | | | '''|'''|'''|'''|'''|'''|'''|'''|'''|'''|''|'''|'''|'''|'''|'''|'''|''' | | | | | | | | | .' | | | | | | | | | | | | | | | | | || | | | | | | | | | | | | | | | | | || | | | | | | | | | | | | | | | | | || | | | | | | | | | | | | | | | | | || | | | | | | | | | | | | | | | | | || | | | | | | | | || | | | | | | | || || | | | | | | || || | | | | || | || || | | | | || |/ L| '/ || | || |/ L| '/ ' ' | ' ' | | | Of course the second is difficult to recognise as sin(...) but I think it is good enough. I actually had to use the Ascii terminal of Gnuplot for a while because my graphics card was broken and I had to get some results quickly. That terminal just used XXX for drawing and one has guess the result mostly. It is a pity that his code is not to be integrated into Gnuplot. I am a big fan of Gnuplot and would use an Ascii output like above just for fun. :) Andreas -- ________________________________________________ http://www.ascii-art.de ###### From: Josef 'Jupp' Schugt Newsgroups: alt.ascii-art Subject: Re: ASCII-Art function plotting, advice needed... Date: Fri, 15 Nov 2002 00:01:01 +0000 Organization: none Lines: 37 Message-ID: References: NNTP-Posting-Host: ab2cc.pppool.de (213.6.178.204) X-Trace: fu-berlin.de 1037374543 15660715 213.6.178.204 (16 [53633]) X-Orig-Path: jupp.8m.com!news User-Agent: slrn/0.9.7.4 (Linux) Path: chonsp.franklin.ch!pfaff.ethz.ch!news-zh.switch.ch!news.imp.ch!news.imp.ch!fu-berlin.de!uni-berlin.de!ab2cc.pppool.DE!not-for-mail Xref: chonsp.franklin.ch alt.ascii-art:33050 On 14 Nov 2002 11:15:50 GMT, Harry Mason wrote: > Things like uptime, load, active connections? You might be better > off with a histogram; it's much easier to represent in ascii. Actually what I want to do *is* drawing histograms. What I am looking for is an improved vertical resolution. Compare these figures that all represent the same constant increase: _ _ _-"| ## _ _ _| | | _-" | ##### _ _ _| | | | | | _-" | ######## _ _ _| | | | | | | | | _-"_________| ########### _|_|_|_|_|_|_|_|_|_|_|_| [...+....1..] [...+....1.] [...+....1....+....2...] In the first case I did use '_' to represent values smaller than 1/3, '-' for values between 1/3 and 2/3 and '"' for values above 2/3 (in units of a single character box). As has been pointed out: the issue is large slopes. The scond one uses '#' for anything above 1/2. The last image shows a 'real' histogramm. You see the difference (both in terms of resolution and width)? The playing around with this problem gave rise to a new signature. I'm pretty sure it will result in some 'Your signature is too long' false alerts ;-) Josef 'Jupp' Schugt -- Web: http://jupp.tux.nu/ __..--""""""--..__ jupp@gmx.de _________________________..--"" There's source ""--..______________ ""--..__ out there! __..--"" ""--..__..--""