[Matplotlib-users] Bizarre clipping of title when markers used

Neal Becker ndbecker2 at gmail.com
Fri Jun 8 08:01:51 EDT 2018


I haven't been able to reproduce yet in a minimal example, but in this
code, if markers are used in the plot, then the title is clipped off and
not shown.  If the markers= is commented out, then the title is fine.  I
know it's clipped, because if I specify
set_title ('blah', y=0.5) < set y to something < .95
Then the title is displayed (but in the wrong position).

So, if markers are present, title is clipped off.  No markers, title is
fine.

My code is here (you can't run it I'm afraid):

matplotlib=2.2.2

import pandas as pd

def do_plot(other_csv, mine_xlsx, name):
    df_tdla_96 = pd.read_csv (other_csv)
    df_tdla_96_mine = pd.read_excel (mine_xlsx)
    df_tdla_96_mine = df_tdla_96_mine[['esno_corrected', 'per']]
    df_tdla_96_mine.rename (index=str, columns={'esno_corrected' : 'SNR',
'per' : 'Hughes'}, inplace=True)
    df_tdla_96.drop(labels='Hughes', inplace=True, axis=1)
    df_tdla_96_merge = pd.merge(left=df_tdla_96, right=df_tdla_96_mine,
on='SNR')
    from matplotlib.lines import Line2D
    from itertools import cycle
    m_cycle = cycle(Line2D.filled_markers)
    import matplotlib.pyplot as plt
    fig, ax = plt.subplots()#, sharex=True)
    for company  in df_tdla_96_merge.columns[1:]:
        df = df_tdla_96_merge[['SNR', company]]
        ax.semilogy(df['SNR'], df[company], marker='x')
    ax.set_title('Simple plot')
    #ax.set_title('blah', fontsize=12, y=0.95)
    # ax.set_xlabel('SNR')
    # ax.set_ylabel('BLER')
    # ax.legend(loc='best')
    #fig.suptitle('blah', fontsize=12, x=0.5, y=0.9)
    ax.grid()
    #plt.tight_layout()
    plt.show()

    #plt.tight_layout()
    #plt.savefig('tdla_96.pdf')

do_plot('tdla_96_other.csv', 'tdla_96_mrc_wiener.xlsx', 'TDLA 96 CP-OFDM')
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/matplotlib-users/attachments/20180608/8498c94a/attachment.html>


More information about the Matplotlib-users mailing list