All Questions
527 questions
55
votes
1
answer
261k
views
TypeError: Invalid dimensions for image data when plotting array with imshow()
For the following code
# Numerical operation
SN_map_final = (new_SN_map - mean_SN) / sigma_SN
# Plot figure
fig12 = plt.figure(12)
fig_SN_final = plt.imshow(SN_map_final, interpolation='nearest')
...
46
votes
4
answers
135k
views
Overlay an image segmentation with numpy and matplotlib
I am trying to overlay two images. The first one is a 512x512 NumPy array (from a CT image). The second one is also a 512x512 NumPy array but I am just interested in the pixels where the value is ...
28
votes
3
answers
55k
views
FutureWarning: Using a non-tuple sequence for multidimensional indexing is deprecated use `arr[tuple(seq)]` instead of `arr[seq]`
I would like not to use the non-tuple sequence for multidimensional indexing so that the script will support future release of Python when this changes.
Below is the code that i am using for plotting ...
22
votes
5
answers
66k
views
how to save an array as a grayscale image with matplotlib/numpy?
I am trying to save a numpy array of dimensions 128x128 pixels into a grayscale image.
I simply thought that the pyplot.imsave function would do the job but it's not, it somehow converts my array into ...
16
votes
2
answers
26k
views
Display numpy array in a for loop using matplotlib imshow
I have a numpy array whose elements are updated in a for loop:
a = np.array([[1,2,3],[4,5,6],[7,8,9]])
for t in range(0,10):
imshow(a)
for i in range(0,a.shape[0]):
for j in range(0,...
16
votes
1
answer
194k
views
How to plot an array in python?
I follow this links How to append many numpy files into one numpy file in python to put all my numpy files in one file.
Now, I need to plot my file which contains many arrays, each array contain ...
15
votes
1
answer
35k
views
Python color map but with all zero values mapped to black
I have a square array of elements which correspond to lattice sites. Some of the elements are zero and the rest vary between 1 and about 2700. Using imshow and the OrRd colour map, I want all lattice ...
15
votes
1
answer
8k
views
Animation quality is better with matshow() than with imshow(). How to improve it?
I displayed an array with matshow and it works fine but now I want to try imshow. The issue is that the quality of imshow is really poor compared to matshow.
How can I fix this ?
Matshow:
matshow(...
15
votes
1
answer
30k
views
Python scatter plot 2 dimensional array
I'm trying to do something that I think should be pretty straight forward but I can't seem to get it to work.
I'm trying to plot 16 byte values measured over time to see how they change. I'm trying ...
13
votes
2
answers
29k
views
Creating a 3D surface plot from three 1D arrays
I've got 3 arrays as shown below and I'm trying to plot a 3d surface plot (wireframe or any other) from it. I've created a scatter plot from it but not sure how to approach it from a 3D surface plot ...
13
votes
2
answers
14k
views
VTK to Matplotlib using Numpy
I want to extract some data (e.g. scalars) from a VTK file along with their coordinates on the grid then process it in Matplotlib. The problem is I dont know how to grab the point/cell data from the ...
13
votes
1
answer
24k
views
X Y Z array data to heatmap
I couldn't quite find a consensus answer for this question or one that fits my needs -- I have data in three columns of a text file: X, Y, and Z. Columns are tab-deliminated. I would like to make a ...
8
votes
2
answers
23k
views
matplotlib: Plot numpy arrays with None as values
I have an array that looks like:
k = numpy.array([(1.,0.001), (1.1, 0.002), (None, None),
(1.2, 0.003), (0.99, 0.004)])
I want to plot the values that are not (None, None) and keep ...
7
votes
1
answer
4k
views
Plotting discrete colorbar in legend style using Matplotlib
Sometimes, I want to plot discrete value in pcolormesh style.
For example, to represent a 2-d array in the shape of 100x100 which contain int 0~7
data = np.random.randint(8, size=(100,100))
cmap =...
7
votes
1
answer
5k
views
How to coarser the 2-d array data resolution
I have a similar question here
That question is about resemble the tiff data, and I want to find a more universal way to deal with it.
My question
For example:
A 2-d numpy array with the ...