Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/70.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R 如何在“闪亮”中更改绘图的背景色?_R_Shiny - Fatal编程技术网

R 如何在“闪亮”中更改绘图的背景色?

R 如何在“闪亮”中更改绘图的背景色?,r,shiny,R,Shiny,我想知道我是否可以更改绘图的背景色,或者至少使其透明以允许继承其父背景, 我试过: ui: plotOutput("scatterChart", width = "80%", height = "294px") output$scatterChart <- renderPlot({ par(bg = "yellow") plot(rules(), col = rainbow(

我想知道我是否可以更改
绘图
背景色
,或者至少使其透明以允许继承其父背景, 我试过:

ui:

plotOutput("scatterChart",
                       width = "80%",
                       height = "294px")
  output$scatterChart <- renderPlot({
    par(bg = "yellow")
    plot(rules(), col  = rainbow(25), cex  = input$cex)
  })
服务器:

plotOutput("scatterChart",
                       width = "80%",
                       height = "294px")
  output$scatterChart <- renderPlot({
    par(bg = "yellow")
    plot(rules(), col  = rainbow(25), cex  = input$cex)
  })
我没有得到预期的结果

或:

这改变了整个div的背景,我甚至看不到情节本身(我正在验证)

这是一张照片:

编辑:

plotOutput("scatterChart",
                       width = "80%",
                       height = "294px")
  output$scatterChart <- renderPlot({
    par(bg = "yellow")
    plot(rules(), col  = rainbow(25), cex  = input$cex)
  })
根据thothal给我的示例,我发现问题出在传递给plot函数的数据上(它只是使用
Apriori
算法获得的一些
association rules
):


rules实际上,您可以像这样简单地更改绘图的背景颜色

库(闪亮)

感谢您的帮助,您的方法非常有效!我在我的代码中注入了它,它也能工作,但当我使用相同的方法时,它不起作用是的,我使用的是
arulesViz
库以及
库(arulesViz,warn.conflications=FALSE)
我试图删除它,但问题仍然存在。从您的代码片段中,我没有看到任何问题。请发布一条消息,以增加您获得问题答案的机会。但我的猜测是,由于您隐式使用了
plot.rules
,因此背景参数不受尊重。快速浏览一下
arulesViz
中的绘图例程似乎可以证实这一点。您有两种选择:重新实现
规则
对象的绘图代码,或者要求包维护人员打开API以允许此参数通过。谢谢!然后我应该把它作为一个问题发布在他们的回购协议上吗?是的。我很快找到了存储库,并提供了一个快速(黑客式)修复程序。请看我的最新答案。