如何用python显式绘制y轴

2024-05-12 17:59:52 发布

您现在位置:Python中文网/ 问答频道 /正文

我在python脚本中使用pp.yscale('log')来绘制一个图形,其中y个记号以logscale显示。但是,在图中,y轴没有出现。有没有什么方法可以在python中显式地显示y轴?在

enter image description here

...
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')
...

Tags: loglenunitppsetconfigurableappendidx