使用matplotlib显示每行的最终y轴值 [英] Show the final y-axis value of each line with matplotlib

查看:248
本文介绍了使用matplotlib显示每行的最终y轴值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用matplotlib绘制带有一些线的图形,我想在每条线在右侧结束的位置旁边显示最终的y值,如下所示:

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:

是否有解决方案或指向API相关部分的指针?我很沮丧.

Any solutions or pointers to the relevant parts of the API? I'm quite stumped.

我正在使用matplotlib 1.0.0和pyplot接口,例如pyplot.plot(xs, ys, f, xs_, ys_, f_).

I'm using matplotlib 1.0.0 and the pyplot interface, e.g. pyplot.plot(xs, ys, f, xs_, ys_, f_).

推荐答案

选项1 - 选项2 -使用第二轴:

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

这篇关于使用matplotlib显示每行的最终y轴值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆