Gmail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
remove the legend but keeping the space
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  4 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Dani Linares  
View profile  
 More options May 20, 11:43 pm
From: Dani Linares <danilina...@gmail.com>
Date: Thu, 21 May 2009 13:43:14 +1000
Local: Wed, May 20 2009 11:43 pm
Subject: remove the legend but keeping the space
Hi all,

I think I read the answer in some place but I cant find it. Is there a
way to remove the legend but keeping the space associate to it?

 I have two plots in the same window. The legend is the same for both,
so I only want to display it in the first plot. The problem is that if
I use opts(legend.position="none") for the second plot, then this
second plot is bigger.

thanks

dani

--
Daniel Linares
web: www.dlinares.org


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Stavros Macrakis  
View profile  
 More options May 21, 8:44 am
From: Stavros Macrakis <macra...@gmail.com>
Date: Thu, 21 May 2009 08:44:45 -0400
Local: Thurs, May 21 2009 8:44 am
Subject: Re: remove the legend but keeping the space

I wonder if you can set the transparency of all the legend items to alpha=0
(fully transparent)....

             -s

On Wed, May 20, 2009 at 11:43 PM, Dani Linares <danilina...@gmail.com>wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
baptiste auguie  
View profile  
 More options May 21, 9:19 am
From: baptiste auguie <bapt4...@googlemail.com>
Date: Thu, 21 May 2009 15:19:24 +0200
Local: Thurs, May 21 2009 9:19 am
Subject: Re: remove the legend but keeping the space
Hi,

I can think of two situations but it's hard to tell without reproducible code,

1) the page layout is a result of facetting (possibly with a dummy
factor) or wrapping, in which case there should be one common legend
and its default position should be nicely aligned in the page

2) you don't want to use the first option, so you've placed two
unrelated ggplots on a page using grid.layout or other viewport
functions. Perhaps you can do something like this,

- create your two plots p1 and p2

- save the legend of p1 as a grob,

p3 <- p1 + opts(keep= "legend_box")

- strip the legend of p1 and p2,

p1 <- p1 + opts(legend.position = "none")
p2 <- p2 + opts(legend.position = "none")

- create three viewports on the page and print p1, p2, p3.

Example:

    dsamp <- diamonds[sample(nrow(diamonds), 1000), ]
    d <- qplot(carat, price, data=dsamp, colour=clarity)

        p3 <- d + opts(keep= "legend_box")

        p1 <- d + opts(legend.position = "none")
        p2 <- d + opts(legend.position = "none")

                p3

                pushViewport(viewport(x=0.4,y=0.75, width = 0.8, height = 0.5, angle = 0,
                name = "topleftvp"))
                grid.rect()    
                print(p1, vp="topleftvp")    
                upViewport()
                pushViewport(viewport(x=0.4,y=0.25, width = 0.8, height = 0.5, angle = 0,
                name = "botleftvp"))
                grid.rect()
                print(p2, vp="botleftvp")
                upViewport()

HTH,

baptiste

--

_____________________________

Baptiste Auguié

School of Physics
University of Exeter
Stocker Road,
Exeter, Devon,
EX4 4QL, UK

Phone: +44 1392 264187

http://newton.ex.ac.uk/research/emag
______________________________


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Dani Linares  
View profile  
 More options May 21, 11:14 am
From: Dani Linares <danilina...@gmail.com>
Date: Fri, 22 May 2009 01:14:26 +1000
Local: Thurs, May 21 2009 11:14 am
Subject: Re: remove the legend but keeping the space
On Thu, May 21, 2009 at 11:19 PM, baptiste auguie

<bapt4...@googlemail.com> wrote:
> Hi,

> I can think of two situations but it's hard to tell without reproducible code,

> 1) the page layout is a result of facetting (possibly with a dummy
> factor) or wrapping, in which case there should be one common legend
> and its default position should be nicely aligned in the page

> 2) you don't want to use the first option, so you've placed two
> unrelated ggplots on a page using grid.layout or other viewport
> functions. Perhaps you can do something like this,

Yes, that was the case. I used grid.layout. I should have specified
that. The below solution you proposed works. Thanks a lot.

dani

--
Daniel Linares
web: www.dlinares.org

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google