Reverse order of discrete y axis in ggplot2

前端 未结 6 710
情歌与酒
情歌与酒 2020-12-01 06:10

Situation & data

I have a dataframe df of athlete positions in a race (I\'ve already melted it for use with ggpl

6条回答
  •  无人及你
    2020-12-01 06:42

    For a discrete axis, using reorder() worked for me. In context of the above problem, it would look something like this:

    ggplot(df, aes(x = distanceRemaining, y = reorder(position, desc(position))))
    

    Hope this helps.

提交回复
热议问题