Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6920637
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T10:10:23+00:00 2026-05-27T10:10:23+00:00

I have generated a dendrogram using ggdendro and ggplot. I have two issues regarding

  • 0

I have generated a dendrogram using ggdendro and ggplot. I have two issues regarding the generated plot.

  1. Is that possible to cut some margin from the generated plot?
  2. How to change the font style, e.g., size, for the label along one axis?

In the plot, the two areas marked by “red pane” are the margins I would like to remove. The six labels along the x-axis is marked with yellow color. I would like to increase the size of them.

enter image description here

The code:

> x<-read.csv("test1.csv",header=TRUE)
> d<-as.dist(x,diag=FALSE,upper=FALSE)
> hc<-hclust(d,"ave")
> dhc<-as.dendrogram(hc)
> ddata<-dendro_data(dhc,type="rectangle")
> ddata$labels$text <- gsub("\\."," ",ddata$labels$text)
> fig1<-ggplot(segment(ddata))+geom_segment(aes(x=x0,y=y0,xend=x1,yend=y1))
> fig1<-fig1+xlab(NULL)+ylab(NULL)+opts(panel.grid.minor=theme_blank())
> fig1<-fig1+scale_x_discrete(limits=ddata$labels$text)
> fig1<-fig1+coord_flip()
> last_plot()
> fig1<-last_plot()
> ggsave("test1.pdf")
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T10:10:24+00:00Added an answer on May 27, 2026 at 10:10 am

    To increase the size of the axis labels (and much, much more) you use theme (in older versions of ggplot2 this was called opts()):

    + theme(axis.text.x = element_text(size = 12))
    

    will make them much bigger. For reducing the margins, you’ll may want to use the expand argument:

    + scale_x_continuous(expand = c(0,0))
    

    where the numbers are the additive and multiplicative expansion factors for the plot limits.

    More generally, these things are all quite well documented at locations like here or here. Or you could just buy Hadley’s book, which will answer nearly every ggplot question you’ll have. (Seriously.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have generated the following plot using the R code that follows it: ggplot(lengths,
I have generated some proxy classes that are consumed by a Java Service. (using
I have generated a collection of images. Some of them are blank as in
I have generated a C# SharePoint Sequential Workflow project using the very handy STSDEV
I have generated using openssl mycert.pem which contents the certificate. And I converted the
I have a generated txt file. This file has certain lines that are superfluous,
I have generated some scaffolding for my rails app. I am running the generated
I have generated a dataset that contains data spanning thirty days. Im trying to
I have generated a sample roo project using command prompt and then imported it
I have generated a minimum spanning tree using Kruskal's algorithm and I wanted to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.