Plot Legend
Are you sure you are using the data set mtcars? That data set doesn't
have variables Na or K nor does it look like what you provided...
For the real mtcars, you could try this which I think does something
like what you want.
with(mtcars, plot(cyl, mpg, pch = carb, col = gear))
with(mtcars, legend("top", legend = unique(carb), pch = unique(carb)))
with(mtcars, legend("bottom", legend = unique(gear), pch = 20, col =
unique(gear)))
Michael
On Mon, Oct 24, 2011 at 6:21 AM, RMSOPS <ricardosousa2000 at clix.pt> wrote:
Good Afternoon, I am inexperienced in data visualization R. so I wonder if someone can help me. I am using the generic database mtcars. I would like to change the chart plot, instead of appearing the name of the medicine, I wanted a symbol in the chart drugX arise for example in a yellow circle, and so for the rest of the drugs. I am using the following code. dataset ? ?Age Sex ? ? BP Cholesterol ? ? ? Na ? ? ? ?K ?Drug 1 ? ?23 ? F ? HIGH ? ? ? ?HIGH 0.792535 0.031258 drugY 2 ? ?47 ? M ? ?LOW ? ? ? ?HIGH 0.739309 0.056468 drugC 3 ? ?47 ? M ? ?LOW ? ? ? ?HIGH 0.697269 0.068944 drugC 4 ? ?28 ? F NORMAL ? ? ? ?HIGH 0.563682 0.072289 drugX 5 ? ?61 ? F ? ?LOW ? ? ? ?HIGH 0.559294 0.030998 drugY 6 ? ?22 ? F NORMAL ? ? ? ?HIGH 0.676901 0.078647 drugX 7 ? ?49 ? F NORMAL ? ? ? ?HIGH 0.789637 0.048518 drugY 8 ? ?41 ? M ? ?LOW ? ? ? ?HIGH 0.766635 0.069461 drugC 9 ? ?60 ? M NORMAL ? ? ? ?HIGH 0.777205 0.051230 drugY 10 ? 43 ? M ? ?LOW ? ? ?NORMAL 0.526102 0.027164 drugY 11 ? 47 ? F ? ?LOW ? ? ? ?HIGH 0.896056 0.076147 drugC plot(dataset$Na, dataset$K, main="Na vs K", ? xlab="Na", ylab="K", pch=20, col="blue") ?text(dataset$Na,dataset$K,dataset$Drug, cex=0.6, pos=4, col="red") The idea is that instead of writing the name had to be a legend and symbol was designed in a different color for each drug Thanks -- View this message in context: http://r.789695.n4.nabble.com/Plot-Legend-tp3932687p3932687.html Sent from the R help mailing list archive at Nabble.com.
______________________________________________ R-help at r-project.org mailing list 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.