Original Usenet thread from alt.ascii-art, started 13 Nov 2002.
_ _ _ _ _ _ | | | |___ ___ _ __ ___| |_ / \ _ __ ___| |__ (_)_ _____ | | | / __|/ _ \ '_ \ / _ \ __| / _ \ | '__/ __| '_ \| \ \ / / _ \ | |_| \__ \ __/ | | | __/ |_ / ___ \| | | (__| | | | |\ V / __/ \___/|___/\___|_| |_|\___|\__| /_/ \_\_| \___|_| |_|_| \_/ \___|
ASCII-Art function plotting, advice needed...
alt.ascii-art
· 6 messages · 13 Nov 2002 - 15 Nov 2002
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
_.--- 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
[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.
Josef 'Jupp' Schugt <jup...@gmx.de> 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/@./.@/)
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
On 14 Nov 2002 11:15:50 GMT, Harry Mason <spa...@no.spam> 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/ __..--""""""--..__ jup...@gmx.de _________________________..--"" There's source ""--..______________ ""--..__ out there! __..--"" ""--..__..--""
Related ASCII art in the Gallery
Explore these categories from our collection of 11,000+ artworks:
Make your own ASCII art
Turn images, text or 3D into ASCII, or draw your own – right in your browser.
About this thread.
These messages were posted publicly to the newsgroup
alt.ascii-art
in 2002 and are mirrored here unchanged as part of the Historic Archives – only email addresses are masked.
The artwork and text belong to their original authors: if you copy a piece, keep the artist's initials or signature intact and credit them where you can.
Are you one of the authors? Contact us to get your posts attributed, connected to your artist profile, or removed.
Report this message
Help us keep the archive clean and accurate. Reports are reviewed by a person – nothing is changed automatically.