1

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.

I have seen that here is no bold option on latex, so is there a way I can either

  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:a

On the other hand, when using usetex= True I get this u:enter image description here

which is actually what I want to have

Billy Matlock
  • 340
  • 2
  • 14
  • [Bold font weight for LaTeX axes label in matplotlib](https://stackoverflow.com/q/14324477/3279716) – Alex Jul 23 '21 at 14:52
  • @Alex I actually want to numbers on the axis to be bolt. not the label – Billy Matlock Jul 23 '21 at 14:59
  • That question has a couple of methods of using `\boldmath` that should be applicable to tick labels – Alex Jul 23 '21 at 15:21
  • @Alex I have tried, but i get nothing. I dont have labels. Only Tick Numbers (Axis Numbers) – Billy Matlock Jul 23 '21 at 15:47
  • The numbers on an axis are also called tick labels. Take a look at [this answer](https://stackoverflow.com/a/29772534/3279716) – Alex Jul 23 '21 at 16:03
  • @Alex First of all, thank you for your interest. Now I tried that way. Thing is I got the problem on question above (edited it some mins before). And this gives the wrong 'u' (I still dont get why tho??) – Billy Matlock Jul 23 '21 at 16:40
  • When writing `mathtext` you should use raw strings (`r"..."`). So your title should probably be: `plt.title(r"$\mathbf{u}_\phi$",fontsize=30)`. Take a look at [writing mathematical expressions](https://matplotlib.org/stable/tutorials/text/mathtext.html) – Alex Jul 23 '21 at 16:48

1 Answers1

0

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:

enter image description here

Karina
  • 1,252
  • 2
  • 5
  • 16
  • Hi! Thanks for your answer! So I had tried this but I have this problem: the "U" symbol is actually different than the one I get while using latex. The one in latex is more calligraphic and its actually what I want the figure to have. So If I can apply certain font on title? I'm really lost ( Will post picture on Question to make this more clear) – Billy Matlock Jul 23 '21 at 15:02