user113156
user113156

Reputation: 7147

Flip ggplot axis so that it makes more sense

I have the below plot

enter image description here

However the axis on the x axis is wrong, the 1 should be on the other side, however the actual plot itself should not move...

I used the following line;

ggroc(list(ROC_base = roc_base, ROC_optimised = roc_optimised))

I had a similar problem with the base R plot previously here. Using legacy.axes = TRUE solved the problem but I cannot find a solution in ggplot

Upvotes: 0

Views: 321

Answers (2)

GordonShumway
GordonShumway

Reputation: 2056

from the ggroc documentation (https://www.rdocumentation.org/packages/pROC/versions/1.11.0/topics/ggroc.roc) it looks like the solution should be the same as your solution with base R. Just add legacy.axes = TRUE

Upvotes: 5

divibisan
divibisan

Reputation: 12165

I believe you want to add scale_x_reverse() to your ggplot. This will flip the x-axis of the plot so that 1 is to the right and 0 is to the left. I haven't used ggroc before, but the normal way to add layers and options like this to a ggplot is with a +:

ggroc(list(ROC_base = roc_base, ROC_optimised = roc_optimised)) +
    scale_x_reverse()

Upvotes: 0

Related Questions