- Download 'file_name.ttf' to /usr/share/fonts/truetype/
- Copy the file in step 1 to mpl-data/fonts/ttf/ which locates at matplotlib's install file folder
- Then copy the same file to /usr/.fonts/
- sudo fc-cache -fv
- ~/.cache/matplotlib -fr
- Check the real name for the 'ttf' file
from matplotlib.font_manager import FontManager
FontManager().ttflist - Change the default configurations in matplotlibrc
font.family : sans-serif
font.sans-serif : ..., Bitstream Vera Sans, Lucida Grande, Verdana, Geneva, Lucid, Arial, Helvetica, Avant Garde, sans-serif
axes.unicode_minus :False - Run the following codes
from matplotlib.font_manager import _rebuild
_rebuild() - Reboot
See here!
>>>fig,ax = plt.subplots(1,1)
>>>l1 = ax.scatter([0],[0], color='', marker='o', edgecolors='r', s=2000)
>>>l2 = ax.scatter(np.random.randn(50),np.random.randn(50))
>>>lgnd = ax.legend([l1,l2],['a','b'], loc='center',title='GYH',framealpha=0.5)
>>>lgnd.legendHandles[0]._sizes = [30]
>>>lgnd.legendHandles[1]._sizes = [30]
>>>ax.legend([Line2D(range(1), range(1), color="white", marker='o', markerfacecolor="red")],['a'])
If you use Rmarkdown, you should add {r, echo=FALSE, fig.showtext=TRUE ,message=FALSE}
to the chunk head.
>>>library(showtext)
>>>showtext_auto(enable = TRUE)
>>>font_add('...', '....ttandf')
>>>pdf('~/Desktop/test2/test.pdf')
>>>plot(c(1:10), xlab = 'ddsd', ylab = 'asdfsd',
main = '更改的字体', family = '...')
>>>dev.off()
>>>library(ggplot2)
>>>ggplot(mtcars, aes(x=wt, y=mpg)) + geom_point() SegoePrint+
... ggtitle("Fuel Efficiency of 32 Cars") +
... xlab("you can 更改r-base中的字体 now") + ylab("Miles per Gallon")+refer
... theme(text=element_text(family="..."))
More detail about that, you can dive into Custom_font_in_RStudio.pdf
inCustomed Font in RStudio
folder.
See here. This is the only way works for me!
See here. And you can also recustom in your r template package easily.
See instruction from Instructions on How to Mix R and Python Up - GYH.pdf
in Mix Python and R
folder.
from music21 import environmnet
environment.set("musescoreDirectPNGPath", "/usr/bin/musescore")
Delete /etc/rstudio/rserver.conf
np.diff(np.flatnonzero(np.diff(np.r_[0,(x.diff())==1,0]))).max()+1