Plotting with Matplotlib Tutorial -- Adding File Option

Hi,
I got the example to work and would love to plot from a file!

For example, I know to open a binary file is
file = open(“sample.bin”, “rb”)

But how could the data be placed into an array, for plotting? For example, assuming you prompt the user for file location, the number of bytes per data (1,2, 3 or 4), and the endiness… i.e. the first byte is the MSB or LSB… how can I plot the data value on the y, and the sample number on the x?