2015-12-18 16 views
5

मैं साजिश करना चाहते हैं, ggplot2 के साथ, इस तरह के भ्रम मैट्रिक्स के साथ:geom_raster() कोई पैडिंग और कोई कथा

# Original data 
samples <- t(rmultinom(50, size = 7, prob = rep(0.1,10))) 

# Co-ocurrence matrix 
coincidences <- sapply(1:ncol(samples), function(i){ colSums(samples[,i]==samples) }) 

अगर मैं geom_roster का उपयोग करें:

p <- ggplot(melt(coincidences), aes(Var1,Var2, fill=value)) + geom_raster() 

मैं इस मिल: enter image description here

मैं इसे कैसे प्राप्त कर सकता हूं? (कोई किंवदंतियों, कोई पैडिंग) enter image description here

उत्तर

7

आप scale_fill_continuous(guide = FALSE) का उपयोग कथा दूर करने के लिए करना चाहिए। तब सभी गद्दी (कुल्हाड़ियों, लेबल, आदि) आप इस लंबे theme() आदेश का उपयोग कर सकते हैं से छुटकारा पाने के:

require(ggplot2) 
# Original data 
samples <- t(rmultinom(50, size = 7, prob = rep(0.1,10))) 

# Co-ocurrence matrix 
coincidences <- sapply(1:ncol(samples), function(i) { 
    colSums(samples[,i]==samples) 
}) 

p <- ggplot(melt(coincidences), aes(Var1, Var2, fill = value)) + 
    geom_raster() + 
    scale_fill_continuous(guide = FALSE) + 
    theme(axis.text  = element_blank(), 
     axis.ticks  = element_blank(), 
     axis.title  = element_blank(), 
     panel.background = element_blank()) 

enter image description here

+0

तुम भी केवल 'axis.text' दोनों' अक्ष के बजाय इस्तेमाल कर सकते हैं। text.x' और 'axis.text.y'। 'Axis.text' का उपयोग करते समय, आप एक ही समय में एक्स और वाई अक्ष के लिए सेटिंग निर्दिष्ट करते हैं। – Jaap

+0

@ जैप अच्छा बिंदु। मैंने तदनुसार जवाब बदल दिया। – christoph

संबंधित मुद्दे