如何在 R 中绘制一维图? [英] How can I plot a 1-D plot in R?

查看:60
本文介绍了如何在 R 中绘制一维图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个整数向量,例如:2,8,11,19.

I have a vector of integers, e.g.: 2,8,11,19.

我想绘制一条长度的线,例如20 然后为列表中存在的每个值(在某个恒定高度)绘制一个点,所以我得到这样的结果:

I would like to plot a line of length e.g. 20 then plot a dot for each value that exist in the list (at some constant height), so I get something like this:

-+-----+--+-------+-

推荐答案

Brandon Bertelsen 真的很亲近...

Brandon Bertelsen is really close...

x <- c(2,8,11,19)
x <- data.frame(x,1) ## 1 is your "height"
plot(x, type = 'o', pch = '|', ylab = '')

但我写这篇文章主要是为了提到您可能还会在基础图形中查看 stripchart() 和 rug() 以了解查看一维数据的方法.

But I wrote this mostly to mention that you might also in base graphics look at stripchart() and rug() for ways to look at 1-d data.

这篇关于如何在 R 中绘制一维图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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