小编Dol*_*ora的帖子

Shiny不显示R plotly plot

我很擅长闪亮,并试图推翻一个阴谋的饼图.单击runapp后,呈现的html仅包含标题,即"Plotly"

代码如下

UI

library(shiny)

shinyUI <- fluidPage(  
  titlePanel("Plotly"),
  mainPanel(
  plotOutput("plot2")))
Run Code Online (Sandbox Code Playgroud)

Server

library(shiny)
library(ggplot2)
library(ggthemes)
library(plotly)
library(shiny)
library(ggthemes)
library(RODBC)
library(magrittr)

synddb <- odbcConnect("Syndromic", uid="uname", pwd="pwd", believeNRows=FALSE)
totalcomplaints<-sqlQuery(channel=synddb,query= "select c.siteid,count(c.siteid) number_of_complaints, s.sitefullname from complainttmp c, site s
                          where s.siteid= c.siteid and c.siteid in(1,2,3,4,5,6,7,8, 10,11,19,20)
                          group by c.siteid,s.sitefullname
                          order by c.siteid asc")


shinyServer <- function(input, output) {
  output$plot2 <- renderPloty({
    print(
      plot_ly(totalcomplaints,labels=paste(totalcomplaints$sitefullname,totalcomplaints$siteid,sep = "-"),values = ~number_of_complaints, type = 'pie',
              textposition = 'inside',
              textinfo = 'label+percent+values',
              insidetextfont = list(color = '#FFFFFF'),
              hoverinfo = 'text', …
Run Code Online (Sandbox Code Playgroud)

r shiny shiny-server r-plotly

5
推荐指数
1
解决办法
1469
查看次数

在R中的plotly饼图中使用自定义图标

我想知道是否有一种方法可以为plotly的饼图提供自定义图标,而不是通常的饼图分区

到目前为止,我正在使用饼图显示性别信息,该饼图如下所示:

在此处输入图片说明

我正在尝试使其看起来像下面链接中的性别图:

https://app.displayr.com/Dashboard?id=c1506180-fe64-4941-8d24-9ec4a54439af#page=3e133117-f3b2-488b-bc02-1c2619cf3914

在此处输入图片说明

绘图代码如下:

plot_ly(genderselection, labels = ~Gender, values = ~Freq, type = 'pie') %>%
      layout(title = paste0("Gender Distribution of Patients from Boston"),
             xaxis = list(showgrid = FALSE, zeroline = FALSE, showticklabels = FALSE),
             yaxis = list(showgrid = FALSE, zeroline = FALSE, showticklabels = FALSE),
             legend=list(orientation='h'))
Run Code Online (Sandbox Code Playgroud)

性别选择数据框:

  Gender Freq
     F   70
     M   65
Run Code Online (Sandbox Code Playgroud)

如果不使用plotly,是否还有其他库可用于使用自定义图标显示信息?

r ggplot2 shiny plotly ggplotly

3
推荐指数
1
解决办法
444
查看次数

标签 统计

r ×2

shiny ×2

ggplot2 ×1

ggplotly ×1

plotly ×1

r-plotly ×1

shiny-server ×1