gpt4 book ai didi

r - R 中带有 rCharts 的 nvd3 scatterPlot : Increase Font size of labels?

转载 作者:行者123 更新时间:2023-12-02 04:26:55 25 4
gpt4 key购买 nike

我正在尝试增加使用创建的图中 x 轴和 y 轴的字体大小NVD3 和 rCharts。这是我的情节代码。如有任何帮助,我们将不胜感激。

n1 <- nPlot(pValues~Chr,data=dat,type="scatterChart",height=400,width=750)
n1$chart(tooltipContent= "#! function(key, x, y, e){
return '<b>ID:</b> ' + e.point.ID
} !#")
n1$chart(forceY = c(0,8))
n1$chart(forceX = c(0,10))
#n1$chart(color = '#! function(d){return d.pValues} !#')
n1$xAxis(axisLabel = 'Chromosome')
n1$yAxis(axisLabel = '-log P value')

最佳答案

实际上,我想我发现了一个解决方案,感谢 this stack overflow discussion 。请让我知道这对你有没有用。将font-size更改为您想要的任何内容。您还可以提供一整套 CSS 来更改样式、位置、颜色等。

dat <- data.frame(
pValues = runif(20,0,5),
Chr = 1:20,
ID = sample(LETTERS[1:20])
)

n1 <- nPlot(pValues~Chr,data=dat,type="scatterChart",height=400,width=750)
n1$chart(tooltipContent= "#! function(key, x, y, e){
return '<b>ID:</b> ' + e.point.ID
} !#")
n1$chart(forceY = c(0,8))
n1$chart(forceX = c(0,10))
#n1$chart(color = '#! function(d){return d.pValues} !#')
n1$xAxis(axisLabel = 'Chromosome')
n1$yAxis(axisLabel = '-log P value')
n1

n1$setTemplate(afterScript = '<script>
var css = document.createElement("style");
css.type = "text/css";
css.innerHTML = ".nv-axislabel { font-size: 15px; }";
document.body.appendChild(css);
</script>'
)
n1

n1$chart(margin = list(left=100))
n1

### as stated in comments, x is basically unworkable but this kind of works

n1$xAxis(
axisLabel = 'Chromosome'
,tickFormat = "#!function(d){return d + " " }!#" #add space to the number
,rotateLabels=90 #rotate tick labels
)
n1$setTemplate(afterScript = '<script>
var css = document.createElement("style");
css.type = "text/css";
css.innerHTML = ".nv-x .nv-axislabel { font-size: 50px; }";
document.body.appendChild(css);
css = document.createElement("style");
css.type = "text/css";
css.innerHTML = ".nv-y .nv-axislabel { font-size: 50px; }";
document.body.appendChild(css);
</script>'
)
n1$chart(margin=list(left=100,bottom=100))
n1

关于r - R 中带有 rCharts 的 nvd3 scatterPlot : Increase Font size of labels?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24334339/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com