-1

I have a data file in excel (.xlsx). The data represents a 100 micrometer by 100 micrometer area. Number of steps were set at 50 for x and 50 for y meaning each pixel is 2 micrometer in size. How can I create a 2D image from this data.

  • Are there values in each cell? – Brian Spiering Dec 18 '18 at 06:33
  • 1
    What is with people and [needlessly complex Excel based workflows](https://stackoverflow.com/q/53663758/425458) lately? You can probably fix your current problem using [`pandas.read_excel`](https://pandas.pydata.org/pandas-docs/stable/generated/pandas.read_excel.html), but a much better long term solution is to find another way to store your image data. – tel Dec 18 '18 at 07:36
  • [plotting a matrix with matplotlib](https://matplotlib.org/2.0.2/examples/pylab_examples/matshow.html) – Jonas Dec 18 '18 at 08:57
  • @BrianSpiering yes they are readings from an analog photomultiplier tube – user188062 Dec 19 '18 at 16:52
  • @tel Agreed but its a labview program written by someone long time ago for some antiquated hardware. – user188062 Dec 19 '18 at 16:54

2 Answers2

1

getting data from xslx files can be achieved using the openpyxl python module. after installing the module a simple example is (assuming you have an xslx as in the image attached):

from openpyxl import load_workbook
wb = load_workbook("/path/to/matrix.xlsx")
cell_range = wb['Sheet1']['B2:G16']
for row in cell_range:
    for cell in row:
        print(str(cell.value) + " ", end='')
    print("")

this would print all the vaules in the range, you could also read them into a numpy array and plot. xslx example

0

If you are willing to plot the pixels instead of points using matplotlib then you can convert your dataframe into numpy array and then plot that array using imshow() method of matplotlib, after manipulating the numpy array as per your need.

Hemang Vyas
  • 309
  • 2
  • 10