[Python] show a data point on boxplot of pandas dataframe

Discussão em 'Python' iniciado por Stack, Outubro 24, 2024.

  1. Stack

    Stack Membro Participativo

    I'm simulating the results of a paper and need to show a data point on boxplot of a pandas dataframe. the image of the corresponding paper is like this:

    [​IMG]

    i tried to plot the boxplot using df.boxplot , and the scatter plot with plt.scatter. but the result is wrong. It seems that the scatter plot is shifted one block to the left! how can I fix this issue?

    df_encoded.boxplot(column = columns, rot=90, fontsize=15)
    newdata = pd.DataFrame(ndarrX_train[0].reshape(1,-1), columns = columns)
    plt.scatter(columns, newdata, c='r')


    [​IMG]

    My data is different from the paper's data. To plot one datapoint, I created a data frame with one row.

    Continue reading...

Compartilhe esta Página