R 增加y轴上文本和标题之间的距离在绘图仪中不起作用
你好,我已经创建了一个闪亮的应用程序,其中包括一个带有plotly的散点图。我的问题是,尽管使用了R 增加y轴上文本和标题之间的距离在绘图仪中不起作用,r,ggplot2,shiny,ggplotly,R,Ggplot2,Shiny,Ggplotly,你好,我已经创建了一个闪亮的应用程序,其中包括一个带有plotly的散点图。我的问题是,尽管使用了axis.title.y=element\u text(margin=margin(t=0,r=20,b=0,l=20)),但我无法增加轴标题(y)和轴标签之间的间距 。每次更改输入时,绘图都会更新,因此轴标题和标签每次都会更改 #ui.r library(shiny) library(ggplot2) library(plotly) fluidPage(
axis.title.y=element\u text(margin=margin(t=0,r=20,b=0,l=20))
,但我无法增加轴标题(y)和轴标签之间的间距
。每次更改输入时,绘图都会更新,因此轴标题和标签每次都会更改
#ui.r
library(shiny)
library(ggplot2)
library(plotly)
fluidPage(
# App title ----
titlePanel(div("CROSS CORRELATION",style = "color:blue")),
# Sidebar layout with input and output definitions ----
sidebarLayout(
# Sidebar panel for inputs ----
sidebarPanel(
),
# Main panel for displaying outputs ----
mainPanel(
tabsetPanel(type = "tabs",
tabPanel("Table",
shiny::dataTableOutput("contents")),
tabPanel("Correlation Plot",
fluidRow(
column(3, uiOutput("lx1")),
column(3,uiOutput("lx2"))),
hr(),
fluidRow(
plotlyOutput("sc"))
))
)))
#server.r
function(input, output) {
output$contents <- shiny::renderDataTable({
iris
})
output$lx1<-renderUI({
selectInput("lx1", label = h4("Select 1st Expression Profile"),
choices = colnames(iris[,1:4]),
selected = "Lex1")
})
output$lx2<-renderUI({
selectInput("lx2", label = h4("Select 2nd Expression Profile"),
choices = colnames(iris[,1:4]),
selected = "Lex2")
})
output$sc<-renderPlotly({
p1 <- ggplot(iris, aes_string(x = input$lx1, y = input$lx2))+
# Change the point options in geom_point
geom_point(color = "darkblue") +
# Change the title of the plot (can change axis titles
# in this option as well and add subtitle)
labs(title = "Cross Correlation") +
# Change where the tick marks are
scale_x_continuous(breaks = seq(0, 2.5, 30)) +
scale_y_continuous(breaks = seq(0, 2.5, 30)) +
# Change how the text looks for each element
theme(title = element_text(family = "Calibri",
size = 10,
face = "bold"),
axis.title = element_text(family = "Calibri Light",
size = 16,
face = "bold",
color = "darkgrey"),
axis.text = element_text(family = "Calibri",
size = 11),
axis.title.y = element_text(margin = margin(t = 0, r = 20, b = 0, l = 20))
)+
theme_bw()+
geom_smooth(method = input$td)+
annotate("text", x = 10, y = 10, label = as.character(input$an))
ggplotly(p1) %>%
layout(hoverlabel = list(bgcolor = "white",
font = list(family = "Calibri",
size = 9,
color = "black")))
})
}
#ui.r
图书馆(闪亮)
图书馆(GG2)
图书馆(绘本)
流动摄影(
#应用程序标题----
标题板(div(“互相关”,style=“color:blue”),
#带有输入和输出定义的侧栏布局----
侧边栏布局(
#输入侧栏面板----
侧栏面板(
),
#用于显示输出的主面板----
主面板(
tabsetPanel(type=“tabs”,
选项卡面板(“表”,
闪亮::dataTableOutput(“内容”),
tabPanel(“相关图”,
fluidRow(
列(3,uiOutput(“lx1”),
列(3,uiOutput(“lx2”),
hr(),
fluidRow(
打印输出(“sc”))
))
)))
#服务器.r
功能(输入、输出){
输出$contents您找到解决方案了吗?我面临同样的问题,但在任何地方都找不到解决方案