 # figure.line(x,y) plots x in ascending order and ignores user x_axis input when in descending order

import numpy as np
from bokeh.plotting import figure, show, output_file

output_file(“example.html”)

r = figure()

x = [5,4,3,2,1]

y = [7,8,9,10,11]

r.line(x,y)

show®

Bokeh version 12.4 . Python 3.5

The output shows x values in ascending order (rather than descending) with their corresponding y values.

Does anyone know why bokeh is not respecting the order of the input for the x-axis? Am I doing something wrong?

Thanks,

Javier

Hi,

That plot renders exactly as I would expect it to. The locations that things get drawn is determined by:

- the data *values*
- axis orientation (default x-axis always increases to the right)

The *order* you provide the data is irrelevant. A point at (5, 7) get drawn where the axis range dictates that (5,7) is located. If you the axis range to be reversed from its normal direction, you'll have to ask for that:

import numpy as np
from bokeh.plotting import figure, show, output_file

output_file("example.html")
r = figure()
r.x_range.flipped = True # NOTE HERE
x = [5,4,3,2,1]
y = [7,8,9,10,11]
r.line(x,y)
show(r)

If you are expecting the *order* you provide the data to be meaningful, perhaps you are really wanting to use some kind of categorical axis?

Thanks,

Bryan

···

On Jan 10, 2017, at 3:43 PM, javbo <[email protected]> wrote:

import numpy as np
from bokeh.plotting import figure, show, output_file

output_file("example.html")
r = figure()
x = [5,4,3,2,1]
y = [7,8,9,10,11]
r.line(x,y)
show(r)

Bokeh version 12.4 . Python 3.5

The output shows x values in ascending order (rather than descending) with their corresponding y values.

Does anyone know why bokeh is not respecting the order of the input for the x-axis? Am I doing something wrong?

Thanks,

Javier

--
You received this message because you are subscribed to the Google Groups "Bokeh Discussion - Public" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/716408cc-c384-4ec4-b515-0a3d3905863b%40continuum.io.

Hi Bryan,

Thank you. I see what you mean. I wanted the flipped functionality. And yes I will want to use a categorical axis as well. Is there a way to specify the axis orientation or a categorical axis? I am guessing this is using factors?

···

On Tuesday, January 10, 2017 at 4:43:14 PM UTC-5, javbo wrote:

import numpy as np
from bokeh.plotting import figure, show, output_file

output_file(“example.html”)

r = figure()

x = [5,4,3,2,1]

y = [7,8,9,10,11]

r.line(x,y)

show®

Bokeh version 12.4 . Python 3.5

The output shows x values in ascending order (rather than descending) with their corresponding y values.

Does anyone know why bokeh is not respecting the order of the input for the x-axis? Am I doing something wrong?

Thanks,

Javier