简体   繁体   English

如何在matplotlib上仅将乳胶字体用于标题而不用于轴号

[英]How to use latex font only for title and not for axis number on matplotlib

really sorry for this, have been searching this since yesterday and I haven't seen a similar problem.真的很抱歉,从昨天开始一直在搜索这个,我还没有看到类似的问题。

The figure is a bit large, so I only post some relevant part:图有点大,只贴一些相关部分:

plt.rcParams.update({
    "text.usetex": True})



font = {'family': 'serif', 'serif': ['Computer Modern'],
        'weight' : 'bold',
        'size'   : 22}

matplotlib.rc('font', **font)

fig = plt.figure(figsize=(15,12))
# set height ratios for subplots
gs = gridspec.GridSpec(5,1, height_ratios=[1, 1, 1, 1, 1]) 

ax0 = plt.subplot(gs[0])


line0, = ax0.plot(xnew, uf_sm(xnew), color='r', linewidth=2.5)
plt.title("\\boldmath$u _\phi$",fontsize=30)
ax0.set_yticks([0.0, 0.3, 0.6])

now, with this font features, everything works properly except one thing: bold doesn't work, AND the axis numbers (next to ticks) are very faint, and don't appear good on the pdf.现在,有了这个字体功能,除了一件事之外,一切都正常工作: bold不起作用,并且轴号(在刻度旁边)非常微弱,并且在 pdf 上看起来不太好。

I have seen that here is no bold option on latex, so is there a way I can either我已经看到这里没有关于乳胶的bold选择,所以有没有办法我可以

  1. use latex only on titles (so I can bold the numbers on axis)仅在标题上使用乳胶(因此我可以将轴上的数字加粗)

OR要么

  1. Keep using latex but somehow use a better font to have "stronger" axis numbers.继续使用乳胶但不知何故使用更好的字体来获得“更强”的轴号。

REALLY thank you for your time, hope its not that hard.真的很感谢您抽出宝贵时间,希望不会那么难。

Using no latex in title, I can work with $$ but I get this u:在标题中不使用乳胶,我可以使用$$工作,但我得到了这个你: 一种

On the other hand, when using usetex= True I get this u:另一方面,当使用usetex= True我得到这个你: 在此处输入图片说明

which is actually what I want to have这实际上是我想要的

How about this?这个怎么样?

fig, ax = plt.subplots()
x = np.arange(5)
ax.scatter(x,x)
ax.set_title(r'$\sum \ \alpha \beta \gamma \ this \ is \ \frac{title}{in \ LaTeX} $')
ax.set_xlabel('xaxis label is not in latex')
ax.set_ylabel('yaxis label is not in latex as well')

output:输出:

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM