0

I'm experiencing a strange behavior of bqplot inside my jupyter notebook. Am I doing something wrong, or is this probably a bug ? Everything works fine, if I provide a min max parameter for the linear scales in the first place.

import numpy as np
import bqplot as bq

marks = []
# If e.g. bq.LinearScale(min=0, max=1) is used, everything works fine
scale_y = bq.LinearScale()
scale_x = bq.LinearScale()

ax_y = bq.Axis(scale=scale_x, orientation='vertical', label='Recovery (%)')
ax_x = bq.Axis(scale=scale_y, orientation='horizontal', label='Time (h)')

x = [0]
y = [0]
line_1 = bq.Lines(x=x, y=y,
                  scales={'x': scale_x, 'y': scale_y},
                  labels=['Test'])
fig = bq.Figure(marks=[line_1], axes=[ax_x, ax_y], title='API Example', legend_location='bottom-right')

fig

It returns:

enter image description here

Later on, I append some data:

x = np.linspace(0, 10)
y = x**2
line_2 = bq.Lines(x=x, y=y,
                  scales={'x': scale_x, 'y': scale_y},
                  labels=['Test'])
fig.marks = [line_2]

enter image description here

Why is the x axis limit set to 100 ? It should be 10 instead.

It is possible to change the limit of the axes the behavior is odd. It seems the axis are somehow switched. I can change the x axis limits and it turns out that the y axis is changed. Furthermore, the plot is still wrong:

scale_y.min = 0
scale_y.max = 100

scale_x.min = 0
scale_x.max = 10
Arkistarvh Kltzuonstev
  • 6,824
  • 7
  • 26
  • 56
Moritz
  • 5,130
  • 10
  • 40
  • 81

1 Answers1

1

Your ax_y and ax_x have been assigned the wrong scales. Swap the scales over.

DougR
  • 3,196
  • 1
  • 28
  • 29