1

I am new to ggplot2 graphics in R. I need to create a graph in the picture.

enter image description here

It's comparison between sensitivity and specificity for each rule. I have 20 rules for each model on average. It is easiest way to compare quality of generated rules than searching results in tables.

my input will be data frame with 3 columns: 1 character(or factor) and 2 numeric.

this is my R version and OS:

R version 3.3.1 (2016-06-21)
OS X 10.12.2 (Sierra).
ggplot2_2.1.0

Any tips would be appreciated.

3
  • I answered your question, but for the next time you should have an example dataset :D Commented Dec 26, 2016 at 13:59
  • Thank you for the answer and advice :D Commented Dec 26, 2016 at 17:19
  • No problem, happy to help Commented Dec 26, 2016 at 17:46

1 Answer 1

1

This is how you do it

library(ggplot2)

df<- data.frame(rule = c("rule 1", "rule 2", "rule 1"), value = c(-0.8, 0.55, 0.8), qualityMeasure = c("FPR", "TPR", "TPR"))

dat1 <- subset(df,value >= 0)
dat2 <- subset(df,value < 0)

ggplot() + geom_bar(data = dat2, stat = "identity", aes(x = rule, y = value, fill = qualityMeasure)) + geom_bar(data = dat1, stat = "identity", aes(x = rule, y = value, fill = qualityMeasure)) + coord_flip()
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.