简体   繁体   中英

Grid of values into density plot in python

I need to convert a grid of values into a density plot to make a picture that shows the structure of the silicon surface that was scanned. The file of values is called stm.txt and can be found here: http://www-personal.umich.edu/~mejn/cp/programs.html

I really can't figure this one out so I'm in some real need of help.

You can use numpy's loadtxt ( https://docs.scipy.org/doc/numpy-1.10.4/reference/generated/numpy.loadtxt.html ) to load your data, and then imshow ( https://matplotlib.org/api/_as_gen/matplotlib.pyplot.imshow.html ).

import numpy as np
import matplotlib.pyplot as plt

grid = np.loadtxt("stm.txt")
plt.imshow(grid)
plt.show()

stm.txt的密度图

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM