1

I need to visualize the folowing function (correlation function) that uses matplotlib in the Flask front end.

def correlation(dataframe):
    correlation_matrix = dataframe.corr()
    axes_heatmap = plt.axes()
    sns.heatmap(correlation_matrix, ax = axes_heatmap)
    axes_heatmap.set_title('Correlation Matrix')
    plt.plot(sns)
    visualization(dataframe,highest_correlated_list) #A list of some features will be given so that they will be visualized in scatter plot. 
    return 'visualized successfully'

def visualization(dataframe,dataframe_list):
    try:
        for i in range(len(dataframe_list)):
            x = dataframe_list[i][0]
            y = dataframe_list[i][1]
            plotdata = sns.pairplot(dataframe, x_vars = [x], y_vars = [y])
            title = str(x) +' VS ' + str(y)
            plotdata.fig.suptitle(title, y = 1)
            plt.show()
    except:
        dataframe.plot()

Is there any way in Flask python front end to show the images from the above function? If so, could anyone help me out here? I checked some answers in stack overflow but I cannot achieve my requirement.

Vishnu
  • 65
  • 7
  • Flask runs on a server so the matplotlib window will be displayed (or at least try to do so) on the server which is not valid because the user does not have access to that image. What you have to do is convert the canvas to an image as the answer to the duplicate question shows – eyllanesc Mar 07 '20 at 23:55

0 Answers0