geom_mosaic:X轴刻度标签未显示?

时间:2020-03-27 22:05:25

标签: r ggplot2 mosaic-plot ggmosaic

我正在使用ggmosaic::geom_mosaic生成镶嵌图。我似乎无法获得自变量的值标签以显示在X轴上。该变量是一个标记的因子,其级别标记为“ 1”,“ 2”,“ 3”。我敢肯定这很愚蠢,但我不知道这是怎么回事。任何见识将不胜感激。

ggplot(data = mosaic)+
geom_mosaic(aes(x = product(X, Norm_Dx), fill=Norm_Dx), na.rm=TRUE)

enter image description here

2 个答案:

答案 0 :(得分:1)

我建议您使用mosaicplot

mosaicplot(table(X, Norm_Dx))

有关更多信息,请参阅this thread

答案 1 :(得分:1)

github问题似乎还没有得到解决...因此,对于任何渴望在ggplot中使用马赛克图并且无法从github获得更新工作的人,可以使用anateate:

?php
/**
 * Front to the WordPress application. This file doesn't do anything, but loads
 * wp-blog-header.php which does and tells WordPress to load the theme.
 *
 * @package WordPress
 */

/**
 * Tells WordPress to load the WordPress theme and output it.
 *
 * @var bool
 */
define( 'WP_USE_THEMES', true );

/** Loads the WordPress Environment and Template */
require __DIR__ . '/wp-blog-header.php';

enter image description here