0

I have a data with following data in csv file

Name marks1 marks2

xy 10 30

yz 20 40

zx 30 40

vx 20 20

vt 10 20

How to draw a graph with both marks1 and marks2 in y axis and name in x axis

please help me

2
Contributors
1
Reply
21
Views
3 Years
Discussion Span
Last Post by L7Sqr
0

I'm not sure I understand your question. Does the following accomplish what you want?

d <- data.frame(
    cbind(
        Name=c('xy','yz','zx','vx','vt'),
        marks1=c(10,20,30,20,10),
        marks2=c(30,40,40,20,20)
    )
)
d$marks1 <- as.numeric(as.character(d$marks1))
d$marks2 <- as.numeric(as.character(d$marks2))
plot(0,type='n',xlim=c(1,5),ylim=c(0,50),axes=FALSE,xlab=NA,ylab=NA)
points(d$marks1 ~ d$Name,cex=1.5)
points(d$marks2 ~ d$Name,pch=19)
axis(1,at=1:5,labels=levels(d$Name))
axis(2)

It is very specific to your dataset so you would have to adjust if you provided a fake set of data. There is probably a way to condense that a bit with something like

plot(marks1 ~ Name, data = d)
points(marks2 ~ Name, data = d)

But I am having trouble formatting the first plot as points. If you follow the documentation for whichever plot.* is actually used for the formula version you may get the generic results you desire.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.