In the general case it is not possible to do as you ask because "Lab" can be
duplicated. However, in your specific case it is unique in your data frame, so
you just have to control the order of the factor labels instead of letting them
be set up in the default manner. Of course, you have to be a
The order the bars are plotted in is determined by the levels in a factor, and
your labels are treated as a factor. You can make sure you keep the order of
your labels by simply doing this:
Lab <- factor(Lab, levels = Lab)
before constructing the data frame.
Cheers
On 27 Jun 2017, 20.43 +0200
Thanks Jean, that worked!
On Tue, Jun 27, 2017 at 3:58 PM, Adams, Jean wrote:
> You just have to change the levels of the factor ...
>
> library(ggplot2)
>
> Lab = c(letters[4:6], letters[1:3])
> valuex = c(3.1,2.3,0.4,-0.4,-1.2,-4.4)
> df <- data.frame(Lab,valuex)
>
> # set the factor levels to
Hi,
I was trying to make a horizontal bar plot. The barplot works when the text
labels are of reasonable length, but not if some of them are slightly long.
I think the long ones get 'squeezed' by default before the plot is flipped
and keep the skew after the flip. Is there a way I can get around t
You just have to change the levels of the factor ...
library(ggplot2)
Lab = c(letters[4:6], letters[1:3])
valuex = c(3.1,2.3,0.4,-0.4,-1.2,-4.4)
df <- data.frame(Lab,valuex)
# set the factor levels to the same order as observed in the data frame
df$Lab <- factor(df$Lab, levels=unique(df$Lab))
p
Hi,
I was trying to draw a geom_bar plot. However, by default, the bars are
arranged according to the label, which I don't want. I want the bars to
appear exactly as they appear in the data frame. For example in the code:
Lab=c(letters[4:6],letters[1:3])
valuex = c(3.1,2.3,0.4,-0.4,-1.2,-4.4)
> -Original Message-
> From: j...@brf.dk
> Sent: Fri, 10 Aug 2012 10:05:32 +
> To: r-help@r-project.org
> Subject: [R] ggplot2 geom_bar produces white slashes in legend keys
>
> When I am using geom_bar I get these white slashes through the legend
> keys.
When I am using geom_bar I get these white slashes through the legend keys. I
cannot figure out how to remove them.
ggplot(diamonds, aes(clarity, fill=cut)) + geom_bar()
I have tried using opts(legend.key = theme_blank()) but with no luck.
Any suggestions would be much appreciated.
I am using R
On 23.04.2012 20:55, Brian Diggs wrote:
> On 4/23/2012 9:24 AM, Matthias Rieber wrote:
>> Hello,
>>
>> I've some problem with the ggplot2. Here's a small example:
>>
>> [...]
>> Is it wrong to use geom_bar with that kind of data? I could avoid this
>> issue when I cast the data.frame, but I like to
On 4/23/2012 9:24 AM, Matthias Rieber wrote:
Hello,
I've some problem with the ggplot2. Here's a small example:
--8<--
library(ggplot2)
molten<- data.frame(date=c('01','01','01','01',
'02','02','02','02'),
channel=c('red','red','blue','blue',
10 matches
Mail list logo