[英]Subplot with Plotly in R
我不能使用R中的圖表庫和R Markdown來獲得餅圖的並排子圖。 相反,看起來子圖將一個餅覆蓋在另一個餅上:
---
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位。 我使用的是封裝版本:2.0.16(2015年12月中旬從Github下載)。
正如MLavoie所建議的,我只會添加一個答案,以防有人發現它有用......
```{r message=FALSE, warning=FALSE}
library(plotly)
p <- plot_ly(x = rnorm(1000), y = rnorm(1000), mode = "markers")
```
<div>
<div style = "float:left">
```{r echo = F, fig.width = 4, fig.height = 4}
p
```
</div>
<div style = "float:right">
```{r, echo = F, fig.width = 4, fig.height = 4}
p
```
</div>
</div>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.