博文

目前显示的是 九月, 2022的博文

matplotlib中文绘图

1 、在 /usr/share/fonts/下载字体 2、 fc-list :lang=zh 查看字体 3、使用 import matplotlib import numpy as np import pandas as pd import matplotlib.pyplot as plt from matplotlib import font_manager font_manager.fontManager.addfont ( "/usr/share/fonts/SourceHanSansCN-Normal.otf" ) plt.rcParams [ 'font.sans-serif' ] = [ 'Source Han Sans CN' ] ### 解决中文乱码 plt.rcParams [ 'axes.unicode_minus' ] = False # fname 为 你下载的字体库路径,注意 SourceHanSansSC-Bold.otf 字体的路径 dataset = pd.read_csv ( 'data/Rabies.csv' , header = 0 , index_col = 0 ) dataset.index=pd.to_datetime ( dataset.index ) dataset [ ' 狂犬疫苗接种量 ' ] .plot () dataset.plot () plt.show ()   import matplotlib.pyplot as plt from matplotlib.font_manager import FontProperties from plotnine import ggplot, aes, geom_bar, coord_flip, theme, element_text font = FontProperties( fname = "/usr/share/fonts/SourceHanSansCN-Regular.otf" ) (     ggplot(top_vaccines.reset_index(), aes( x = 'ym_mc' , y = &

Rmarkdown控制文本输出的宽度

  使用LaTeX软件包列表,详细参考 https://bookdown.org/yihui/rmarkdown-cookbook/text-width.html --- output : pdf_document : pandoc_args : --listings includes : in_header : preamble.tex --- 我们设置 了列表包的选项 : preamble.tex \lstset { breaklines=true }

rJava安装

sudo apt install libcurl4-openssl-dev libxml2-dev libudunits2-dev  libgdal-dev libbz2-dev libpcre3-dev liblzma-dev zlib1g-dev  -y  sudo apt install -y default-jre default-jdk sudo R CMD javareconf install.packages("rJava") install.packages("xml2", dependencies=TRUE, INSTALL_opts = c('--no-lock'))