On Aug 10, 2017, at 05:04, pistukem@gmail.com wrote:
Hi,
sorry to resurrect an old thread but is this supposed to work with patches (with missing points), too?
Kind regards,
Istvan
On Wednesday, June 8, 2016 at 5:31:01 PM UTC+2, Oscar Delgado wrote:
Hello Bjorn,
Those are called "Categorical Coordinates". Bryan told me about them:
Redirecting to Google Groups
Note that I have something awkward in my example (the left-right are inverted) but the idea is that the first group of bars (males) should be moved to the left and the second group to the right. You should do a little of math based on the number of groups/width to determine the deviations but at the end, you can implement a loop when you have several groups (2+). NOTE: Check always the space between categories to avoid overlap when you have several groups.
Best!
Le mercredi 8 juin 2016 08:06:38 UTC-4, Björn Pollex a écrit :
Hi Oscar,
thanks for providing these examples, they are very useful indeed. The key point there is that you specify coordinates as name:factor pairs. I wasn’t aware that this is possible, and I don’t understand what exactly goes on here. Can you explain this?
Cheers,
Björn
On 7 Jun 2016, at 16:39, Oscar Delgado <oscar...@gmail.com> wrote:
Hello,
The same example using quads. Please note I haven't work much on simplifying the code (for example, you can combine the lambdas to get the right/left coords at once, and the put it into the for loop), but at least it can give you some start point.
import pandas as pd
import bokeh.plotting as bk
def main():
""" Run the whole program """
bk.output_file("bars.html")
cols= ['Rock/Folk/Indie','Country' ,'Singer-Songwriter', 'Jazz/Blues']
d = {'Rock/Folk/Indie':[56,12] ,'Country':[11,7] ,'Singer-Songwriter':[7,10],
'Jazz/Blues':[7,6]}
df = pd.DataFrame(d, columns=cols, index=['male', 'female'])
print (df)
rows = len(df.index)
wdth = 0.3
categorical_coord = lambda name,row: "{}:{}".format(name, 0.5 - wdth + wdth*row)
right = [[categorical_coord(name,jdx) for name in cols]for jdx in range(rows)]
categorical_coord = lambda name,row: "{}:{}".format(name, 0.50 + wdth*row)
left = [[categorical_coord(name,jdx) for name in cols]for jdx in range(rows)]
plot = bk.figure(x_range=cols, y_range= [0, 60], tools="", title="Genre")
n = 2 # number of bars
colour = ["#CD7F32", "silver"]
leg = ['male', 'female']
for idx in range(n):
plot.quad(bottom=0, top=df.iloc[idx], left=left[idx], right=right[idx], color=colour[idx],legend=leg[idx])
bk.show(plot)
if __name__ == '__main__':
main()
Let me know if you have questions.
Best !
--
You received this message because you are subscribed to a topic in the Google Groups "Bokeh Discussion - Public" group.
To unsubscribe from this topic, visit https://groups.google.com/a/continuum.io/d/topic/bokeh/h22xpZmxId8/unsubscribe\.
To unsubscribe from this group and all its topics, send an email to bokeh+un...@continuum.io.
To post to this group, send email to bo...@continuum.io.
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/cb775dad-7250-4e4e-80db-fffa9ddf6851%40continuum.io\.
For more options, visit https://groups.google.com/a/continuum.io/d/optout\.
--
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 bokeh+unsubscribe@continuum.io.
To post to this group, send email to bokeh@continuum.io.
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/94f6d545-3fbd-4223-8a3a-7acc0c8061df%40continuum.io\.
For more options, visit https://groups.google.com/a/continuum.io/d/optout\.