data<-iris
plot(data$Sepal.Length, data$Sepal.Width, col=data$Species)
legend(7,4.3,unique(data$Species),col=1:length(data$Species),pch=1)
should do it for you. But I prefer ggplot2
and would suggest that for better graphics in R.
More Related Contents:
- Plot multiple lines (data series) each with unique color in R
- Plot with conditional colors based on values in R [duplicate]
- ggplot2: How to specify multiple fill colors for points that are connected by lines of different colors
- Colour points in a plot differently depending on a vector of values
- Creating a vertical color gradient for a geom_bar plot
- Cleaning up factor levels (collapsing multiple levels/labels)
- Save a plot in an object
- Remove space between plotted data and the axes
- Wrap long axis labels via labeller=label_wrap in ggplot2
- What do hjust and vjust do when making a plot using ggplot?
- asymmetric color distribution in scale_gradient2?
- Reduce PDF file size of plots by filtering hidden objects
- Pretty ticks for log normal scale using ggplot2 (dynamic not manual)
- Why does as.factor return a character when used inside apply?
- How to change order of boxplots when using ggplot2?
- Stacked barplot with colour gradients for each bar
- R package lattice won’t plot if run using source()
- Expand spacing between tick marks on x axis
- Increase resolution of color scale for values close to zero
- R: Plotting a 3D surface from x, y, z
- Add error bars to show standard deviation on a plot in R
- Directly creating dummy variable set in a sparse matrix in R
- Creating a Plot Window of a Particular Size
- How to fill with different colors between two lines? (originally: fill geom_polygon with different colors above and below y = 0 (or any other value)?)
- Create frequency tables for multiple factor columns in R
- Plotting during a loop in RStudio
- Control the size of points in an R scatterplot?
- Is there a way to output text to the R console in color
- Special characters and superscripts on plot axis titles
- Remove unused factor levels from a ggplot bar plot