我很擅长闪亮,并试图推翻一个阴谋的饼图.单击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) 我想知道是否有一种方法可以为plotly的饼图提供自定义图标,而不是通常的饼图分区
到目前为止,我正在使用饼图显示性别信息,该饼图如下所示:
我正在尝试使其看起来像下面链接中的性别图:
绘图代码如下:
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,是否还有其他库可用于使用自定义图标显示信息?