0

EDIT 2

I fixed one part of the code that was wrong, With that line of code, I add the category for every information (Axis X).

y = joy(cat, EveryTest[i].GPS)

After adding that line of code, the graph improved, but something is still failing. The graph starts with the 4th category (I mean 12:40:00), and it must start in the first (12:10:00), What I am doing wrong?

enter image description here

EDIT 1:

I Updated Bkoeh to 0.12.13, then the label problem was fixed. Now my problem is: I suppose the loop for (for i, cat in enumerate(reversed(cats)):) put every chart on the label, but do not happen that. I see the chart stuck in the 5th o 6th label. (12:30:00 or 12:50:00)

enter image description here

- Start of question -

I am trying to reproduce the example of joyplot. But I have trouble when I want to lot my own data. I dont want to plot an histogram, I want to plot some list in X and some list in Y. But I do not understand what I am doing wrong.

the code (Fixed):

from numpy import linspace
from scipy.stats.kde import gaussian_kde
from bokeh.io import output_file, show
from bokeh.models import ColumnDataSource, FixedTicker, PrintfTickFormatter
from bokeh.plotting import figure
#from bokeh.sampledata.perceptions import probly 
bokeh.BOKEH_RESOURCES='inline'
import colorcet as cc

output_file("joyplot.html")

def joy(category, data, scale=20):
    return list(zip([category]*len(data),data))

#Elements = 7

cats = ListOfTime #  list(reversed(probly.keys())) #list(['Pos_1','Pos_2']) #

print len(cats),' lengh of times'

palette = [cc.rainbow[i*15] for i in range(16)]
palette += palette
print len(palette),'lengh palette'
x = X # linspace(-20,110, 500) #Test.X #
print len(x),' lengh X'
source = ColumnDataSource(data=dict(x=x))

p = figure(y_range=cats, plot_width=900, x_range=(0, 1500), toolbar_location=None)

for i, cat in enumerate(reversed(cats)):
    y = joy(cat, EveryTest[i].GPS)
    #print cat
    source.add(y, cat)
    p.patch('x', cat, color=palette[i], alpha=0.6, line_color="black", source=source)
    #break
print source
p.outline_line_color = None
p.background_fill_color = "#efefef"

p.xaxis.ticker = FixedTicker(ticks=list(range(0, 1500, 100)))
#p.xaxis.formatter = PrintfTickFormatter(format="%d%%")

p.ygrid.grid_line_color = None
p.xgrid.grid_line_color = "#dddddd"
p.xgrid.ticker = p.xaxis[0].ticker

p.axis.minor_tick_line_color = None
p.axis.major_tick_line_color = None
p.axis.axis_line_color = None

#p.y_range.range_padding = 0.12
#p
show(p)

the variables are:

print X, type(X)
[ 3  6  9 12 15 18 21 24 27 30 33 36 39 42 45 48 51 54 57 60 63 66 69 72 75
 78 81 84 87 90 93 96 99] <type 'numpy.ndarray'>

and

print EveryTest[0].GPS, type(EveryTest[i].GPS)
0     2
1     2
2     2
3     2
4     2
5     2
6     2
7     2
8     2
9     2
10    2
11    2
12    2
13    2
14    2
15    2
16    2
17    2
18    2
19    2
20    2
21    2
22    2
23    2
24    2
25    2
26    2
27    2
28    2
29    2
30    2
31    2
32    2
Name: GPS, dtype: int64 <class 'pandas.core.series.Series'>

Following the example, the type of data its ok. But I get the next image: enter image description here

And I expected something like this: enter image description here

Marcus Campbell
  • 2,746
  • 4
  • 22
  • 36
mikesneider
  • 772
  • 2
  • 10
  • 28
  • The fact that you are seeing `MALFORMED_CATEGORY_LABEL` indicates that you are using a version of Bokeh too old for this example (before the recent work to improve categorical support). But your data does not seem appropriate for a joyplot in any case. Joyplots are multiple series, each associated with a different category. You don't appear to have any categoricals for the y-axis at all. – bigreddot Dec 08 '17 at 06:16
  • Thank you @bigreddot , to be clear, each category is a list of time (string). And each object *EveryTrst* is the time serie to the first category or first moment in the *List of timr*. May be I missunderstand how joyplot works. – mikesneider Dec 08 '17 at 09:12
  • You are right @bigreddot, I recently to update the versión of Bokeh, and the error of MALFORMED_CATEGORY_LABEL is fixed. Now I need to check the graph. I Still do not have. – mikesneider Dec 11 '17 at 14:44
  • Your image actually looks like things are working? You have to tune the vertical scaling to account for however many categories you have. You currently have many categories (tho most of them are empty, not sure if this is just because this is partial code) so the default scale in the example makes things "squished". If you keep all those categories you will need to set the scale for the time series to something that is appropriate for your particular case (probably through trial and error until it "looks good" -- joy plots are demonstrative, not quantitative) – bigreddot Dec 11 '17 at 17:37
  • @bigreddot but it supposes I assign the category in 'source.add(y, cat)' and 'EveryTest[0].GPS' have the scale in each category (around from 0 to 10)(axis y) and "Axis X" is the variable called: X (from 0 to 1044). is not ok in this way? – mikesneider Dec 12 '17 at 04:51
  • I'm sorry I don't really understand your situation or use case. SO comments are pretty terrible for iterative discussion, perhaps you can come by the mailing list https://groups.google.com/a/continuum.io/forum/#!forum/bokeh – bigreddot Dec 12 '17 at 17:56

0 Answers0