首页
学习
活动
专区
圈层
工具
发布
    • 综合排序
    • 最热优先
    • 最新优先
    时间不限
  • 来自专栏生信补给站

    showtext:字体,好玩的字体和好玩的图形

    当然了,R本身是不认识这些字体的,我们需要使用showtext附加包来真正利用这些字体绘图。 showtext的用法更加简单,目前只有两个函数:showtext.begin()和showtext.end()。我们需要做的就是把绘图的命令包含在这两个语句中间,然后在适当的地方选取字体即可。 不多说,直接上代码: # showtext会自动加载sysfonts包 library(showtext); # 导入楷体 font.add("kaishu", "simkai.ttf");library (Cairo); # 打开图形设备 CairoPNG("chinese-char.png", 600, 600); # 开始使用showtext showtext.begin(); # 一系列绘图命令 showtext.end(); # 关闭图形设备 dev.off(); 也就是说,要让R使用我们之前加载的字体,只需要将画图命令包含在一对showtext.begin()和showtext.end()

    2.5K20发布于 2020-08-06
  • 来自专栏数据 学术 商业 新闻

    R-sysfonts+showtext包 -告别windows字体添加的烦恼

    需要用到sysfonts和showtext两个包。 绘制图形 先打开图形设备,然后将绘图代码放在showtext_begin()和showtext_end()之间。 library(showtext) # 加载包 font_add("myFont1", "timesbd.ttf") # 加载字体 showtext_auto() # 全局自动使用showtext渲染字体 showtext_begin()和showtext_end()可以控制在哪一段代码间使用字体,而showtext_auto()是全局都使用。 参考资料 COS主站文章《showtext:字体,好玩的字体和好玩的图》 作者 邱怡轩 sysfonts包和showtext包帮助文件 ----

    7.1K20发布于 2021-02-22
  • 来自专栏优雅R

    「R」showtext:在R图里面更简单地使用字体

    to render text for future devices showtext_auto() ## Tell showtext the resolution of the device, ## 用法 分为以下几步: 载入字体 打开绘图设备 声明你想要使用showtext画文本图 画图 关闭画图设备 If you want to use showtext globally, you can call the function showtext_auto() once, and then all the devices after that will automatically use showtext If you want to have finer control on which part of the code should use showtext, functions showtext_begin () and showtext_end() will help.

    3.2K10发布于 2020-07-02
  • 来自专栏EpiHub

    Meta分析森林图中文显示问题

    ) cairo_pdf( "plotname1.pdf",width = 12,height = 6) showtext.begin() ## turn on showtext forest(m2,comb.random=T, family = 'GB1' ) showtext.end() ## turn off showtext dev.off() ## save library(showtext) cairo_pdf( "plotname2.pdf",width = 12,height = 6) showtext.begin ",width = 12,height = 6) showtext.begin() ## turn on showtext forest(m2,comb.random=T, family = 'Arial Unicode MS' ) showtext.end() ## turn off showtext dev.off()

    81720编辑于 2023-01-15
  • 来自专栏北野茶缸子的专栏

    83-R可视化16-用showtext让R绘图认得中文及花里胡哨的字体

    12-19_Sun]] Tags :  #R/index/02 #R/R可视化 #R/R数据科学 #R/R包 参考: R 绘图 – 中文支持 | 菜鸟教程 (runoob.com)[1] yixuan/showtext 打卡了一个新世界的钥匙: library(showtext) font_add_google("Playfair Display", ## name of Google font 字体前,需要提前声明: font_add("source-han-serif-cn") showtext_auto() (p <- ggplot(income.2019) + geom_col # 载入 showtext library(showtext); # 第一个参数设置字体名称,第二个参数为字体库路径,同目录下,我们写字体库名就可以了 font_add("SyHei", " SourceHanSansSC-Bold.otf") font_add("source-han-serif-cn") showtext_auto() (p <- ggplot(income.2019)

    1.5K20编辑于 2022-02-08
  • 来自专栏优雅R

    R 语言画图中英文字体解决方案

    这里推荐一个showtext的 R 包。如果需要将含有中文字体的图形保存为 pdf 文件,可以使用下面讲到的方案,最新版的showtext已经支持了ggplot2,推荐使用此种方案。 这样,在你写的 R 代码中,开头添加: library(showtext) showtext_auto(enable=True) # 表示之后用上同样的字体 font_add("kaishu", simsun.ttc: NSimSun,新宋体:style=Regular /usr/share/fonts/chinese/simsun.ttc: SimSun,宋体:style=Regular 使用 showtext 包在绘图钟显示中英文 library(showtext) showtext_auto(enable=True) font_add('SimSun', "simsun.ttc") set.seed(123 on and draw some characters showtext_begin() text(runif(100, -3, 3), runif(100, -3, 3), intToUtf8

    3K10发布于 2020-07-06
  • 来自专栏程序员备忘录

    Tkinter学习笔记(二)

    7.Checkbutton学习笔记 import tkinter as tk window=tk.Tk() window.geometry('500x300') showText=tk.StringVar () labelOne=tk.Label(window,textvariable=showText,width=40,bg='red') labelOne.pack() def show(): ('select all') elif v1==0 and v2==1: showText.set('select two') elif v1==1 and v2==0: showText.set('select one') else: showText.set('no select ') var=tk.StringVar() =tk.Label(window,textvariable=showText,width=50,bg='red') lableOne.pack() def show(value): print(

    57310发布于 2020-11-02
  • 来自专栏刘望舒

    React Native探索之组件的属性和状态

    class Flash extends Component { constructor(props) {//1 super(props); this.state = {showText : true};//2 setInterval(() => { this.setState({showText: ! this.state.showText}); }, 1000);//3 } render() { let display = this.state.showText 注释3处调用setInterval方法,每隔1000毫秒对showText的值进行取反,使得showText的值不断在true和false之间切换。 注释4处通过showText的值来控制文本的显示,如果showText为true,则通过this.props.text来获取Flash组件的text属性的值。

    3.2K30发布于 2018-10-25
  • 来自专栏Linux驱动

    56.Qt-滚动字幕之无间隙滚动

    private: QTimer* timer; //时间定时器 QRgb textColor; QString m_text; QString m_showText textScroll::resizeEvent(QResizeEvent *event) { font.setPixelSize(event->size().height()*0.75); m_showText (0," "); } m_moveSize=metrics.width(m_showText)+blankSuffix; m_moveOffset=0; update( ; font.setPixelSize(height()*0.75); this->textColor = textColor; m_text = text; m_showText (0," "); } m_moveSize=metrics.width(m_showText)+blankSuffix; m_moveOffset=0; if(!

    1.8K30发布于 2020-10-29
  • 来自专栏数据小魔方

    一篇全是代码的数据可视化案例

    ) library("maptools") library("maps") library("REmap") library("Cairo") library("baidumap") library(showtext myfont", "msyhl.ttc") CairoPNG(file="C:/Users/Administrator/Desktop/航线图1.png",width=1000,height=670) showtext.begin element_blank(), #legend.position=c(0.8,0.3), legend.position="none" ) showtext.end element_blank(), #legend.position=c(0.8,0.3), legend.position="none" ) showtext.end 以上所有图表的指标数据均为随机数虚构,图表的图形代码使用showtext和Cario进行高清渲染并自动输出,除了需加载的地图素材之外,其他代码均可一次性放在控制台流畅运行。

    1.1K60发布于 2018-04-11
  • 来自专栏BioIT爱好者

    R 语言画图中英文字体解决方案

    这里推荐一个showtext的 R 包。如果需要将含有中文字体的图形保存为 pdf 文件,可以使用下面讲到的方案,最新版的showtext已经支持了ggplot2,推荐使用此种方案。 这样,在你写的 R 代码中,开头添加: library(showtext) showtext_auto(enable=True) # 表示之后用上同样的字体 font_add("kaishu", simsun.ttc: NSimSun,新宋体:style=Regular /usr/share/fonts/chinese/simsun.ttc: SimSun,宋体:style=Regular 使用 showtext 包在绘图钟显示中英文 library(showtext) showtext_auto(enable=True) font_add('SimSun', "simsun.ttc") set.seed(123 on and draw some characters showtext_begin() text(runif(100, -3, 3), runif(100, -3, 3), intToUtf8

    1.5K20发布于 2021-10-15
  • 来自专栏Unity3d程序开发

    u3d打字机效果

    using UnityEngine.UI; public class Typewriter : MonoBehaviour { float fSpeed = 0.1f; Text Showtext ; string sContent;//文本字符串 int curPos;//当前文字位置(当前的最后一个字) void Start() { Showtext >(); SetContent(); } void SetContent() { curPos = 0; sContent = Showtext.text ; Debug.Log("lenth++" + sContent.Length); Showtext.text = string.Empty; InvokeRepeating sContent.Contains(Showtext.text)) { Debug.Log("typing"); CancelInvoke

    36620编辑于 2023-08-24
  • 来自专栏爪哇学习日记

    hexo-butterfly-自定义内置标签

    label', addLabel, { ends: false }) 内置标签自定义实现 ​ 基于上述说明,则可通过上述步骤构建内置标签,实现自己所需的效果和内容,举一个简单的例子:创建一个标签为showText ,通过这个标签定义完成文本信息的输出,其构建内容参考如下: # 1.在themes/butterfly/script/tag/showText.js # 2.填充showText内容 'use strict ' // 定义函数 function addText (args, content) { const text = args[0] || 'non' console.log("showText Plugin"); return `

    ${text}

    `; } // 注册插件 hexo.extend.tag.register('showText', addText, { ends : false }) # 3.引用参考: {% showText 插件测试 %} {% showText %} 由此可得到渲染后的文本信息 ​ 上述这种方式是基于辅助函数的方式构建插件,如果有其他的插件需求根据则可根据自身喜好进行构建

    85010编辑于 2022-06-15
  • 来自专栏移动开发面面观

    React Native的state

    => { return { showText: ! previousState.showText }; }); }, 500); } render() { // 根据当前showText的值决定是否显示text 内容 let display = this.state.showText ? 我们在构建方法中,创建了一个定时方法,定时方法中对previousState.showText的状态进行了取反,时间为500ms。 然后在render方法中,先判断previousState.showText状态。为true时,显示从外界传入的props的值,如果状态为false,则不显示。

    1.4K30发布于 2018-07-03
  • 来自专栏数据小魔方

    送你两款炫酷到没朋友的神奇字体~

    项目主页: http://9ishare.cc/ 以下代码运行前务必要保证系统已经安装了这两款字体: library("ggplot2") library("showtext") library("Cairo setwd("E:/微信公众号/公众号——数据小魔方/2017年8月/20170805/") CairoPNG(file="PieChart.png",width=1000,height=750) showtext.begin scale_colour_manual(values=c("#92D24F","#FFC000"),guide=FALSE)+ ylim(1.5,3.5)+ xlim(.5,5.5)+ theme_void() showtext.end -char3[PieChart$value*100+1] #百分比方块堆积图可视化过程: CairoPNG(file="BlockCharts.png",width=1000,height=750) showtext.begin scale_colour_manual(values=c("#92D24F","#FFC000"),guide=FALSE)+ ylim(1.5,3.5)+ xlim(0.5,5.5)+ theme_void() showtext.end

    1.2K40发布于 2018-04-11
  • 来自专栏闵开慧

    ajax_option.html

    javascript"> function getText(value){ var xmlhttp; if(value == ""){ document.getElementById("showText function(){ if(xmlhttp.readyState == 4 && xmlhttp.status == 200){ document.getElementById("showText option> <option value="tecent">tecent</option> </select> </label> </form> <div id="<em>showText</em>

    1.1K30发布于 2018-03-30
  • 来自专栏大宇笔记

    React Native 生命周期

    :'+nowTime); showText = showText+'componentDidMount:'+nowTime+'\r\r'; alert(showText); } shouldComponentUpdate(){ console.log('shouldComponentUpdate:'+nowTime); showText = showText = showText+'componentWillUpdate:'+nowTime+'\r\r'; } componentDidUpdate(){ console.log ('componentDidUpdate:'+nowTime); showText = showText+'componentDidUpdate:'+nowTime+'\r\r'; } componentWillUnmount(){ console.log('componentWillUnmount:'+nowTime); showText = showText

    1.3K30发布于 2019-01-15
  • 来自专栏TopFE

    使用 white-space 来实现保留文本域 textarea的换行格式和 空格格式

    width: 200px;"></textarea> <button onclick="submit()">提交</button>

    normal:

    nowrap:</ p>

    space-pre:

    pre-wrap:

    pre-line:

    break-spaces:<

    3.1K30编辑于 2022-04-10
  • 来自专栏数据小魔方

    实习僧招聘网爬虫数据可视化

    ) library(Rwebdriver) library(dplyr) library(Rwordseg) library(wordcloud2) library(treemap) library(showtext (Freq)) CairoPNG(file="E:/微信公众号/公众号——数据小魔方/2017年5月/20170512/circle-rose.png",width=1580,height=950) showtext.begin family="myfont",size=35), plot.caption=element_text(family="myfont",size=18,hjust=0,lineheight=1.2) ) showtext.end CairoPNG(file="E:/微信公众号/公众号——数据小魔方/2017年5月/20170512/jingjixue2.png",width=800,height=600) showtext.begin element_blank(), axis.text.y=element_text(size=15), axis.text.x=element_blank() ) showtext.end

    1.5K70发布于 2018-04-11
  • 来自专栏生信宝典

    R语言学习 - 图形设置中英字体

    ) # 或者 theme_bw(base_family="Arial") # 修改geom_text的字体 geom_text(family="Arial") ggplot2支持中文字体输出PDF showtext 包可给定字体文件,加载到R环境中,生成新的字体家族名字,后期调用这个名字设定字体,并且支持中文写入pdf不乱码 library(showtext) showtext.auto(enable=TRUE) library(showtext) ## Add fonts that are available on current path # 方正字体+schoole bell (中英混合) font.add () ## automatically use showtext for new devices library(ggplot2) p = ggplot(NULL, aes(x = 1:10, y Reference 中英文字体混合 http://www.voidcn.com/article/p-gnggkwmy-vn.html 改变字体类型 https://github.com/yixuan/showtext

    3.2K80发布于 2018-02-05
领券