All Projects → johnmyleswhite → ASCIIPlots.jl

johnmyleswhite / ASCIIPlots.jl

Licence: other
Generate simple plots as ASCII art in Julia

Programming Languages

julia
2034 projects

ASCIIPlots.jl

THIS PACKAGE IS ABANDONED. DO NOT USE IT.

Generate basic plots in Julia as ASCII art in the Julia REPL. This is based on code by Billou Bielour.

Usage Examples

We'll start with imagesc:

using ASCIIPlots

A = eye(10)
imagesc(A)

This evaluates to,

julia> imagesc(A)


	@#                  
	  @#                
	    @#              
	      @#            
	        @#          
	          @#        
	            @#      
	              @#    
	                @#  
	                  @#

Then we'll change the data a bit and replot it:

A[10, 1] = 1
A[1, 10] = 1
imagesc(A)

This evaluates to,

julia> imagesc(A)


	@#                @#
	  @#                
	    @#              
	      @#            
	        @#          
	          @#        
	            @#      
	              @#    
	                @#  
	@#                @#

Now we'll make a lineplot and a scatterplot:

x = 2 * pi * rand(30)
y = sin(x) + 0.1 * randn(30)

lineplot(x, y)

This evaluates to,

julia> lineplot(x, y)

	-------------------------------------------------------------
	|             \                                              | 1.01
	|         \/                                                 |
	|          /                                                 |
	|     /  /                                                   |
	|                                                            |
	|  /                                                         |
	|                                                            |
	|                                                            |
	|/                                                           |
	|                                                            |
	|                                                          \ |
	|                               \                        \  \|
	|                              -                          /  |
	|                                                            |
	|                                   \                 /      |
	|                                    \               /       |
	|                                     \           /\         |
	|                                                   /        |
	|                                         -  \ /             |
	|                                      /       /             | -1.16
	-------------------------------------------------------------
	0.13                                                    6.19

Then we'll do a scatterplot:

scatterplot(x, y)

This evaluates to,

julia> scatterplot(x, y)

	-------------------------------------------------------------
	|             ^                                              | 1.01
	|         ^^                                                 |
	|          ^                                                 |
	|     ^  ^                                                   |
	|                                                            |
	|  ^                                                         |
	|                                                            |
	|                                                            |
	|^                                                           |
	|                                                            |
	|                                                          ^ |
	|                               ^                        ^  ^|
	|                              ^                          ^  |
	|                                                            |
	|                                   ^                 ^      |
	|                                    ^               ^       |
	|                                     ^           ^^         |
	|                                                   ^        |
	|                                         ^  ^ ^             |
	|                                      ^       ^             | -1.16
	-------------------------------------------------------------
	0.13                                                    6.19

We can control the glyph being used:

scatterplot(x, y, sym = '*')

This evaluates to,

julia> scatterplot(x, y, sym = '*')

	-------------------------------------------------------------
	|             *                                              | 1.01
	|         **                                                 |
	|          *                                                 |
	|     *  *                                                   |
	|                                                            |
	|  *                                                         |
	|                                                            |
	|                                                            |
	|*                                                           |
	|                                                            |
	|                                                          * |
	|                               *                        *  *|
	|                              *                          *  |
	|                                                            |
	|                                   *                 *      |
	|                                    *               *       |
	|                                     *           **         |
	|                                                   *        |
	|                                         *  * *             |
	|                                      *       *             | -1.16
	-------------------------------------------------------------
	0.13                                                    6.19
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].