0
I’m trying to generate a histogram in Django for a project I developed. The code usually generates the histogram without difficulties in the first attempt, however, when I try again, it returns me the following error:
Runtimeerror: main thread is not in main loop.
How can I correct this mistake? Follow the code below:
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})
						
what library you are using to generate the charts?
– Vinicius Mesel
I’m using the mathplotlib
– Luiz Júnior