I seem to have some problems storing a plot created using matplotlib.pcolormesh()
. As far i know is pcolormesh
convert an input data matrix using a colormap. The colormap outputs a RGB value for each entry in the matrix and plots it.
Which in my head would be similar to
import numpy as np
import matplotlib.pyplot as plt
import matplotlib
from PIL import Image
import librosa
import librosa.display
from matplotlib import cm
fig = plt.figure(figsize=(12,4))
min = -1.828067
max = 22.70058
data = np.random.uniform(low=min, high=max, size=(474,40))
librosa.display.specshow(data.T,sr=16000,x_axis='frames',y_axis='mel',hop_length=160,cmap=cm.jet)
plt.axis('off')
plt.show()
raw_input("sadas")
convert = plt.get_cmap(cm.jet)
norm = matplotlib.colors.Normalize(vmin=0,vmax=1)
numpy_output_static = convert(norm(data.T))
plt.imshow(numpy_output_static,cmap = cm.jet, aspect = 'auto')
plt.show()
raw_input("asds")
Problem here is that the numpy array of the data being represented as a plot, is not similar to what the first plot shows. I need the numpy to have data that represents the plot, such that if I wanted to plot it, I would get an identical image as the first one, and the shape of the numpy array should be similar to the input data which was used in plot 1.
The numpy is being fed to a neural network, for detecting patterns which means that representation is important here.
So how do I make it store the actual plot, without all the red things..
And if this is not possible in matplotlib
what other library would it be possible to do it in.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…