作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
使用ggplotly
将ggplot图形转换为plotly图形时,我可以获得一些 HTML,例如标题中的:
library(plotly)
library(ggplot2)
library(scales)
library(mvtnorm)
sims <- rmvnorm(500, mean=c(0,0,0))
dat <- setNames(data.frame(sims), c("x", "y", "z"))
dat$z <- dat$x+dat$y
gg <- ggplot(dat, aes(x=x, y=y, colour=z)) +
geom_point() +
scale_colour_gradient2(limits=c(-2,2), midpoint=0, low=muted("blue"), high=muted("red")) +
ggtitle("<em>hello</em>")
ggplotly(gg)
标题<em>hello</em>
正如预期的那样,以斜体显示。
但是当我想要一个 HTML 希腊字母时,这不起作用:
gg <- ggplot(dat, aes(x=x, y=y, colour=z)) +
geom_point() +
scale_colour_gradient2(limits=c(-2,2), midpoint=0, low=muted("blue"), high=muted("red")) +
ggtitle("Δ")
ggplotly(gg)
如何渲染 Δ
正如预期的希腊字母?
我正在使用plotly_4.5.2
和ggplot2_2.1.0
.
最佳答案
这适用于 decimal character reference :
gg <- ggplot(dat, aes(x=x, y=y, colour=z)) +
geom_point() +
scale_colour_gradient2(limits=c(-2,2), midpoint=0, low=muted("blue"), high=muted("red")) +
ggtitle("Δ")
ggplotly(gg)
根据this comment on the Github repo ,plotly.js 最近删除了通用 HTML 实体解码”。我不确定是否理解,但这可能是解释。
plotly 开发人员现已删除了 html 十进制字符编码。作为一种解决方案,可以直接输入 UTF-8 字符,或者使用 intToUtf8
:
ggtitle("Δ")
ggtitle(intToUtf8(0x0394L))
关于r - HTML 希腊字母与 ggplotly,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40223815/
我有一个绘图脚本,我从 JSON 文件加载字幕(变量 subplot_titles): JSON 文件示例: "subplot_titles" : { "0" : "Model: $~w_{0
在 MATLAB 中,如果您在轴标签中键入“\alpha”,它将呈现“纯文本”希腊字符 alpha,而不需要 Latex。我希望对 Matplotlib 的 Pyplot 做同样的事情。 正在关注 H
我是一名优秀的程序员,十分优秀!