如何修改R语言Flexdashboard中项目符号文本的字体与字号?
你之前使用的.chart-title CSS选择器仅针对图表标题,无法作用于无序列表(项目符号)文本。要修改这类内容,需要针对无序列表的元素设置样式:
正确的CSS配置
在你的flexdashboard文档开头(YAML配置之后)添加一次全局样式即可,无需重复添加:
<style type="text/css"> /* 修改无序列表(项目符号)文本的字体与字号 */ .storyboard-body ul li { font-size: 18px; /* 自定义字号,可按需调整 */ font-family: "Arial", sans-serif; /* 自定义字体,可替换为其他可用字体 */ } /* 如需保留图表标题的样式修改可保留此部分 */ .chart-title { font-size: 30px; font-family: Algerian; } </style>
修改后的完整代码示例
--- title: "HTML Widgets Showcase" output: flexdashboard::flex_dashboard: storyboard: true social: menu source: embed --- <style type="text/css"> .storyboard-body ul li { font-size: 18px; font-family: "Arial", sans-serif; } .chart-title { font-size: 30px; font-family: Algerian; } </style> ```{r setup, include=FALSE} library(flexdashboard)
Leaflet is a JavaScript library for creating dynamic maps that support panning and zooming along with various annotations.
library(leaflet) leaflet() %>% addTiles() %>% addMarkers(lng=174.768, lat=-36.852, popup="The birthplace of R")
https://rstudio.github.io/leaflet/
Interactive panning/zooming
Compose maps using arbitrary combinations of map tiles, markers, polygons, lines, popups, and GeoJSON.
Create maps right from the R console or RStudio
Embed maps in knitr/R Markdown documents and Shiny apps
Easily render Spatial objects from the sp package, or data frames with latitude/longitude columns
Use map bounds and mouse events to drive Shiny logic
d3heatmap creates interactive D3 heatmaps including support for row/column highlighting and zooming.
library(d3heatmap) d3heatmap(mtcars, scale="column", colors="Blues")
https://github.com/rstudio/d3heatmap/
Highlight rows/columns by clicking axis labels
Click and drag over colormap to zoom in (click on colormap to zoom out)
Optional clustering and dendrograms, courtesy of base::heatmap
## 补充说明 - `.storyboard-body ul li` 是针对storyboard布局下无序列表项的精准选择器,确保样式仅作用于你需要的项目符号文本; - 若要全局修改文档中所有无序列表,可简化选择器为 `ul li`; - 选择字体时需确保渲染环境支持该字体,避免使用系统未安装的特殊字体。 内容的提问来源于stack exchange,提问作者stats_noob

