Show the final y-axis value of each line with matplotlib

前端 未结 3 661
旧巷少年郎
旧巷少年郎 2020-12-11 04:57

I\'m drawing a graph with some lines using matplotlib and I want to display the final y value next to where each line ends on the right hand side like this:

3条回答
  •  误落风尘
    2020-12-11 05:49

    Option 1 - pyplot.text

    pyplot.text(x, y, string, fontdict=None, withdash=False, **kwargs)
    

    Option 2 - Use a second axes:

    second_axes = pyplot.twinx() # create the second axes, sharing x-axis
    second_axis.set_yticks([0.2,0.4]) # list of your y values
    pyplot.show() # update the figure
    

提交回复
热议问题