docs: def plot_populations(path, name, Ne, states=None, filename='a.png',
                       fontsize=12, absolute_frequency=True,
                       save_path='', use_netcdf=True):
      r"""Plot the populations of a density matrix."""
      pyplot.close("all")
      dat = read_result(path, name, N=Ne, use_netcdf=use_netcdf)
      x = dat[0]
      if absolute_frequency:
          x = [xi/2/pi for xi in x]
      pop = dat[1:Ne]
      Nd = len(pop[0])
  
      pop1 = [1-sum([pop[j][i] for j in range(Ne-1)]) for i in range(Nd)]
      pop = [pop1]+pop
  
      # We do different things depending on what states we are given.
      if states is None:
          # If we recieve no states all populations are ploted.
          for i in range(Ne):
              lab = r"$\mathrm{Poblaci\'on} \ " + str(i+1)+"$"
              pyplot.plot(x, pop[i], label=lab)
          pyplot.legend(fontsize=fontsize)
          pyplot.savefig(save_path+filename, bbox_inches='tight')
          pyplot.close('all')
  
      elif len(states[0].quantum_numbers) >= 5:
          # If we recieve magnetic states we make a plot
          # for each hyperfine state.
          magnetic_plots = len(states[0].quantum_numbers) == 6
  
          if not magnetic_plots:
              N_plots = len(states)
              states = split_hyperfine_to_magnetic(states)
              aux = [hsv_to_rgb(m*0.8/(N_plots-1), 1.0, 1.0)
                     for m in range(N_plots)]
              hyperfine_colors = list(reversed(aux))
              conta = 0
  
          fine_states = find_fine_states(states)
          boundaries = reversed(calculate_boundaries(fine_states, states)[1])
          boundaries = list(boundaries)
  
          for pair in boundaries:
              f = states[pair[0]].f
              if f == 0:
                  colors = [(0.8, 0.0, 1.0)]
              else:
                  aux = [hsv_to_rgb(m*0.8/f, 1.0, 1.0) for m in range(f+1)]
                  colors = list(reversed(aux))
  
              for i in range(pair[0], pair[1]):
                  m = states[i].m
                  if m < 0:
                      color = colors[-m]
                      style = ':'
                  else:
                      color = colors[m]
                      style = '-'
                  if magnetic_plots:
                      aux = r"$\mathrm{Poblaci\'on} \ M_F="
                      aux += str(states[i].m)+"$"
                      pyplot.plot(x, pop[i], style, label=aux, color=color)
  
              if magnetic_plots:
                  if f != 0:
                      suma = [sum([pop[i][j] for i in range(pair[0], pair[1])])
                              for j in range(len(pop[0]))]
                      pyplot.plot(x, suma, 'k-', label=r'$\mathrm{suma}$')
  
                  aux = str(states[i]).split()[1].replace('_', '')
                  filenamei = aux.replace('/', '_').replace('^', 'F=')
                  s = filenamei.find(',')
                  filenamei = filenamei[:s]
                  filenamei = name+'_'+filenamei+'.png'
  
                  aux = find_fine_states([states[i]])[0]
                  title = aux._latex_()+'\ F='+str(states[i].f)
  
                  pyplot.title(r"$"+title+"$")
                  pyplot.ylim([0, None])
                  pyplot.xlim([x[0], x[-1]])
                  pyplot.legend(fontsize=fontsize, loc=0)
  
                  pyplot.savefig(save_path+filenamei, bbox_inches='tight')
                  pyplot.close('all')
              else:
                  suma = [sum([pop[i][j] for i in range(pair[0], pair[1])])
                          for j in range(len(pop[0]))]
                  label = states[i]._latex_()
                  label = label[label.find(' ')+1:]
                  label = label[:label.find('^')]
                  label += r"\ F="+str(states[i].f)
                  label = "$"+label+"$"
  
                  pyplot.plot(x, suma, '-', color=hyperfine_colors[conta],
                              label=label)
                  conta += 1
  
          if not magnetic_plots:
              title = states[0]._latex_()
              title = "$"+title[:title.find(' ')-1]+"$"
              pyplot.title(title, fontsize=20)
              pyplot.xlim([x[0], x[-1]])
              pyplot.legend(fontsize=fontsize, loc=0)
              pyplot.savefig(save_path+name+'_pops.png', bbox_inches='tight')
              pyplot.close('all')