width ignore with rect when x axis are dates

I couldn’t find a issue on github for this, but I guess it’s a bug. Please confirm, so I can fill an issue.

When I plot with rect, and the X axis is categorical or numerical, it works as expected. But it the X axis is a list of dates, then the width property is ignored, and the rectangles painted are really narrow.

See this example, when the plots are the same, except for the type of the X axis, and in one case it works well, and in the other doesn’t.

import datetime
import numpy as np
import pandas as pd
import bokeh.plotting as plt

x1 = np.arange(10)
x2 = pd.date_range(datetime.date(2014, 1, 1), datetime.date(2014, 1, 10))
y = np.random.randn(10)

p1 = plt.figure(title=‘Numbers in X’)
p1.rect(x1, y/2, 0.8, y)

p2 = plt.figure(title=‘Dates in X’)
p2.rect(x2, y/2, 0.8, y)

plt.show(plt.VBox(p1, p2))

``

The resulting plots are these:

Ok, I’ve just seen in the candlestick example [1] that in case of dates the width is in milliseconds, so a huge number like 10006060*12 is required to see a difference. I’ll check if it can be added somewhere else in the documentation, I don’t think it’s really intuitive if you don’t read this.

Cheers,

Marc

  1. http://bokeh.pydata.org/en/latest/docs/gallery/candlestick.html
···

On Tuesday, January 20, 2015 at 5:59:17 PM UTC+1, Marc Garcia wrote:

I couldn’t find a issue on github for this, but I guess it’s a bug. Please confirm, so I can fill an issue.

When I plot with rect, and the X axis is categorical or numerical, it works as expected. But it the X axis is a list of dates, then the width property is ignored, and the rectangles painted are really narrow.

See this example, when the plots are the same, except for the type of the X axis, and in one case it works well, and in the other doesn’t.

import datetime
import numpy as np
import pandas as pd
import bokeh.plotting as plt

x1 = np.arange(10)
x2 = pd.date_range(datetime.date(2014, 1, 1), datetime.date(2014, 1, 10))
y = np.random.randn(10)

p1 = plt.figure(title=‘Numbers in X’)
p1.rect(x1, y/2, 0.8, y)

p2 = plt.figure(title=‘Dates in X’)
p2.rect(x2, y/2, 0.8, y)

plt.show(plt.VBox(p1, p2))

``

The resulting plots are these:

Is there a way to skip the weekend blank in the plot , **And keep the x axis date time is correct ? **

···

On Wednesday, January 21, 2015 at 12:59:17 AM UTC+8, Marc Garcia wrote:

I couldn’t find a issue on github for this, but I guess it’s a bug. Please confirm, so I can fill an issue.

When I plot with rect, and the X axis is categorical or numerical, it works as expected. But it the X axis is a list of dates, then the width property is ignored, and the rectangles painted are really narrow.

See this example, when the plots are the same, except for the type of the X axis, and in one case it works well, and in the other doesn’t.

import datetime
import numpy as np
import pandas as pd
import bokeh.plotting as plt

x1 = np.arange(10)
x2 = pd.date_range(datetime.date(2014, 1, 1), datetime.date(2014, 1, 10))
y = np.random.randn(10)

p1 = plt.figure(title=‘Numbers in X’)
p1.rect(x1, y/2, 0.8, y)

p2 = plt.figure(title=‘Dates in X’)
p2.rect(x2, y/2, 0.8, y)

plt.show(plt.VBox(p1, p2))

``

The resulting plots are these: