[R] ggplot2: remove axis ticks

William Dunlap wdunlap at tibco.com
Mon Dec 7 16:44:25 CET 2015


Change the order of adding the themes from
   theme(axis.ticks=element_blank()) + theme_bw()
to
   theme_bw() + theme(axis.ticks=element_blank())
because theme_bw() adds axis.ticks = element_line(colour = "black").
Bill Dunlap
TIBCO Software
wdunlap tibco.com


On Mon, Dec 7, 2015 at 7:10 AM, Brian Smith <bsmith030465 at gmail.com> wrote:
> Hi,
>
> I was trying to remove the axis tick marks and their values using theme()
> but haven't had much success. Here is sample code:
>
> rx <- sample(1:100,10)
> ry <- sample(1:100,10)
> rz <- sample(letters[1:3],10,replace=T)
> rdf <- data.frame(rx,ry,rz)
>
> p <- ggplot(rdf,aes(x=rx,y=ry))
> p1 <- p + geom_point(aes(shape=factor(rz),colour=factor(rz)),size=6) +
>     theme(axis.ticks = element_blank(), axis.text.x =
> element_blank(),axis.text.y = element_blank()) +
>     scale_shape_manual(values=rz)  + theme_bw() +
>     labs(colour='rz',shape='rz')
> p1
>
>
> My session info:
>
>> sessionInfo()
> R version 3.2.2 (2015-08-14)
> Platform: x86_64-apple-darwin13.4.0 (64-bit)
> Running under: OS X 10.10.5 (Yosemite)
>
> locale:
> [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
>
> attached base packages:
>  [1] grid      stats4    parallel  stats     graphics  grDevices utils
> datasets  methods   base
>
> other attached packages:
>  [1] IlluminaHumanMethylation450kmanifest_0.4.0 biomaRt_2.26.1
>
>  [3] data.table_1.9.6                           foreign_0.8-65
>
>  [5] preprocessCore_1.32.0                      gtools_3.5.0
>
>  [7] BiocInstaller_1.20.1                       ggdendro_0.1-17
>
>  [9] reshape_0.8.5                              RnBeads_1.2.0
>
> [11] plyr_1.8.3                                 methylumi_2.16.0
>
> [13] minfi_1.16.0                               bumphunter_1.10.0
>
> [15] locfit_1.5-9.1                             iterators_1.0.8
>
> [17] foreach_1.4.3                              Biostrings_2.38.2
>
> [19] XVector_0.10.0                             SummarizedExperiment_1.0.1
>
> [21] lattice_0.20-33
>  FDb.InfiniumMethylation.hg19_2.2.0
> [23] org.Hs.eg.db_3.2.3                         RSQLite_1.0.0
>
> [25] DBI_0.3.1
>  TxDb.Hsapiens.UCSC.hg19.knownGene_3.2.2
> [27] GenomicFeatures_1.22.5                     AnnotationDbi_1.32.0
>
> [29] reshape2_1.4.1                             scales_0.3.0
>
> [31] Biobase_2.30.0                             illuminaio_0.12.0
>
> [33] matrixStats_0.15.0                         limma_3.26.3
>
> [35] gridExtra_2.0.0                            gplots_2.17.0
>
> [37] ggplot2_1.0.1                              fields_8.3-5
>
> [39] maps_3.0.0-2                               spam_1.3-0
>
> [41] ff_2.2-13                                  bit_1.1-12
>
> [43] cluster_2.0.3                              RColorBrewer_1.1-2
>
> [45] MASS_7.3-43                                GenomicRanges_1.22.1
>
> [47] GenomeInfoDb_1.6.1                         IRanges_2.4.4
>
> [49] S4Vectors_0.8.3                            BiocGenerics_0.16.1
>
>
> loaded via a namespace (and not attached):
>  [1] nlme_3.1-121            bitops_1.0-6            tools_3.2.2
>   doRNG_1.6
>  [5] nor1mix_1.2-1           KernSmooth_2.23-15      colorspace_1.2-6
>  base64_1.1
>  [9] chron_2.3-47            pkgmaker_0.22           labeling_0.3
>  rtracklayer_1.30.1
> [13] caTools_1.17.1          genefilter_1.52.0       quadprog_1.5-5
>  stringr_1.0.0
> [17] digest_0.6.8            Rsamtools_1.22.0        siggenes_1.44.0
>   GEOquery_2.36.0
> [21] mclust_5.1              BiocParallel_1.4.0      RCurl_1.95-4.7
>  magrittr_1.5
> [25] futile.logger_1.4.1     Rcpp_0.12.2             munsell_0.4.2
>   proto_0.3-10
> [29] stringi_1.0-1           zlibbioc_1.16.0         gdata_2.17.0
>  splines_3.2.2
> [33] multtest_2.26.0         annotate_1.48.0         beanplot_1.2
>  igraph_1.0.1
> [37] corpcor_1.6.8           rngtools_1.2.4          codetools_0.2-14
>  mixOmics_5.2.0
> [41] futile.options_1.0.0    XML_3.98-1.3            lambda.r_1.1.7
>  gtable_0.1.2
> [45] xtable_1.8-0            survival_2.38-3         ellipse_0.3-8
>   GenomicAlignments_1.6.1
> [49] registry_0.3            rgl_0.95.1201
>
>
> Am I setting the arguments for theme() incorrectly?
>
> many thanks,
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list