如何用R中的分类数据制作3D图?

编程入门 行业动态 更新时间:2024-10-28 01:26:33
本文介绍了如何用R中的分类数据制作3D图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我一直试图根据分类数据创建一个3D条形图,但没有找到办法。

I've been trying to create a 3D bar plot based on categorical data, but have not found a way.

这很容易解释。考虑下面的示例数据(真实的例子是更复杂,但它减少到这一点),显示招致按收入和年龄分类的分类数据的相对风险。

It is simple to explain. Consider the following example data (the real example is more complex, but it reduces to this), showing the relative risk of incurring something broken down by income and age, both categorical data.

我想在3D条形图中显示此信息(类似于 demos.devexpress/aspxperiencedemos/NavBar/Images/Charts/ManhattanBar.jpg )。我查看了scatterplot3d包,但它只适用于散点图,不能很好地处理分类数据。我能够制作一个三维图表,但它显示点而不是3d条。没有我需要的图表类型。我也试过rgl包,但也没有运气。我一直在谷歌搜索超过一个小时,现在还没有找到一个解决方案。我还有一个ggplot2 - 数据分析的优雅图形的副本,但ggplot2没有这种图表。

I want to display this in a 3D bar plot (similar in idea to demos.devexpress/aspxperiencedemos/NavBar/Images/Charts/ManhattanBar.jpg). I looked at the scatterplot3d package, but it's only for scatter plots and doesn't handle categorical data well. I was able to make a 3d chart, but it shows dots instead of 3d bars. There is no chart type for what I need. I've also tried the rgl package, but no luck either. I've been googling for more than an hour now and haven't found a solution. I have a copy of the ggplot2 - Elegant Graphics for Data Analysis book as well, but ggplot2 doesn't have this kind of chart.

还有另一个免费应用程序使用?

Is there another freeware app I could use? OpenOffice 3.2 doesn't have this chart either.

感谢您的任何提示。

Age,Income,Risk young,high,1 young,medium,1.2 young,low,1.36 adult,high,1 adult,medium,1.12 adult,low,1.23 old,high,1 old,medium,1.03 old,low,1.11

推荐答案

我不知道如何在R中制作一个3d图表,使用3d条形图表示这些数据的方法。 3d图表使解释困难,因为酒吧的高度,然后歪斜的3d透视。在该示例图表中,很难判断威斯康星在2004年是否真的高于威斯康星2001年,或者这是一个透视的效果。

I'm not sure how to make a 3d chart in R, but there are other, better ways to represent this data than with a 3d bar chart. 3d charts make interpretation difficult, because the heights of the bars and then skewed by the 3d perspective. In that example chart, it's hard to tell if Wisconsin in 2004 is really higher than Wisconsin 2001, or if that's an effect of the perspective. And if it is higher, how much so?

因为 Age 和收入有有意义的订单,制作线形图不会太糟糕。 ggplot2 代码:

Since both Age and Income have meaningful orders, it wouldn't be awful to make a line graph. ggplot2 code:

ggplot(data, aes(Age, Risk, color = Income))+ geom_line(aes(group = Income))

<您可以制作热图。

Or, you could make a heatmap.

ggplot(data, aes(Age, Income, fill = Risk)) + geom_tile()

更多推荐

如何用R中的分类数据制作3D图?

本文发布于:2023-07-18 05:12:13,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1141317.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:如何用   数据

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!