The labeling_args parameter appears to be returning NULL, and the reason for this behavior eludes me.
Additionally, despite attempting to specify colors for both countries, the plot only assigns color to Italy, not to China. I’m unsure why this discrepancy exists.
<code>library(vcd)
data <- matrix(c(43649, 7669, 1023, 357), nrow = 2, byrow = TRUE)
rownames(data) <- c("China", "Italy")
colnames(data) <- c("Survivor", "Death")
largs <- list(set_varnames = list(Country = rownames(data), Result = colnames(data)))
mosaic(data,
labeling_args = largs,
shade = TRUE,
main = "Mosaicplot for COVID-19 Data",
xlab = "Result", ylab = "Country", legend = FALSE)
</code>
<code>library(vcd)
data <- matrix(c(43649, 7669, 1023, 357), nrow = 2, byrow = TRUE)
rownames(data) <- c("China", "Italy")
colnames(data) <- c("Survivor", "Death")
largs <- list(set_varnames = list(Country = rownames(data), Result = colnames(data)))
mosaic(data,
labeling_args = largs,
shade = TRUE,
main = "Mosaicplot for COVID-19 Data",
xlab = "Result", ylab = "Country", legend = FALSE)
</code>
library(vcd)
data <- matrix(c(43649, 7669, 1023, 357), nrow = 2, byrow = TRUE)
rownames(data) <- c("China", "Italy")
colnames(data) <- c("Survivor", "Death")
largs <- list(set_varnames = list(Country = rownames(data), Result = colnames(data)))
mosaic(data,
labeling_args = largs,
shade = TRUE,
main = "Mosaicplot for COVID-19 Data",
xlab = "Result", ylab = "Country", legend = FALSE)
Recognized by R Language Collective
New contributor
דניאל שוורץ is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
Try this to fix the labels:
<code>largs <- list(set_varnames = c(A = "Country", B = "Result"))
mosaic(data,
labeling_args = largs,
shade = TRUE,
main = "Mosaicplot for COVID-19 Data",
xlab = "Result", ylab = "Country")
</code>
<code>largs <- list(set_varnames = c(A = "Country", B = "Result"))
mosaic(data,
labeling_args = largs,
shade = TRUE,
main = "Mosaicplot for COVID-19 Data",
xlab = "Result", ylab = "Country")
</code>
largs <- list(set_varnames = c(A = "Country", B = "Result"))
mosaic(data,
labeling_args = largs,
shade = TRUE,
main = "Mosaicplot for COVID-19 Data",
xlab = "Result", ylab = "Country")
To change the colours see this post
- How to change color palette of mosaic plot
Recognized by R Language Collective