散点图:针对一个 Y 绘制多个单独的 X [英] Scatterplot: multiple individual Xs plotted against one Y

查看:51
本文介绍了散点图:针对一个 Y 绘制多个单独的 X的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个预测变量 Y 和许多 X.我想针对 Y 绘制所有 X,您将如何使用对(),但我不想看到每个组合的矩阵.

I have one predictor variable, Y, and many Xs. I would like to plot all of the Xs against the Y, how you would using pairs(), but I do not want to see the matrix of every combination.

我只想看到一个 Y 行和 X 列或一个 Y 列和 X 行.任何帮助将不胜感激.

I just want to see one Y row and X columns or one Y column and X rows. Any help would be appreciated.

推荐答案

假设您的数据是 mtcars(内置)并且您的一个预测器是 mpg:

Let's say your data is mtcars (built-in) and your one predictor is mpg:

library(ggplot2)
library(reshape2)
mtmelt <- melt(mtcars, id = "mpg")

ggplot(mtmelt, aes(x = value, y = mpg)) +
    facet_wrap(~variable, scales = "free") +
    geom_point()

这很不寻常,更常见的是您将预测变量放在 x 轴上,但这正是您所要求的.

This is pretty unusual, more commonly you put predictors on the x-axis, but it's what you asked for.

这篇关于散点图:针对一个 Y 绘制多个单独的 X的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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