2017-06-23 5 views
10

मैं निम्नलिखित निबल है:कैसे x- अक्ष और y- अक्ष का विस्तार करने और ggthemes में अंतर संकीर्ण करने के लिए :: theme_tufte()


library(tidyverse) 
#> + ggplot2 2.2.1.9000  Date: 2017-06-23 
#> + tibble 1.3.3    R: 3.3.2 
#> + tidyr 0.6.3    GUI: X11 
#> + readr 1.1.1   Locale: en_US.UTF-8 
#> + purrr 0.2.2.2    TZ: Asia/Tokyo 
#> + dplyr 0.7.0   
#> + stringr 1.2.0 
#> Conflicts ----------------------------------------------------------------- 
#> * filter(), from dplyr, masks stats::filter() 
#> * lag(),  from dplyr, masks stats::lag() 
tbl <- structure(list(sample = c("Fx", "Vx"), nof_degs = c(6038L, 
3606L)), .Names = c("sample", "nof_degs"), class = c("tbl_df", 
"tbl", "data.frame"), row.names = c(NA, -2L)) 

tbl 
#> # A tibble: 2 x 2 
#> sample nof_degs 
#> <chr> <int> 
#> 1  Fx  6038 
#> 2  Vx  3606 
निम्नलिखित कोड के साथ

:

library(ggthemes) 
ggplot(tbl, aes(x=sample,y=nof_degs)) + 
geom_histogram(position=position_dodge(0.01), colour="black", stat="identity", width=0.2) + 
    geom_rangeframe() + 
    theme_tufte() + 
    theme(axis.ticks.length = unit(7, "pt")) 

के रूप में नीचे छवि में दिखाया:

enter image description here

उत्तर

9

मुझे जानते हैं अगर यह काफी करीब है:

ggplot(df, aes(x=sample,y=nof_degs)) + 
    geom_histogram(position=position_dodge(0.01), colour="black", 
       stat="identity", width=0.8) + 
    geom_rangeframe(y=c(0, max(df$nof_degs))) + 
    theme_tufte() + 
    theme(axis.ticks.length = unit(5, "pt")) 

enter image description here

एक अन्य विकल्प aspect.ratio साथ है:

ggplot(df, aes(x=sample,y=nof_degs)) + 
    geom_histogram(position=position_dodge(2), colour="black", 
       stat="identity", width = 0.6) + 
    geom_rangeframe(y=c(0, max(df$nof_degs))) + 
    theme_tufte() + 
    theme(aspect.ratio = 2) + 
    theme(axis.ticks.length = unit(5, "pt")) 

enter image description here

आप width के साथ चारों ओर खेल सकते हैं औरवांछित साजिश पाने के लिएपैरामीटर।

enter image description here

+1

धन्यवाद एक लाख: उदाहरण के width = 0.8 और aspect.ratio = 1.5 लिए। मैं बार पतला कैसे कर सकता हूं (25% पतला?) – neversaint

+1

'चौड़ाई' को शायद '0.6' तक घटाएं? – AK88

+1

मैंने आपके कोड के साथ 'geom_histogram (स्थिति = position_dodge (0.01), रंग =" काला ", stat =" पहचान ", चौड़ाई = 0.2)' कोशिश की। यह फिर से अंतर बढ़ाता है। मैंने किससे बचने की कोशिश की। – neversaint

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