{
  "id": 208798,
  "title": "Different colormaps for same values in a spectrogram",
  "url": "/competitions/rfcx-species-audio-detection/discussion/208798",
  "author_name": "",
  "post_date": "2021-01-05T04:22:31.931887400Z",
  "votes": null,
  "comment_count": 4,
  "views": 0,
  "content": "<p>So I was doing some EDA and plotted some spectrograms for the same. I found that when I generated spectrograms for a single species_id (1 to be specific). Some spectrograms were darker while some were lighter. Although the color had same values. Can someone tell me why this may be.<br>\n<img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F1604765%2F5143b1261cdf7856b24a52668b9db9e2%2FScreenshot%20from%202021-01-05%2009-46-56.png?generation=1609820542189978&amp;alt=media\" alt=\"\"></p>",
  "messages": [
    {
      "id": "1138937",
      "postDate": "01/05/2021 04:22:31",
      "content": "<p>So I was doing some EDA and plotted some spectrograms for the same. I found that when I generated spectrograms for a single species_id (1 to be specific). Some spectrograms were darker while some were lighter. Although the color had same values. Can someone tell me why this may be.<br>\n<img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F1604765%2F5143b1261cdf7856b24a52668b9db9e2%2FScreenshot%20from%202021-01-05%2009-46-56.png?generation=1609820542189978&amp;alt=media\" alt=\"\"></p>",
      "rawMarkdown": "So I was doing some EDA and plotted some spectrograms for the same. I found that when I generated spectrograms for a single species_id (1 to be specific). Some spectrograms were darker while some were lighter. Although the color had same values. Can someone tell me why this may be.\n![](https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F1604765%2F5143b1261cdf7856b24a52668b9db9e2%2FScreenshot%20from%202021-01-05%2009-46-56.png?generation=1609820542189978&alt=media)",
      "votes": null
    },
    {
      "id": "1140038",
      "postDate": "01/05/2021 19:02:15",
      "content": "<p>Hi, <a href=\"https://www.kaggle.com/aryaman1999\" target=\"_blank\">@aryaman1999</a>,<br>\nIt is convenient to use an Audio gadget in notebook to just listen to the sound. Recordings vary in background sound a lot.</p>\n<pre><code>from IPython.display import Audio,display\nwav, sr = librosa.load(f'../data/rfcx-species-audio-detection/train/003bec244.flac')\ndisplay(Audio(wav,rate=sr))\n</code></pre>",
      "rawMarkdown": "Hi, @aryaman1999,\nIt is convenient to use an Audio gadget in notebook to just listen to the sound. Recordings vary in background sound a lot.\n```\nfrom IPython.display import Audio,display\nwav, sr = librosa.load(f'../data/rfcx-species-audio-detection/train/003bec244.flac')\ndisplay(Audio(wav,rate=sr))\n```",
      "votes": null
    },
    {
      "id": "1145367",
      "postDate": "01/09/2021 05:03:34",
      "content": "<p>Hey <a href=\"https://www.kaggle.com/barnwellguy\" target=\"_blank\">@barnwellguy</a> thanks alot for the reply. While that is sure the case, my doubt is that the scale of y axis and the colorbar values seem to be the same. Only the colormap has changed. Why is that the case. If there is a change in frequency one of these two should be different right?</p>",
      "rawMarkdown": "Hey @barnwellguy thanks alot for the reply. While that is sure the case, my doubt is that the scale of y axis and the colorbar values seem to be the same. Only the colormap has changed. Why is that the case. If there is a change in frequency one of these two should be different right?",
      "votes": null
    },
    {
      "id": "1154406",
      "postDate": "01/15/2021 16:09:37",
      "content": "<p><a href=\"https://www.kaggle.com/aryaman1999\" target=\"_blank\">@aryaman1999</a> spectogram is for the whole 1 minute while the annotation could be for a second or 2. If we clip the annotation perhapes the spectograms would be much more similar?</p>",
      "rawMarkdown": "aryaman1999 spectogram is for the whole 1 minute while the annotation could be for a second or 2. If we clip the annotation perhapes the spectograms would be much more similar?",
      "votes": null
    },
    {
      "id": "1163911",
      "postDate": "01/22/2021 03:43:12",
      "content": "<p>Hi, <a href=\"https://www.kaggle.com/aryaman1999\" target=\"_blank\">@aryaman1999</a> , sorry for seeing your message 2 weeks after you wrote it :)<br>\nI guess most likely you have figured out by yourself already. <br>\nPerhaps what I say below is too straightforward. FWIW, anyways.</p>\n<p>The y axis measures frequency, the color bar measures the power (I think roughly speaking, loudness).<br>\nThey are independent from each other.</p>\n<p>It seems you are using <code>librosa</code> to make the plot, so, there is perhaps some level of processing that is hidden, which confuses people. After </p>\n<pre><code>s = librosa.feature.melspectrogram(y=wav,\n                                   n_mels=n_mels,\n                                   sr=sr,\n                                   n_fft=n_fft,\n                                   hop_length=hop,\n                                   win_length=None,\n                                   window='hann',\n                                   center=True,\n                                   pad_mode='reflect',\n                                   power=2.0,\n                                   fmin=fmin,\n                                   fmax=fmax)\np = librosa.power_to_db(s).astype(np.float32)\n</code></pre>\n<p>You can make plot your self, </p>\n<pre><code>plt.imshow(p,origin='lower',cmap=cm.jet)\n</code></pre>",
      "rawMarkdown": "Hi, @aryaman1999 , sorry for seeing your message 2 weeks after you wrote it :)\nI guess most likely you have figured out by yourself already. \nPerhaps what I say below is too straightforward. FWIW, anyways.\n\nThe y axis measures frequency, the color bar measures the power (I think roughly speaking, loudness).\nThey are independent from each other.\n\nIt seems you are using `librosa` to make the plot, so, there is perhaps some level of processing that is hidden, which confuses people. After \n```\ns = librosa.feature.melspectrogram(y=wav,\n                                   n_mels=n_mels,\n                                   sr=sr,\n                                   n_fft=n_fft,\n                                   hop_length=hop,\n                                   win_length=None,\n                                   window='hann',\n                                   center=True,\n                                   pad_mode='reflect',\n                                   power=2.0,\n                                   fmin=fmin,\n                                   fmax=fmax)\np = librosa.power_to_db(s).astype(np.float32)\n```\nYou can make plot your self, \n```\nplt.imshow(p,origin='lower',cmap=cm.jet)\n```",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 1140038,
      "author_name": "barnwellguy",
      "author_url": "",
      "post_date": "01/05/2021 19:02:15",
      "content": "<p>Hi, <a href=\"https://www.kaggle.com/aryaman1999\" target=\"_blank\">@aryaman1999</a>,<br>\nIt is convenient to use an Audio gadget in notebook to just listen to the sound. Recordings vary in background sound a lot.</p>\n<pre><code>from IPython.display import Audio,display\nwav, sr = librosa.load(f'../data/rfcx-species-audio-detection/train/003bec244.flac')\ndisplay(Audio(wav,rate=sr))\n</code></pre>",
      "votes": null,
      "replies": [
        {
          "id": 1145367,
          "author_name": "aryaman1999",
          "author_url": "",
          "post_date": "01/09/2021 05:03:34",
          "content": "<p>Hey <a href=\"https://www.kaggle.com/barnwellguy\" target=\"_blank\">@barnwellguy</a> thanks alot for the reply. While that is sure the case, my doubt is that the scale of y axis and the colorbar values seem to be the same. Only the colormap has changed. Why is that the case. If there is a change in frequency one of these two should be different right?</p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 1154406,
          "author_name": "allohvk",
          "author_url": "",
          "post_date": "01/15/2021 16:09:37",
          "content": "<p><a href=\"https://www.kaggle.com/aryaman1999\" target=\"_blank\">@aryaman1999</a> spectogram is for the whole 1 minute while the annotation could be for a second or 2. If we clip the annotation perhapes the spectograms would be much more similar?</p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 1163911,
          "author_name": "barnwellguy",
          "author_url": "",
          "post_date": "01/22/2021 03:43:12",
          "content": "<p>Hi, <a href=\"https://www.kaggle.com/aryaman1999\" target=\"_blank\">@aryaman1999</a> , sorry for seeing your message 2 weeks after you wrote it :)<br>\nI guess most likely you have figured out by yourself already. <br>\nPerhaps what I say below is too straightforward. FWIW, anyways.</p>\n<p>The y axis measures frequency, the color bar measures the power (I think roughly speaking, loudness).<br>\nThey are independent from each other.</p>\n<p>It seems you are using <code>librosa</code> to make the plot, so, there is perhaps some level of processing that is hidden, which confuses people. After </p>\n<pre><code>s = librosa.feature.melspectrogram(y=wav,\n                                   n_mels=n_mels,\n                                   sr=sr,\n                                   n_fft=n_fft,\n                                   hop_length=hop,\n                                   win_length=None,\n                                   window='hann',\n                                   center=True,\n                                   pad_mode='reflect',\n                                   power=2.0,\n                                   fmin=fmin,\n                                   fmax=fmax)\np = librosa.power_to_db(s).astype(np.float32)\n</code></pre>\n<p>You can make plot your self, </p>\n<pre><code>plt.imshow(p,origin='lower',cmap=cm.jet)\n</code></pre>",
          "votes": null,
          "replies": []
        }
      ]
    }
  ],
  "raw_markdown_by_id": {
    "1138937": "So I was doing some EDA and plotted some spectrograms for the same. I found that when I generated spectrograms for a single species_id (1 to be specific). Some spectrograms were darker while some were lighter. Although the color had same values. Can someone tell me why this may be.\n![](https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F1604765%2F5143b1261cdf7856b24a52668b9db9e2%2FScreenshot%20from%202021-01-05%2009-46-56.png?generation=1609820542189978&alt=media)",
    "1140038": "Hi, @aryaman1999,\nIt is convenient to use an Audio gadget in notebook to just listen to the sound. Recordings vary in background sound a lot.\n```\nfrom IPython.display import Audio,display\nwav, sr = librosa.load(f'../data/rfcx-species-audio-detection/train/003bec244.flac')\ndisplay(Audio(wav,rate=sr))\n```",
    "1145367": "Hey @barnwellguy thanks alot for the reply. While that is sure the case, my doubt is that the scale of y axis and the colorbar values seem to be the same. Only the colormap has changed. Why is that the case. If there is a change in frequency one of these two should be different right?",
    "1154406": "aryaman1999 spectogram is for the whole 1 minute while the annotation could be for a second or 2. If we clip the annotation perhapes the spectograms would be much more similar?",
    "1163911": "Hi, @aryaman1999 , sorry for seeing your message 2 weeks after you wrote it :)\nI guess most likely you have figured out by yourself already. \nPerhaps what I say below is too straightforward. FWIW, anyways.\n\nThe y axis measures frequency, the color bar measures the power (I think roughly speaking, loudness).\nThey are independent from each other.\n\nIt seems you are using `librosa` to make the plot, so, there is perhaps some level of processing that is hidden, which confuses people. After \n```\ns = librosa.feature.melspectrogram(y=wav,\n                                   n_mels=n_mels,\n                                   sr=sr,\n                                   n_fft=n_fft,\n                                   hop_length=hop,\n                                   win_length=None,\n                                   window='hann',\n                                   center=True,\n                                   pad_mode='reflect',\n                                   power=2.0,\n                                   fmin=fmin,\n                                   fmax=fmax)\np = librosa.power_to_db(s).astype(np.float32)\n```\nYou can make plot your self, \n```\nplt.imshow(p,origin='lower',cmap=cm.jet)\n```"
  },
  "source": "meta"
}