我正在尝试使用ShinyR
创建一个应用程序,并使用ggplot创建一些动态图形。我已经使用了:
annotate("text", -Inf, Inf, label = "Label",
hjust = 0, vjust = 1, col = "red", fontface = "bold")
在我的图表的上角创建一些文字。我确定它的位置是因为图形的高度/宽度会随着用户的输入而变化。这个文本有时很难从图表中读取,所以我想了两种方法来使其更容易阅读,但这两种方法我都无法实现:
ggplot
.中绝对定位框
renderPlot
中找到的代码中的一些信息,我不知道如何使用renderText
.访问这些信息
红色文本,这是绝对的位置,是我希望通过一个框来使其更加可见的内容:
发布于 2018-08-18 07:21:16
我认为这个解决方案将为您工作:R: How can I annotate a ggplot with a text box?
或者,您可以尝试:
annotate("rect", xmin = (value), xmax = (value), ymin = (value), ymax = (value), alpha = (opacity))
发布于 2018-08-19 03:24:44
明白了!
有点麻烦,但看起来就是这样...
words <- qplot(1:10,1:10,geom="blank")+annotate("text", x=5, y=9, label= paste("Rejection Region: X <=", rejreg/input$n),col="red",fontface="bold")+annotate("text",x=5,y=7,label=paste("Hypothesized Proportion of Reps:", min*input$reps, "/", input$reps, "=", round(min,2)),col="red",fontface="bold")+annotate("text",x=5,y=5,label=paste("Alternaitve Proportion of Reps:", altmin*input$reps, "/", input$reps, "=", round(altmin,2)),col="red",fontface="bold")+
theme(axis.title.x=element_blank(),
axis.text.x=element_blank(),
axis.ticks.x=element_blank(),
axis.title.y=element_blank(),
axis.text.y=element_blank(),
axis.ticks.y=element_blank(),
panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
panel.border = element_blank(),
panel.background = element_blank())
现在,问题图像中的单词出现在图的下方。
https://stackoverflow.com/questions/51903169
复制相似问题