Generate histogram in django

0

Hello, I've been trying to generate a histogram in django for a project I'm developing. The code usually generates the histogram without difficulty the first time, however, when I try again, it returns me the following error "RuntimeError: main thread is not in main loop" . How can I correct this error? Below are images of the code.

def gerador_de_histograma():
    y_axis = definir_valores_das_classes_histograma()
    x_axis = range(len(limite_corte_entre_classes))
    width_n = 0.8
    bar_color = 'green'

    bar = plt.bar(x_axis, y_axis, width=width_n, color=bar_color, align="center", linewidth=10)
    plt.xticks(x_axis, gerador_de_nomes_para_labels(limite_corte_entre_classes))
    return plt
    # plt.show()
    # plt.save("histograma.png")



def show_histogram(request):
    histogram = gerador_de_histograma()
    return render(request, 'city/histogram.html',{'histogram': histogram})
    
asked by anonymous 04.06.2018 / 16:09

0 answers