用ggplot的coord_theta()奇怪的绘图行为

时间:2019-06-11 03:17:04

标签: r ggplot2 plotly polar-coordinates ggplotly

我正在尝试在Plotly中渲染极坐标ggplot,但是每当我调用ggplotly为我执行自动转换时,我都会收到一些警告,并且极坐标方面会从图中消失。以下带有图片的可复制代码。 有什么想法为什么使用coord_theta时Plotly在ggplot上玩的不好?

library(ggplot2)
library(plotly)

# Generate a spread of data
x = c(0, rep(1, 5), rep(2, 12), rep(3, 23))
y = c(1, seq(0,1, length.out = 5), 
      seq(0,1, length.out = 12), 
      seq(0,1, length.out = 23))

# Create the ggplot
gp <- ggplot() + geom_point(aes(x=x, y=y)) +
  coord_polar(theta = "y")

# Render the ggplot (looks fine)
gp

A polar ggplot

# Render the plotly version
ggplotly(gp)

# WARNING MESSAGES
# 1: In min(z$x.range %||% z$x_range) :
#   no non-missing arguments to min; returning Inf
# 2: In max(z$x.range %||% z$x_range) :
#   no non-missing arguments to max; returning -Inf
# 3: In min(z$y.range %||% z$y_range) :
#   no non-missing arguments to min; returning Inf
# 4: In max(z$y.range %||% z$y_range) :
#  no non-missing arguments to max; returning -Inf

A ggplotly, but without the polar coordinates

ggplotly保留了所有其他功能-缩放,平移,鼠标悬停文本-只是极坐标系已从图中剥离。

0 个答案:

没有答案