Replacing ggplot2 legend key for geom_line with symbol

后端 未结 2 408
暗喜
暗喜 2021-01-07 10:30

I have a line plot of prices for three stocks, which I normalise by taking the percentage change from the beginning of the period I am looking at. This seems to work fine, b

2条回答
  •  灰色年华
    2021-01-07 11:19

    In ggplot the legend matches the plot itself. So, to get circles or squares in the legend you need to add circles or squares to the plot.

    This can be done with geom_point(shape=...). shape=1 generates circles, shape=7 generates squares.

    chart1 + geom_point(shape=7)
    

    enter image description here

提交回复
热议问题