Closed kayahans closed 1 year ago
I don't know how did you get that code to work. That's not the definition of reproducible minimal example.
Anyways, the latex backend is not generating bold labels because that property is not being given as its input.
The easiest way to solve it is to use the no-latex
style. See plt.style.use(['science', 'no-latex'])
:
import matplotlib.pyplot as plt
import scienceplots
import numpy as np
plt.style.use(['science', 'no-latex'])
np.random.seed(1000)
x = np.random.rand(10)
y = np.random.rand(10)
labels = ['a','b', 'c', 'd', 'e','f','g', 'h','i', 'j']
fig, ax = plt.subplots(figsize= (10,3))
ax.scatter(x, y)
ax.set_xticks(x, labels)
for ind in [2,3,4]:
ax.get_xticklabels()[ind].set_weight('bold')
plt.show()
Another way is by sending the appropriate latex commands, if you require it. You may want to customize the latex preamble via text.latex.preamble
import matplotlib.pyplot as plt
import scienceplots
import numpy as np
plt.style.use(['science'])
np.random.seed(1000)
x = np.random.rand(10)
y = np.random.rand(10)
labels = ['a','b', r'$\mathbf{c}$', r'\textbf{d}', r'\textbf{e}','f','g', 'h','i', 'j']
fig, ax = plt.subplots(figsize= (10,3))
ax.scatter(x, y)
ax.set_xticks(x, labels)
# for ind in [2,3,4]:
# ax.get_xticklabels()[ind].set_weight('bold')
plt.show()
Environment
Describe your issue here
Hi, thank you for all the work you put into this very nice and useful package. I have an issue with making some of the tick labels bold. Using the code below, I would expect that letters b, c, and d should be bold. However, the for loop does not make any effect in the produced image. Thanks
How can we reproduce it? What have you tried?