अंतिम कार्यान्वयन भी कई अंकों के साथ क्षेत्र भरें - समाप्त नहीं हुआ है, लेकिन सही तरीके से बढ़ रहाभूखंड/ggplot2 -
आइडिया/समस्या: आप कई अतिव्यापी अंकों के साथ एक साजिश है और उन्हें एक से बदलना चाहते हैं सादा क्षेत्र, इसलिए साजिश देखने में प्रदर्शन बढ़ रहा है।
संभावित कार्यान्वयन: सभी बिंदुओं के बीच दूरी मैट्रिक्स की गणना करें और निर्दिष्ट दूरी के नीचे सभी बिंदुओं को कनेक्ट करें।
टोडो/समाप्त नहीं हुआ: यह वर्तमान में मुद्रित साजिश के आकार के आधार पर मैन्युअल रूप से दूरी निर्धारित करने के लिए काम करता है। मैंने यहां रुक दिया क्योंकि परिणाम मेरी सौंदर्य भावना को पूरा नहीं कर पाया।
मध्यवर्ती भूखंडों
set.seed(074079089)
n.points <- 3000
mat <- matrix(rnorm(n.points*2, 0,0.2), nrow=n.points, ncol=2)
colnames(mat) <- c("x", "y")
d.mat <- dist(mat)
fit.mat <-hclust(d.mat, method = "single")
lims <- c(-1,1)
real.lims <- lims*1.1 ## ggplot invokes them approximately
# An attempt to estimate the point-sizes, works for default pdfs pdf("test.pdf")
cutsize <- sum(abs(real.lims))/100
groups <- cutree(fit.mat, h=cutsize) # cut tree at height cutsize
# plot(fit.mat) # display dendogram
# draw dendogram with red borders around the 5 clusters
# rect.hclust(fit.mat, h=cutsize, border="red")
library(ggplot2)
df <- data.frame(mat)
df$groups <- groups
plot00 <- ggplot(data=df, aes(x,y, col=factor(groups))) +
geom_point() + guides(col=FALSE) + xlim(lims) + ylim(lims)+
ggtitle("Each color is a group")
pdf("plot00.pdf")
print(plot00)
dev.off()
# If less than 4 points are connected, show them seperately
t.groups <- table(groups) # how often which group
drop.group <- as.numeric(names(t.groups[t.groups<4])) # groups with less than 4 points are taken together
groups[groups %in% drop.group] <- 0 # in group 0
df$groups <- groups
plot01 <- ggplot(data=df, aes(x,y, col=factor(groups))) +
geom_point() + xlim(lims)+ ylim(lims) +
scale_color_hue(l=10)
pdf("plot01.pdf")
print(plot01)
dev.off()
find_hull <- function(df_0)
{
return(df_0[chull(df_0$x, df_0$y), ])
}
library(plyr)
single.points.df <- df[df$groups == 0 , ]
connected.points.df <- df[df$groups != 0 , ]
hulls <- ddply(connected.points.df, "groups", find_hull) # for all groups find a hull
plot02 <- ggplot() +
geom_point(data=single.points.df, aes(x,y, col=factor(groups))) +
xlim(lims)+ ylim(lims) +
scale_color_hue(l=10)
pdf("plot02.pdf")
print(plot02)
dev.off()
साथ कम से कम उदाहरण
plot03 <- plot02
for(grp in names(table(hulls$groups)))
{
plot03 <- plot03 + geom_polygon(data=hulls[hulls$groups==grp, ],
aes(x,y), alpha=0.4)
}
# print(plot03)
plot01 <- plot01 + theme(legend.position="none")
plot03 <- plot03 + theme(legend.position="none")
# multiplot(plot01, plot03, cols=2)
pdf("plot03.pdf")
print(plot03)
dev.off()
प्रारंभिक प्रश्न
मैं एक (शायद अजीब) प्रश्न है।
कुछ भूखंडों में, मेरे विश्लेषण में हजारों अंक हैं। उन्हें प्रदर्शित करने के लिए, पीसी को काफी समय लगता है क्योंकि बहुत सारे अंक हैं। अब के बाद, इनमें से कई बिंदु ओवरलैप हो सकते हैं, मेरे पास एक भरा क्षेत्र है (जो ठीक है!)। समय/प्रयास को प्रदर्शित करने के लिए, यह केवल इस क्षेत्र को भरने के लिए उपयोगी होगा लेकिन प्रत्येक बिंदु को अपने आप पर प्लॉट करना होगा।
मुझे पता है कि हीटमैप में संभावनाएं हैं और इसी तरह, लेकिन यह विचार मेरे मन में नहीं है। मेरा विचार कुछ ऐसा है:
#plot00: ggplot with many many points and a filled area of points
plot00 <- plot00 + fill.crowded.areas()
# with plot(), I sadly have an idea how to manage it
कोई विचार? या यह कुछ भी कभी भी नहीं करेगा?
# Example code
# install.packages("ggplot2")
library(ggplot2)
n.points <- 10000
mat <- matrix(rexp(n.points*2), nrow=n.points, ncol=2)
colnames(mat) <- c("x", "y")
df <- data.frame(mat)
plot00 <- ggplot(df, aes(x=x, y=y)) +
theme_bw() + # white background, grey strips
geom_point(shape=19)# Aussehen der Punkte
print(plot00)
# NO ggplot2
plot(df, pch=19)
संपादित करें:
घनत्व-भूखंडों करवाने के लिए fdetsch (कैसे मैं नाम चिह्नित कर सकते हैं?) वहाँ कुछ इस विषय में सवाल कर रहे हैं ने उल्लेख की तरह विषय। लेकिन यह वही बात नहीं है जो मैं चाहता हूं। मुझे पता है कि मेरी चिंता थोड़ा अजीब है, लेकिन घनत्व कभी-कभी ज़रूरी ज़रूरी ज़रूरी व्यस्त रहता है।घनत्व के साथ विषयों के लिए
लिंक:
Scatterplot with too many points
High Density Scatter Plots
पर एक नज़र क्या आप के लिए पूछ कठिन है क्योंकि एक प्रतिपादन है ठोस ब्लॉक आपके द्वारा चुने गए ग्राफ़िकल पैरामीटर (जैसे बिंदु आकार) पर निर्भर करता है। ठोस क्षेत्रों को बनाने के लिए आपको भौगोलिक सूचना प्रणाली के समान बिंदुओं को एक परत में बफर करने की आवश्यकता है - [यह प्रश्न] (https://stackoverflow.com/questions/25411251/buffer-geospatial-points-in-r -with-gbuffer) मदद कर सकता है। – geotheory