在ggplot()或geom()中放置aes(x = ...)有什么区别(例如下面的geom_histogram()):
1。在ggplot()中:
ggplot(diamonds) +
geom_histogram(binwidth=500, aes(x=diamonds$price))+
xlab("Diamond Price U$") + ylab("Frequency")+
ggtitle("Diamond Price Distribution")
2。在geom()中:
ggplot(diamonds, aes(x=diamonds$price)) +
geom_histogram(bidwidth= 500) +
xlab("Price") + ylab("Frequncy") +
ggtitle("Diamonds Price distribution")
答案 0 :(得分:2)
如果您有多个具有不同映射的geom,那么您是将jQuery ->
$('#plan_material_tokens').tokenInput('/materials.json', { propertyToSearch: 'title' })
zindex: 6000
allowCustomEntry: false
preventDuplicates: true
prePopulate: $("#plan_material_tokens").data('pre')
置于原始x = price
调用还是特定ggplot()
中才真正重要。您在geom
调用中指定的映射将应用于所有geom,因此通常最好将映射放在顶层,如果只是为了节省您必须为每个单独的geom再次键入它。如果仅适用于特定ggplot()
,请在单个geom
中指定映射。
另请注意,它应该只是geom
,而不是aes(x = price)
。 aes(x = diamonds$price)
知道查看您正在使用的数据框作为ggplot
参数。如果你像data
那样手动传递矢量,你可能会在更复杂的情节中弄乱分面或分组。