Pythonnvd3,如何将xaxis设置为logs

2024-06-16 13:52:55 发布

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

我正在使用针对nvd3的python包装器绘制折线图,如下所示。但我想知道如何把x轴设置成对数刻度

from nvd3 import lineChart
chart = lineChart(name="lineChart", x_is_date=False, x_axis_format="AM_PM")

xdata = range(18000)
ydata = [0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 4, 3, 3, 5, 7, 5, 3, 16, 6, 9, 15, 4, 12]
ydata2 = [9, 8, 11, 8, 3, 7, 10, 8, 6, 6, 9, 6, 5, 4, 3, 10, 0, 6, 3, 1, 0, 0, 0, 1]

extra_serie = {"tooltip": {"y_start": "There are ", "y_end": " calls"}}
chart.add_serie(y=ydata, x=xdata, name='sine', extra=extra_serie)
extra_serie = {"tooltip": {"y_start": "", "y_end": " min"}}
chart.add_serie(y=ydata2, x=xdata, name='cose', extra=extra_serie)
chart.buildhtml()
output_file = open('test-nvd3.html', 'w')
output_file.write(chart.htmlcontent)
output_file.close()

Tags: nameaddoutputchartextrastartfileend