我想绘制每年的直方图,但是当我使用facet_grid或facet_wrap时,y轴变化的百分比。 您可以从here下载数据。
正常使用:
<VBox prefHeight="400.0" prefWidth="600.0">
<children>
<HBox style="-fx-background-color: green;" VBox.vgrow="SOMETIMES" />
<HBox style="-fx-background-color: blue;" VBox.vgrow="SOMETIMES" />
<HBox style="-fx-background-color: red;" VBox.vgrow="SOMETIMES" />
</children>
</VBox>
方面:
<VBox fx:id="vbox" fillWidth="false" prefHeight="400.0" prefWidth="600.0">
<children>
<HBox prefHeight="100.0" style="-fx-background-color: green;" VBox.vgrow="SOMETIMES" prefWidth="${vbox.width * 0.5}" />
<HBox prefHeight="100.0" style="-fx-background-color: blue;" VBox.vgrow="SOMETIMES" prefWidth="${vbox.width * 0.5}" />
<HBox prefHeight="100.0" style="-fx-background-color: red;" VBox.vgrow="SOMETIMES" prefWidth="${vbox.width * 0.5}" />
</children>
</VBox>
使用data <- gss %>%
select(year, educ, race) %>%
filter(race!="Other", year %in% 1972:1977)
ggplot(data %>% filter(year == 1972)) +
geom_histogram(data = data %>% filter(race=="Black"),
aes(y=(..count..)/sum(..count..), x=educ, fill="green"), alpha =.5) +
geom_histogram(data = data %>% filter(race=="White"),
aes(y=(..count..)/sum(..count..), x=educ, fill="red"), alpha =.5)
时如何防止轴改变?