Contour/imshow plot for irregular X Y Z data

Does plt.tricontourf(x,y,z) satisfy your requirements? It will plot filled contours for irregularly spaced data (non-rectilinear grid). You might also want to look into plt.tripcolor(). import numpy as np import matplotlib.pyplot as plt x = np.random.rand(100) y = np.random.rand(100) z = np.sin(x)+np.cos(y) f, ax = plt.subplots(1,2, sharex=True, sharey=True) ax[0].tripcolor(x,y,z) ax[1].tricontourf(x,y,z, 20) # choose 20 contour levels, … Read more

Matplotlib – sequence is off when using plt.imshow()

It seems you are using Juypter notebook. This always shows any autogenerated output (like the matplotlib figures) last in the output. You may use IPython.display.display to display the figures at the position of the output where they belong. import matplotlib.pyplot as plt import numpy as np from IPython.display import display images = [np.random.rayleigh((i+1)/8., size=(180, 200, … Read more

update frame in matplotlib with live camera preview

Interactive mode One way of updating a plot in matplotlib is to use interactive mode (plt.ion()). You should then not recreate new subplots for each frame you capture, but create your plot with images once and update it afterwards. import cv2 import matplotlib.pyplot as plt def grab_frame(cap): ret,frame = cap.read() return cv2.cvtColor(frame,cv2.COLOR_BGR2RGB) #Initiate the two … Read more