Skip to content
Advertisement

Insert a matrix in matplolib

I want to import a numpy matrix in a matplotlib plot. Let’s say that I have this matrix:

JavaScript

In a scale from 0 to 3 of the x axis, I want to plot the points

JavaScript

This is the code I use:

JavaScript

and this is the outcome:

enter image description here

Yet, if I have to use a large array of let’s say (1000×1000) elements or more, this procedure is going to be extremely slow. I wander if there is a method in matplotlib in which the array is inserted in the plot without the need to “manually” insert each one element.

Also (and I know that this should be a different question) if the above question solved, is there an easy way to clear the drawing in order to update with a new matrix?

Advertisement

Answer

JavaScript

enter image description here

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement