Hi
To rotate plot to get levels on Y axis use coord_flip
ggplot(dat2, aes(N, value, colour = variable, group = variable)) +
geom_point() + geom_line()+coord_flip()
Cheers
Petr
Tento e-mail a jak?koliv k n?mu p?ipojen? dokumenty jsou d?v?rn? a podl?haj?
tomuto pr?vn? z?vazn?mu prohl??en? o vylou?en? odpov?dnosti:
https://www.precheza.cz/01-dovetek/ | This email and any documents attached to
it may be confidential and are subject to the legally binding disclaimer:
https://www.precheza.cz/en/01-disclaimer/
> -----Original Message-----
> From: R-help [mailto:r-help-bounces at r-project.org] On Behalf Of John
Kane via
> R-help
> Sent: Wednesday, May 23, 2018 12:41 PM
> To: Jim Lemon <drjimlemon at gmail.com>; R-help <r-help at
r-project.org>;
> Pedro p?ramo <percentil101 at gmail.com>
> Subject: Re: [R] Plot qualitative y axis
>
> Hi Pedro,
> melt() is probably working. The problem is I did not finish the copy and
> paste. It would have been better if I had included the ggplot() command.
>
> Try
> =============================================================>
library(reshape2)
> library(ggplot2)
>
> dat1 <- structure(list(N = c("I", "II",
"III", "IV", "V", "VI", "VII",
"VIII", "IX", "X",
> "XI", "XII", "XIII", "XIV"), M =
c(10L, 124L, 321L, 777L, 896L, 1706L, 635L, 1437L,
> 693L, 1343L, 1221L, 25L, 3L, 7L), W = c(106L, 484L, 874L, 1140L, 996L,
1250L,
> 433L, 654L, 333L, 624L, 611L, 15L, NA, 8L)), .Names = c("N",
"M", "W"), class > "data.frame", row.names =
c(NA,
> -14L))
>
> dat2 <- melt(dat1)
>
> ggplot(dat2, aes(N, value, colour = variable, group = variable)) +
> geom_point() + geom_line()
> ============================================================> I feel
very stupid.
>
> On Tuesday, May 22, 2018, 10:40:09 p.m. EDT, Pedro p?ramo
> <percentil101 at gmail.com> wrote:
>
> Many thanks,
>
> My goal is to make a plott like attached but the Y axis starts in XIV and
end at
> top in I. Generally for instance in excel X axis is categories but Y axis
is numbers
> I want the contrary plotted in lines, your last help is near what I look
but
> barplot is not needed.
>
> Hope you can help me thanks in advance.
>
> 2018-05-22 0:58 GMT+02:00 Jim Lemon <drjimlemon at gmail.com>:
>
> > Hi Pedro,
> > In addition to the other suggestions, here's a guess at what you
want
> > by the lines for M and W:
> >
> > ppdf<-read.table(text="N M W
> > I 10 106
> > II 124 484
> > III 321 874
> > IV 777 1140
> > V 896 996
> > VI 1706 1250
> > VII 635 433
> > VIII 1437 654
> > IX 693 333
> > X 1343 624
> > XI 1221 611
> > XII 25 15
> > XIII 3 NA
> > XIV 7 8",
> > header=TRUE)
> > barpos<-barplot(t(as.matrix(ppdf[,2:3])),horiz=TRUE,
> > names.arg=ppdf$N,beside=TRUE,col=c("red","blue"))
> >
legend(1000,8,c("W","M"),fill=c("blue","red"))
> > lines(ppdf$W,barpos[2,],col="blue")
> > lines(ppdf$M,barpos[1,],col="red")
> >
> > Jim
> >
> >
> > On Mon, May 21, 2018 at 10:44 PM, Pedro p?ramo
> > <percentil101 at gmail.com>
> > wrote:
> > > Hi all,
> > >
> > > I?m trying to plot this data
> > >
> > > N M W
> > > I 10 106
> > > II 124 484
> > > III 321 874
> > > IV 777 1140
> > > V 896 996
> > > VI 1706 1250
> > > VII 635 433
> > > VIII 1437 654
> > > IX 693 333
> > > X 1343 624
> > > XI 1221 611
> > > XII 25 15
> > > XIII 3
> > > XIV 7 8
> > > So that in de Y axis will be the level (qualitative data) and in
the
> > > X
> > axis
> > > will be M and W variables. So x axis will be wwith a lenght
between
> > > 0 and 2000.
> > >
> > > I would like to plot a line with M and other with W so it will be
> > > obvious that above V (in the Y axis) thera are more W and below
> > > level V there are more M.
> > >
> > > Can you please guide me?
> > >
> > > In excel putting Y as X axis is easy but dind?nt achieve to
invert
> > > rows
> > and
> > > I ?m trying to plot it in R.
> > >
> > > Many thanks in advance
> > >
> > > [[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.
> >
>
> [[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.
> [[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.
________________________________
Tento e-mail a jak?koliv k n?mu p?ipojen? dokumenty jsou d?v?rn? a jsou ur?eny
pouze jeho adres?t?m.
Jestli?e jste obdr?el(a) tento e-mail omylem, informujte laskav? neprodlen? jeho
odes?latele. Obsah tohoto emailu i s p??lohami a jeho kopie vyma?te ze sv?ho
syst?mu.
Nejste-li zam??len?m adres?tem tohoto emailu, nejste opr?vn?ni tento email
jakkoliv u??vat, roz?i?ovat, kop?rovat ?i zve?ej?ovat.
Odes?latel e-mailu neodpov?d? za eventu?ln? ?kodu zp?sobenou modifikacemi ?i
zpo?d?n?m p?enosu e-mailu.
V p??pad?, ?e je tento e-mail sou??st? obchodn?ho jedn?n?:
- vyhrazuje si odes?latel pr?vo ukon?it kdykoliv jedn?n? o uzav?en? smlouvy, a
to z jak?hokoliv d?vodu i bez uveden? d?vodu.
- a obsahuje-li nab?dku, je adres?t opr?vn?n nab?dku bezodkladn? p?ijmout;
Odes?latel tohoto e-mailu (nab?dky) vylu?uje p?ijet? nab?dky ze strany p??jemce
s dodatkem ?i odchylkou.
- trv? odes?latel na tom, ?e p??slu?n? smlouva je uzav?ena teprve v?slovn?m
dosa?en?m shody na v?ech jej?ch n?le?itostech.
- odes?latel tohoto emailu informuje, ?e nen? opr?vn?n uzav?rat za spole?nost
??dn? smlouvy s v?jimkou p??pad?, kdy k tomu byl p?semn? zmocn?n nebo p?semn?
pov??en a takov? pov??en? nebo pln? moc byly adres?tovi tohoto emailu p??padn?
osob?, kterou adres?t zastupuje, p?edlo?eny nebo jejich existence je adres?tovi
?i osob? j?m zastoupen? zn?m?.
This e-mail and any documents attached to it may be confidential and are
intended only for its intended recipients.
If you received this e-mail by mistake, please immediately inform its sender.
Delete the contents of this e-mail with all attachments and its copies from your
system.
If you are not the intended recipient of this e-mail, you are not authorized to
use, disseminate, copy or disclose this e-mail in any manner.
The sender of this e-mail shall not be liable for any possible damage caused by
modifications of the e-mail or by delay with transfer of the email.
In case that this e-mail forms part of business dealings:
- the sender reserves the right to end negotiations about entering into a
contract in any time, for any reason, and without stating any reasoning.
- if the e-mail contains an offer, the recipient is entitled to immediately
accept such offer; The sender of this e-mail (offer) excludes any acceptance of
the offer on the part of the recipient containing any amendment or variation.
- the sender insists on that the respective contract is concluded only upon an
express mutual agreement on all its aspects.
- the sender of this e-mail informs that he/she is not authorized to enter into
any contracts on behalf of the company except for cases in which he/she is
expressly authorized to do so in writing, and such authorization or power of
attorney is submitted to the recipient or the person represented by the
recipient, or the existence of such authorization is known to the recipient of
the person represented by the recipient.