ggplot2 3D 条形图 [英] ggplot2 3D Bar Plot

查看:42
本文介绍了ggplot2 3D 条形图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道这听起来很基本,但是已经搜索了一个多小时没有成功.我只是尝试使用 'ggplot2' 包在 'R' 中绘制 3D 条形图.我的数据框看起来像这样:

I Know this sounds basic, but have a been searching for literally more than an hour now without success. I'm simply trying to plot a 3D bar plot in 'R' using the 'ggplot2' package. My dataframe looks something like this:

 x   y     z
t1   5   high
t1   2   low
t1   4   med
t2   8   high
t2   1   low
t2   3   med
t3  50   high
t3  12   med
t3  35   low

我想在上面绘制这样的图:

and I want to plot something like this on it:

非常感谢任何帮助!!

推荐答案

如评论中所述,3D 绘图通常不是一个好的选择(当其他选项可用时),因为它们往往会提供扭曲/模糊的数据视图.

As mentioned in comments, 3D plots usually aren't a good choice (when other options are available) since they tend to give a distorted/obscured view of data.

也就是说,以下是如何使用 latticeExtra 根据需要绘制数据:

That said, here's how you can plot your data as desired with latticeExtra:

d <- read.table(text=' x   y     z
t1   5   high
t1   2   low
t1   4   med
t2   8   high
t2   1   low
t2   3   med
t3  50   high
t3  12   med
t3  35   low', header=TRUE)

library(latticeExtra)

cloud(y~x+z, d, panel.3d.cloud=panel.3dbars, col.facet='grey', 
      xbase=0.4, ybase=0.4, scales=list(arrows=FALSE, col=1), 
      par.settings = list(axis.line = list(col = "transparent")))

这篇关于ggplot2 3D 条形图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆