पर लेबल जोड़ें मैं पहलू पाई चार पर डेटा लेबल जोड़ना चाहता हूं।
शायद कोई मेरी मदद कर सकता है।आर + ggplot2 => पहलू पाई चार्ट
मेरे डेटा:
year <- c(1,2,1,2,1,2)
prod <- c(1,1,2,2,3,3)
quantity <- c(33,50,33,25,34,25)
df <- data.frame(year, prod, quantity)
rm(year, prod, quantity)
कोड:
library(ggplot2)
# center's calculated by hand
centr2 <- c(16, 25, 49, 62.5, 81, 87.5)
ggplot(data=df, aes(x=factor(1), y=quantity, fill=factor(prod))) +
geom_bar(stat="identity") +
geom_text(aes(x= factor(1), y=centr2, label = df$quantity), size=10) +
facet_grid(facets = .~year, labeller = label_value) +
coord_polar(theta = "y")
और मेरे परिणाम है:
अगर मैं coord_polar हटाने (थीटा = "y"), मैं निम्नलिखित प्लॉट होगा:
और अब यह मेरे लिए स्पष्ट है, मेरे डेटा लेबल क्यों मेल नहीं खाते।
लेकिन मुझे नहीं पता कि इसे कैसे ठीक किया जाए।
मैंने पढ़ा:
1. Place labels on Pie Chart
2. Add text to ggplot with facetted densities
3. Pie plot getting its text on top of each other
लेकिन जवाब नहीं मिला।
आप कैसे आप संख्या की स्थिति की गणना पर औचित्य समझा सकते हैं? – Kots