1

This is a simple lineChart example using python-nvd3:

from nvd3 import lineChart
chart = lineChart(width=600)

xdata = range(13)
ydata = [1, 2, 3, 5, 8, 10, 11, 10, 8, 5, 4, 2, 1]

chart.add_serie(y=ydata, x=xdata)
chart.buildhtml()

with open('plot.html', 'w') as f:
    f.write(chart.htmlcontent)

By default, the range of values of the X and Y-axis is derived from the minimum and maximum values of xdata and ydata, thus X is from 0 to 12 and Y is from 1 to 11. The rendered plot in plot.html looks like this:

enter image description here

How can I modify the code above to define a custom range for X and Y-axis for a given xdata & ydata? For instance, set Y from 0 to 12 and X from -1 to 13.

PApostol
  • 2,152
  • 2
  • 11
  • 21

0 Answers0