How to darken spectrograms for a figure

58 views
Skip to first unread message

Benjamin Colbert

unread,
Jan 17, 2023, 12:14:31 PM1/17/23
to seewave
I have the attached spectogram created using the code below. I want the signals to be much darker while keeping background as white. How can I do that? I will be getting rid of the amplitude label - that info isn't useful for what I am trying to display.

spec<- spectro(wav, f=f, ovlp=75, zp=16, wl = 1024, collevels=seq(-40,0,0.5), flim=c(.1,.8),palette=reverse.gray.colors.2)00000f.png

Jérôme SUEUR

unread,
Jan 18, 2023, 5:08:20 AM1/18/23
to seewave GROUP
Dear Benjamin,

The gray palettes, 'reverse.gray.colors.1' and 'reverse.gray.colors.2', are based on the function gray().

The code for 'reverse.gray.colors.1' is 
reverse.gray.colors.1 <- function (x) gray(seq(from = 1^1.7, to = 0, length = x)^(1/1.7))

You could then adapt it to you own needs by changing the scaling factor (here 1.7), for instance setting a lower value should give more importance to high part of the scale, like
reverse.gray.colors.3 <- function (x) gray(seq(from = 1^0.5, to = 0, length = x)^(1/0.5))

For a comparison:
library(seewave)
data(tico)
reverse.gray.colors.3 <- function (x) gray(seq(from = 1^0.5, to = 0, length = x)^(1/0.5))
par(mfrow=c(2,1))
spectro(tico, palette=reverse.gray.colors.1, scale=FALSE)
spectro(tico, palette=reverse.gray.colors.3, scale=FALSE)

Another possibility might to use the function choose_palette() of the package colorspace. This is a nice GUI to play with.

HTH,

Jerome

NB: when posting a request you might say "hello", "thank you" or other kind words, it is always welcome for those who spend time to try to help ;-)


De: "Benjamin Colbert" <bcol...@umces.edu>
À: "seewave GROUP" <see...@googlegroups.com>
Envoyé: Mardi 17 Janvier 2023 18:14:31
Objet: [seewave] How to darken spectrograms for a figure

I have the attached spectogram created using the code below. I want the signals to be much darker while keeping background as white. How can I do that? I will be getting rid of the amplitude label - that info isn't useful for what I am trying to display.
spec<- spectro(wav, f=f, ovlp=75, zp=16, wl = 1024, collevels=seq(-40,0,0.5), flim=c(.1,.8),palette=reverse.gray.colors.2)00000f.png


--
You received this message because you are subscribed to the Google Groups "seewave" group.
To unsubscribe from this group and stop receiving emails from it, send an email to seewave+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/seewave/be36c013-34a1-4b9f-9b2e-d385fd619ff4n%40googlegroups.com.

Reply all
Reply to author
Forward
0 new messages