如何使用python明确绘制y轴 [英] how to explicitly plot y axis with python

查看:54
本文介绍了如何使用python明确绘制y轴的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的 python 脚本中使用了 pp.yscale('log') 来绘制一个图形,其中 y 刻度以对数刻度显示.但是,图中未显示y轴.有没有办法在python中显式显示y轴?

I used pp.yscale('log') in my python script to plot a figure with y ticks shown in log scale. However, in the figure, the y axis does not appear. Is there any way to explicitly show y axis in python?

...
leg = pp.legend( series_labels, loc='upper right' )
pp.axis([-0.5, x_len-0.5, 0, max_y*1.1])   
configurable_xlabel = x_label + '(unit)'
pp.xlabel(configurable_xlabel)
configurable_ylabel = metrics[metric_idx] + '(unit)'
pp.ylabel(configurable_ylabel)
configurable_scaling = 2
xticklabels = []
for idx in xrange(0,x_len):
    if idx % configurable_scaling == 0:
        xticklabels.append(x_data[idx])
    else:
        xticklabels.append('');
pp.axes().set_xticks(xrange(0,x_len));
pp.axes().set_xticklabels(xticklabels[0:len(xticklabels)])
pp.yscale('log')
...

推荐答案

我在 这个问题的重复 可能是由于对数刻度没有 0 并进一步建议人们可以将轴移动到另一个数字.我没有办法检查,但是 Richard 表示这是一种解决方案.我希望是:-}

I suggested on a duplicate of this question that it might be due to logarithmic scales having no 0 and suggested further that one might be able to move the axis to another number. I have no way to check this but Richard stated that this is a solution. I hope it is :-}

这篇关于如何使用python明确绘制y轴的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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