In this repo, we include a basic plotting library in JACK (Nand2Tetris).
In a nutshell, we have classes for the following plot types:
- Line Graph
- Histogram
- Scatter Plot
For plotting, we use the inbuilt screen functions to draw circles and rectangles to create the plot type.
Based on our requirements, we translate the co-ordinates of the plot type to the screen co-ordinates.
For every plot, we make a while loop, and plot the graphics on screen.
Edit the Main.jack file, compile the file and run the program in VMEmulator.
let random = Random.new(420);
The number in the bracket decides the seed of the random number generator.
let number = random.randRange(intRange);
The number in the bracket decides the range of the random number generator.
Now we create an array with the needed values or random values.
We can now call the respective class to draw the plot types.
Takes input of X array and Y array, along with int Array Length
do Scatter.draw(InputX, InputY, ArrayLength);
Takes input of X array and Y array, along with int Array Length
do LineGraph.draw(InputX, InputY, ArrayLength);
Takes input of X array, along with int Array Length
do Hist.draw(InputX, ArrayLength);
- Automatic Scaling of the plots based on the input values
- X and Y tics and labels