Skip to content

Instantly share code, notes, and snippets.

@yuwash
Created August 1, 2013 19:40
Show Gist options
  • Save yuwash/6134540 to your computer and use it in GitHub Desktop.
Save yuwash/6134540 to your computer and use it in GitHub Desktop.
Simple ASCII Plotter usage examples, 1-D (some discrete points) and 2-D (sin([0,2pi])) each
""" @file plot-examples.py
@brief ASCII-Plotter examples
@details Example usage of
[ASCII-Plotter](https://pypi.python.org/pypi/ASCII-Plotter/1.0),
with 1-D and 2-D examples each;
Currently you can obtain the aplotter.py file by
Imri Goldberg from
http://www.algorithm.co.il/blogs/ascii-plotter/
@author [Yushin Washio](https://github.com/yuwash)
@date 2013
@copyright GNU GPL 3, see http://www.gnu.org/licenses/gpl.html
"""
import aplotter, math
print('****** Sin([0,2pi]) ******')
scale=0.1
n=int(2*math.pi/scale)
plotx=[scale*i for i in xrange(n)]
ploty=[math.sin(scale*i) for i in xrange(n)]
aplotter.plot(plotx,ploty)
print('****** Some discrete data sequence ******')
data=[ord(c) for c in 'ASCII Plotter example']
aplotter.plot(data)
@yuwash
Copy link
Author

yuwash commented Aug 1, 2013

Output (Rev 1):

****** Sin([0,2pi]) ******
   |                                                                            
   +1              -------                                                      
   |           ----       ---                                                   
   |          -              \\\                                                
   |       ///                  \                                               
   |      /                      \\                                             
   |    //                         \                                            
   |   /                            \\                                          
   |  /                               \\                                        
---+//----------------------------------\-----------------------------------+---
   +0                                    \                              +6.1    
   |                                      \                                 *   
   |                                       \\\                             /    
   |                                          \                         ///     
   |                                           \                       /        
   |                                            \\\                  //         
   |                                               \-             ///           
   |                                                 ----      ---              
   -1                                                    ------                 
   |                                                                            
****** Some discrete data sequence ******
   |                                                                            
   +120                                                   \                     
   |                                ----\      |         /\                     
   +                         -------     \    /|        /  \     --------   +   
   +0                       /             \  / |       /   \    /        +20    
   |                       /               //  |      /     \  /           -*   
   |                       /                   |     |       //                 
   |                      /                    |     |                          
   |   \                 /                      |    |                          
   |  / \                /                      |   |                           
   | /   \    ----\     |                       |   |                           
   |/     ----    \     |                       |   |                           
   /              \    |                        |  |                            
   |               \   |                         | |                            
   |               \  |                          | |                            
   |               \  |                          ||                             
   |                \|                           ||                             
   |                \|                           ||                             
   +32               |                            |                             
   |        

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment