可视化具有相同列名的数据框,在 R 中用不同颜色表示每一列
Visualize a dataframe with same column names, represent each column with different colors in R
我正在尝试可视化数据框,这是采样变化的结果。
class
Data
Data
Data
Car
3.4
1.2
90
Bike
3.6
2.4
89
Cycle
4.2
1.5
78
如您所见,该列具有相同名称的数据,我想可视化一个标记这些点的折线图,并且对于每一列,我需要不同的颜色。
ggplot(tab7, aes(class,data)) + geom_line() + facet_grid(data~ .)
我收到如下错误:
geom_path: Each group consists of only one observation. Do you need to adjust the group aesthetic?
不清楚你在找什么,但好像是这样的:
tab7 %>%
pivot_longer(-class) %>%
select(class, value) %>%
ggplot(aes(value, class)) +
geom_point(aes(colour = class))
我正在尝试可视化数据框,这是采样变化的结果。
class | Data | Data | Data |
---|---|---|---|
Car | 3.4 | 1.2 | 90 |
Bike | 3.6 | 2.4 | 89 |
Cycle | 4.2 | 1.5 | 78 |
如您所见,该列具有相同名称的数据,我想可视化一个标记这些点的折线图,并且对于每一列,我需要不同的颜色。
ggplot(tab7, aes(class,data)) + geom_line() + facet_grid(data~ .)
我收到如下错误:
geom_path: Each group consists of only one observation. Do you need to adjust the group aesthetic?
不清楚你在找什么,但好像是这样的:
tab7 %>%
pivot_longer(-class) %>%
select(class, value) %>%
ggplot(aes(value, class)) +
geom_point(aes(colour = class))