我无法在R Markdown中使用plotly库获得饼图的并排子图。相反,它看起来像是一个饼图覆盖在另一个饼图上:
---
title: "Test Plotly Pie"
author: ""
date: ""
output:
html_document:
self_contained: no
---
```{r plotpie1, results='asis', tidy=FALSE, message=FALSE, fig.retina=NULL, echo=FALSE, out.width = "99%", out.height="750p[![enter image description here][1]][1]x"}
require(plotly)
require(dplyr)
p1 <- plot_ly(type="pie",values=c(5,954), height = 7,
labels=c("Change","No Change"),textinfo="label", hoverinfo="all",
textposition="outside",showlegend=F,marker=list(colors=c(
"lightskyblue",
"deepblue"
))) %>%
layout(autosize = T)
p2 <- plot_ly(type="pie",values=c(15,1325), height = 7,
labels=c("Change","No Change"),textinfo="label", hoverinfo="all",
textposition="outside",showlegend=F,marker=list(colors=c(
"lightskyblue",
"deepblue"
))) %>%
layout(autosize = T)
p4 <- suppressWarnings(subplot(
p1,
p2,
margin=0.05))
p4
```
我在使用Windows 7 64位操作系统上的R 3.1.3 64位版本。我正在使用plotly包的版本为:2.0.16(于2015年12月中旬从Github下载)。