Skip to content
Prev 336804 / 398513 Next

scatterplot of two y's

The quickest way, using the example data, would be

  matplot( df$x, df[,-1])

Obviously doesn't have the nice ggplot style, but it does do what was
requested. And depending on the context and ultimate goal, may be
sufficient.

Simple improvements are easy:

  matplot( df$x, df[,-1],
     xlab='x', ylab='y1, y2',
     pch=c(1,4) , main='My Data' )

-Don

p.s.
As a personal and editorial aside, I often think that amongst all of the
great extensions to R that have been developed over the years, the basics
get forgotten.