I am using the EMD package for R. This package has a spectrogram function for displaying a Hilbert Spectr开发者_如何学Cum (calculated with hilbertspec). The output however, is really vague and black-white.
This function does not seem to have an option for outputting color images. How can I get the spectrum displayed clearly and if possible in color.
The gray levels are hardcoded in the spectrogram
function (gray()
), to override this setting you could use, for instance, the following:
# define a color palette
colors <- colorRampPalette(c("#007FFF", "blue", "#000077"))
gray <- function(x) colors(255*x) # redefine gray palette
spectrogram(test1$amplitude[,1], test1$instantfreq[,1])
gray <- grDevices::gray # reset gray palette function
Another option is to use the source of the spectrogram
function to define your own plot function which has an argument for the color palette.
精彩评论