Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Label formatting issue #491

Open
schaefes opened this issue Apr 22, 2024 · 0 comments
Open

Label formatting issue #491

schaefes opened this issue Apr 22, 2024 · 0 comments

Comments

@schaefes
Copy link

Hello,
I experienced a weird formatting of the llable next to the CMS logo. It creates a vertical offset of the llabel relative to the CMS logo. I have played around with different parameters like loc, fontsize, pad, but none fixed the issue. In fact the addition of a fondsize=18 argument increased the vertical offset.
This is a snipped of the code:

        figsize = (len(features) * 1.6, len(ds) * 1.1)
        fig2 = plt.figure(figsize=figsize)
        plt.style.use(mplhep.style.CMS)
        mplhep.cms.label(llabel='Private Work', data=False, fontsize=18)
        corrcoef_str = np.round(corrcoef, decimals=2).astype(str)
        for i, _ in enumerate(corrcoef.tolist()):
            for j, _ in enumerate(corrcoef.tolist()[i]):
                corrcoef_str[i][j] = "{:.2f}".format(corrcoef[i][j])
        # plot the coefficients in a heatmap
        im = plt.imshow(corrcoef, vmin=-1, vmax=1)
        im_ratio = corrcoef.shape[0] / corrcoef.shape[1]
        plt.colorbar(im, aspect=im_ratio * 20)
        plt.xticks(np.arange(len(features)), labels=features, rotation=90)
        plt.yticks(np.arange(len(ds)), labels=ds)

        # set the grid
        plt.xticks(np.arange(corrcoef.shape[1] + 1) - .5, minor=True)
        plt.yticks(np.arange(corrcoef.shape[0] + 1) - .5, minor=True)
        plt.grid(which="minor", color="black", linestyle='-', linewidth=.25)

        # annotate the the heatmap with the values in each cell
        for i in range(corrcoef.shape[0]):
            for j in range(corrcoef.shape[1]):
                plt.annotate(str(corrcoef_str[i][j]), xy=(j, i), ha='center', va='center', color='black',
                            fontsize=21)
        plt.savefig(os.path.join(save_path, f'corrcoef_fold{f}_ensemble{e}.pdf'))

I will append screenshots of the labels with and without the fontsize argument as well as files specifying my technical setup. My setup is embedded in an analysis framework called coulmnflow.
mplhep_screenshot_fontsize18
label_offset
venv_requirements.txt
model_specifications.txt
venv_requirements.txt
model_specifications.txt
mplhep_screenshot_fontsize18
label_offset

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant