nodes: 0, module; 1, function_definition; 2, function_name:_plot_spectrogram; 3, parameters; 4, block; 5, identifier:G; 6, identifier:node_idx; 7, expression_statement; 8, import_from_statement; 9, expression_statement; 10, if_statement; 11, expression_statement; 12, expression_statement; 13, expression_statement; 14, expression_statement; 15, expression_statement; 16, expression_statement; 17, expression_statement; 18, expression_statement; 19, expression_statement; 20, expression_statement; 21, expression_statement; 22, expression_statement; 23, expression_statement; 24, expression_statement; 25, expression_statement; 26, expression_statement; 27, global_statement; 28, expression_statement; 29, comment:r"""Plot the graph's spectrogram.
  
      Parameters
      ----------
      node_idx : ndarray
          Order to sort the nodes in the spectrogram.
          By default, does not reorder the nodes.
  
      Notes
      -----
      This function is only implemented for the pyqtgraph backend at the moment.
  
      Examples
      --------
      >>> G = graphs.Ring(15)
      >>> G.plot_spectrogram()
  
      """; 30, dotted_name; 31, dotted_name; 32, assignment; 33, not_operator; 34, block; 35, assignment; 36, assignment; 37, assignment; 38, assignment; 39, assignment; 40, assignment; 41, assignment; 42, assignment; 43, assignment; 44, assignment; 45, call; 46, assignment; 47, assignment; 48, call; 49, assignment; 50, call; 51, identifier:_qtg_windows; 52, call; 53, identifier:pygsp; 54, identifier:features; 55, pattern_list; 56, call; 57, call; 58, expression_statement; 59, identifier:M; 60, subscript; 61, identifier:spectr; 62, conditional_expression:G.spectr[node_idx, :] if node_idx is not None else G.spectr; 63, identifier:spectr; 64, call; 65, pattern_list; 66, expression_list; 67, identifier:pos; 68, call; 69, identifier:color; 70, list; 71, identifier:color; 72, call; 73, identifier:cmap; 74, call; 75, identifier:spectr; 76, binary_operator:(spectr.astype(float) - min_spec) / (max_spec - min_spec); 77, identifier:w; 78, call; 79, attribute; 80, argument_list; 81, identifier:label; 82, call; 83, identifier:v; 84, call; 85, attribute; 86, argument_list; 87, identifier:spi; 88, call; 89, attribute; 90, argument_list; 91, attribute; 92, argument_list; 93, identifier:qtg; 94, identifier:_; 95, identifier:_; 96, identifier:_import_qtg; 97, argument_list; 98, identifier:hasattr; 99, argument_list; 100, call; 101, attribute; 102, integer:1; 103, subscript; 104, comparison_operator:node_idx is not None; 105, attribute; 106, attribute; 107, argument_list; 108, identifier:min_spec; 109, identifier:max_spec; 110, call; 111, call; 112, attribute; 113, argument_list; 114, list; 115, list; 116, list; 117, list; 118, list; 119, attribute; 120, argument_list; 121, attribute; 122, argument_list; 123, parenthesized_expression; 124, parenthesized_expression; 125, attribute; 126, argument_list; 127, identifier:w; 128, identifier:setWindowTitle; 129, call; 130, attribute; 131, argument_list; 132, attribute; 133, argument_list; 134, identifier:v; 135, identifier:setAspectLocked; 136, attribute; 137, argument_list; 138, identifier:v; 139, identifier:addItem; 140, identifier:spi; 141, identifier:_qtg_windows; 142, identifier:append; 143, identifier:w; 144, identifier:G; 145, string; 146, attribute; 147, argument_list; 148, attribute; 149, identifier:shape; 150, attribute; 151, identifier:node_idx; 152, slice; 153, identifier:node_idx; 154, None; 155, identifier:G; 156, identifier:spectr; 157, identifier:np; 158, identifier:ravel; 159, identifier:spectr; 160, attribute; 161, argument_list; 162, attribute; 163, argument_list; 164, identifier:np; 165, identifier:array; 166, list; 167, integer:20; 168, integer:133; 169, integer:212; 170, integer:255; 171, integer:53; 172, integer:42; 173, integer:135; 174, integer:255; 175, integer:48; 176, integer:174; 177, integer:170; 178, integer:255; 179, integer:210; 180, integer:184; 181, integer:87; 182, integer:255; 183, integer:249; 184, integer:251; 185, integer:14; 186, integer:255; 187, identifier:np; 188, identifier:array; 189, identifier:color; 190, keyword_argument; 191, identifier:qtg; 192, identifier:ColorMap; 193, identifier:pos; 194, identifier:color; 195, binary_operator:spectr.astype(float) - min_spec; 196, binary_operator:max_spec - min_spec; 197, identifier:qtg; 198, identifier:GraphicsWindow; 199, attribute; 200, argument_list; 201, string; 202, identifier:format; 203, integer:0; 204, binary_operator:G.lmax/M; 205, attribute; 206, identifier:w; 207, identifier:addPlot; 208, keyword_argument; 209, identifier:qtg; 210, identifier:ScatterPlotItem; 211, call; 212, call; 213, keyword_argument; 214, keyword_argument; 215, keyword_argument; 216, keyword_argument; 217, string_content:spectr; 218, identifier:features; 219, identifier:compute_spectrogram; 220, identifier:G; 221, identifier:G; 222, identifier:spectr; 223, identifier:G; 224, identifier:spectr; 225, identifier:spectr; 226, identifier:min; 227, identifier:spectr; 228, identifier:max; 229, float:0.; 230, float:0.25; 231, float:0.5; 232, float:0.75; 233, float:1.; 234, identifier:dtype; 235, attribute; 236, call; 237, identifier:min_spec; 238, identifier:max_spec; 239, identifier:min_spec; 240, string:"Spectrogram of {}"; 241, identifier:format; 242, call; 243, string_content:frequencies {}:{:.2f}:{:.2f}; 244, attribute; 245, identifier:M; 246, identifier:G; 247, identifier:lmax; 248, identifier:labels; 249, dictionary; 250, attribute; 251, argument_list; 252, attribute; 253, argument_list; 254, identifier:pxMode; 255, False; 256, identifier:symbol; 257, string; 258, identifier:size; 259, integer:1; 260, identifier:brush; 261, call; 262, identifier:np; 263, identifier:ubyte; 264, attribute; 265, argument_list; 266, attribute; 267, argument_list; 268, identifier:G; 269, identifier:lmax; 270, pair; 271, pair; 272, identifier:np; 273, identifier:repeat; 274, call; 275, identifier:M; 276, identifier:np; 277, identifier:ravel; 278, call; 279, string_content:s; 280, attribute; 281, argument_list; 282, identifier:spectr; 283, identifier:astype; 284, identifier:float; 285, identifier:G; 286, identifier:__repr__; 287, keyword_argument; 288, string; 289, string; 290, string; 291, identifier:label; 292, attribute; 293, argument_list; 294, attribute; 295, argument_list; 296, identifier:cmap; 297, identifier:map; 298, identifier:spectr; 299, string; 300, identifier:limit; 301, integer:4; 302, string_content:bottom; 303, string_content:nodes; 304, string_content:left; 305, identifier:np; 306, identifier:arange; 307, attribute; 308, identifier:np; 309, identifier:tile; 310, call; 311, tuple; 312, string_content:qcolor; 313, identifier:G; 314, identifier:N; 315, attribute; 316, argument_list; 317, integer:1; 318, attribute; 319, identifier:np; 320, identifier:arange; 321, identifier:M; 322, identifier:G; 323, identifier:N
code: def _plot_spectrogram(G, node_idx):
      r"""Plot the graph's spectrogram.
  
      Parameters
      ----------
      node_idx : ndarray
          Order to sort the nodes in the spectrogram.
          By default, does not reorder the nodes.
  
      Notes
      -----
      This function is only implemented for the pyqtgraph backend at the moment.
  
      Examples
      --------
      >>> G = graphs.Ring(15)
      >>> G.plot_spectrogram()
  
      """
      from pygsp import features
  
      qtg, _, _ = _import_qtg()
  
      if not hasattr(G, 'spectr'):
          features.compute_spectrogram(G)
  
      M = G.spectr.shape[1]
      spectr = G.spectr[node_idx, :] if node_idx is not None else G.spectr
      spectr = np.ravel(spectr)
      min_spec, max_spec = spectr.min(), spectr.max()
  
      pos = np.array([0., 0.25, 0.5, 0.75, 1.])
      color = [[20, 133, 212, 255], [53, 42, 135, 255], [48, 174, 170, 255],
               [210, 184, 87, 255], [249, 251, 14, 255]]
      color = np.array(color, dtype=np.ubyte)
      cmap = qtg.ColorMap(pos, color)
  
      spectr = (spectr.astype(float) - min_spec) / (max_spec - min_spec)
  
      w = qtg.GraphicsWindow()
      w.setWindowTitle("Spectrogram of {}".format(G.__repr__(limit=4)))
      label = 'frequencies {}:{:.2f}:{:.2f}'.format(0, G.lmax/M, G.lmax)
      v = w.addPlot(labels={'bottom': 'nodes',
                            'left': label})
      v.setAspectLocked()
  
      spi = qtg.ScatterPlotItem(np.repeat(np.arange(G.N), M),
                                np.ravel(np.tile(np.arange(M), (1, G.N))),
                                pxMode=False,
                                symbol='s',
                                size=1,
                                brush=cmap.map(spectr, 'qcolor'))
      v.addItem(spi)
  
      global _qtg_windows
      _qtg_windows.append(w)