[Python] How can I make my axes visible with matplotlib?

Discussão em 'Python' iniciado por Stack, Março 15, 2025.

  1. Stack

    Stack Membro Participativo

    I am using matplotlib.pyplot to plot some graphs and for some reasons I can't see the lines of the axes, although I can see the xticks and yticks. Important to note that I am using python notebook, and usually I try to visualize my graphs with the function (%matplotlib inline)

    Here is an example figure that I get (without the axes):

    [​IMG]

    Here is the code I used to produce this figure:

    fig, ax = plt.subplots(1,1, figsize=(7.5,6), sharey=False, sharex=False, edgecolor='k', frameon=True)
    ax.plot(np.array(frequency_vec), before_LTP, 'b-o', label='Before');
    ax.plot(np.array(frequency_vec), After_LTP, 'r-o', label='After');
    plt.yticks([1,2,3,4,5,6,7,8], ['1','2','3','4','5','6','7','0'], fontsize=14)
    plt.xticks(fontsize=14)
    plt.rcParams['axes.edgecolor']='k'
    ax.patch.set_visible(False)
    ax.grid(False)
    ax.set_frame_on(True)
    ax.set_xlim(0, 110)
    ax.set_ylim(1,(Number_of_pulses)+2)
    ax.legend(loc='best', fontsize=15)
    plt.xticks([12.5,25,50,75,100], ['12.5','25','50','75','100']);


    So again - How can I make my axes-lines to be visible?

    Thanks!

    Continue reading...

Compartilhe esta Página