pnkraemer / tueplots

Figure sizes, font sizes, fonts, and more configurations at minimal overhead. Fix your journal papers, conference proceedings, and other scientific publications.
https://tueplots.readthedocs.io
MIT License
675 stars 25 forks source link

Font seems off #76

Closed dmandic17 closed 2 years ago

dmandic17 commented 2 years ago

Hi,

I tried using tueplots but encountered some weird bug, where my plot got from this:

im1

to this:

im2

just by removing defined figsize and adding:

from tueplots import bundles 

plt.rcParams.update(bundles.neurips2021(usetex=False, ncols=2, nrows=1))

Example code can be found here.

Is this a bug or am I missing something?

philipphennig commented 2 years ago

I think the problem here may be that seaborn is using its own custom rc's that don't fully cooperate with pyplot.

You could try manually setting sns.set(rc={"font.size":9}) as a quick fix. But in general, it may be that seaborn and tueplots just don't mix well. They're both trying to do similar things (i.e. change the default parameters of matplotlib), and may thus be messing with each other.

So if you like seaborn so much that you don't want to give it up, you may have to live without tueplots. Note that you can do the bar plots in plain pyplot, too.

pnkraemer commented 2 years ago

Hi @dmandic17, thanks for raising this issue!

@philipphennig is right. However, instead of plt.rcParams.update, seaborn.set(rc=bundles.neurips2021()) seems to work on my machine, which is good news.

The bad news are that the bar-label-text-size does not have the corresponding rcParams, which can be adjusted to make your plot look good automatically. (At least, I didnt find any.) This means that on the tueplots side, we cannot do anything to resolve your issue. You will have to manually set the label size of the bars to, e.g., small. Then, things should look fine.

I have not tried what happened if you make the same bar plot in matplotlib directly, but I think the same issue applies (i.e. calling bar_label(..., fontsize="small") if you want smaller fonts.

Does that help?

dmandic17 commented 2 years ago

Both plt.rcParams.update and seaborn.set(rc=bundles.neurips2021()) fix all the plots for me, this problem arises just when trying adding additional text with Axes.text(...). But yes, manually setting the fontsize here seems to be fixing this issue.

Thank you for your responses! @philipphennig @pnkraemer

pnkraemer commented 2 years ago

Thanks for getting back to us. I will close the issue then. Please reopen if it is not fully resolved. :)