r - 如何在R中调整破折号的高度?
问题描述
我有 3 个使用 ggplotly 和 dash 制作的散点图。然后,我使用 Dash 在选项卡中绘制 3 个数字,但数字的高度看起来被压扁了,我不知道如何增加它们的高度。
我使用这样的代码制作了 3 个有情节的数字 3 次:
p1 <- ggplot(data, aes(x=col1, y=col1))
plotlyp1 <- ggplotly(p1)
然后,我使用 3 个选项卡(每个图形一个选项卡)对破折号图进行编码,其中:
app <- Dash$new()
app$layout(htmlDiv(list(
htmlH1('3 plots'),
dccTabs(id="tabs-example", value='tab-1-example', children=list(
dccTab(label='plot1', value='tab-1-example'),
dccTab(label='plot2', value='tab-2-example'),
dccTab(label='plot3', value='tab-3-example')
)),
htmlDiv(id='tabs-plots')
)))
app$callback(
output = list(id='tabs-plots', property = 'children'),
params = list(input(id = 'tabs-example', property = 'value')),
function(tab){
if(tab == 'tab-1-example'){
return(htmlDiv(list(
htmlH3(''),
dccGraph(
id='graph-1-tabs',
figure=plotlyp1
)
)))
}
else if(tab == 'tab-2-example'){
return(htmlDiv(list(
htmlH3(''),
dccGraph(
id='graph-2-tabs',
figure=plotlyp2
)
)))
}
else if(tab == 'tab-3-example'){
return(htmlDiv(list(
htmlH3(''),
dccGraph(
id='graph-3-tabs',
figure=plotlyp3,
style = list(
height ='100%'),
)
)))
}
}
)
app$run_server()
目前为了尝试获得更多高度,我正在尝试style = list(height ='100%')
,dccGraph()
但这似乎没有任何作用,我在 R 中找不到任何示例/资源来显示如何更改绘图高度。
作为参考,上面的破折号代码给出了这个:
每个选项卡都有这样的情节,我只想让它们的高度变大。
解决方案
style = list(height = "100%")
将 CSS 添加height:100%
到div
包含情节。这会将绘图缩放到父级的 100% 高度,div
由 生成htmlDiv()
。您可以放大父级:
if(tab == 'tab-1-example'){
return(htmlDiv(
style = list(height = '750px'), # <=
list(
htmlH3(''),
dccGraph(
id = 'graph-1-tabs',
figure = plotlyp1,
style = list(height = '100%')
)
)))
}
推荐阅读
- java - 按用户定义的字段集查找重复对象
- php - preg_replace 和 regexp 获取域
- reactjs - 使用 react-redux 时如何高效设计组件/配置 store
- entity-framework - ASP.NET :- 使用单一视图从两个表中删除记录
- node.js - Nodejs中的异步方法超时
- c++ - unique_ptr:赋值前调用reset有什么效果
- php - 从控制器功能设置全局变量
- google-bigquery - Google BigQuery 在加载作业的 ignoreUnknownValues 选项上出现意外行为(收到额外列的错误)
- python - 无法在 Python 3 中获取 tkinter Entry 小部件的内容
- python-3.x - Python原理图忽略流氓字段名称但验证其值