-1

I have a csv file that is 200x200. Most of the values are zeros. Somewhere at the center, I have values like this:

one

Zooming it out further gives this:

two

Nonzero values form this rectangle(ish) shape.

I want to plot these values with matplotlib so that they look as follows:

three

Any quick help would be appreciated. Thank you!

Sarmad Gulzar
  • 136
  • 2
  • 9
  • Actually I am not sure about the type of graph that would accomplish what I want. – Sarmad Gulzar Oct 10 '19 at 18:24
  • you should probably show what you've tried. I'm not sure what type of graph you want either. At the minimum, you should be able to use a heatmap. https://stackoverflow.com/questions/33282368/plotting-a-2d-heatmap-with-matplotlib – Buckeye14Guy Oct 10 '19 at 18:26

1 Answers1

0

It should be as simple as:

import numpy as np
import matplotlib.pyplot as plt

data = np.genfromtxt('data.csv', delimiter=',')

plt.figure(figsize=(15, 15))
plt.imshow(data)

The plot has to be a decent size to see the nonzero data, since there are quite a few pixels.

Matt Hall
  • 7,614
  • 1
  • 23
  • 36