python: plot glyph on condition over existing graph

Hi gurus,
I have a plot of a small moving average and large moving average over a scatter plot of the values. The data also contains a signal column indicating when the moving averages cross, either up or down (1 or -1, with 0 filling in the rest).

p.scatter(x, signals.temp, legend=‘Temperature’)

p.line(x, signals[‘smavg’], line_color=‘Blue’, line_width=0.5, legend=‘Smavg’ )

p.line(x, signals[‘lmavg’], line_color=‘Red’, line_width=0.5, legend=‘Lmavg’ )

I would like to plot a triangle glyph for the up signal (1) and an inverted triangle on the down signal (-1) by doing:

p.triangle(x, signals.loc[signals[‘mavgS’] == 1][‘temp’], size=[10], color="#99D594", line_width=0.5)

p.inverted_triangle(x, signals.loc[signals[‘mavgS’] == -1][‘temp’], size=[10], color="#DE2D26", line_width=0.5)

but I’m running in to this problem:

ColumnDataSource column lengths are not all the same: ColumnDataSource, ViewModel:ColumnDataSource

Any advice for a struggling noob?

J.

Hi Johan

x and y need to be the same length. If x is also a pandas Series, can you try filtering with the same .loc logic you are applying to y?

cheers,

Dennis

···

On Fri, Feb 19, 2016 at 11:44 AM [email protected] wrote:

Hi gurus,
I have a plot of a small moving average and large moving average over a scatter plot of the values. The data also contains a signal column indicating when the moving averages cross, either up or down (1 or -1, with 0 filling in the rest).

p.scatter(x, signals.temp, legend=‘Temperature’)

p.line(x, signals[‘smavg’], line_color=‘Blue’, line_width=0.5, legend=‘Smavg’ )

p.line(x, signals[‘lmavg’], line_color=‘Red’, line_width=0.5, legend=‘Lmavg’ )

I would like to plot a triangle glyph for the up signal (1) and an inverted triangle on the down signal (-1) by doing:

p.triangle(x, signals.loc[signals[‘mavgS’] == 1][‘temp’], size=[10], color="#99D594", line_width=0.5)

p.inverted_triangle(x, signals.loc[signals[‘mavgS’] == -1][‘temp’], size=[10], color="#DE2D26", line_width=0.5)

but I’m running in to this problem:

ColumnDataSource column lengths are not all the same: ColumnDataSource, ViewModel:ColumnDataSource

Any advice for a struggling noob?

J.

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/ff22f8e1-c1fc-407f-908e-5681f1c5092d%40continuum.io.

For more options, visit https://groups.google.com/a/continuum.io/d/optout.

Thanks Dennis,
still getting the problem. Here’s the line of code just in case I’m making some noob mistake;

p.triangle(signals.loc[signals[‘mavgS’] == 1].index, signals.loc[signals[‘mavgS’] == 1][‘temp’], size=[10], color="#99D594", line_width=0.5)

I printed x & y and they line up.

Also tried making sure both have the same column just for fun/confirmation;

p.triangle(signals.loc[signals[‘mavgS’] == 1][‘temp’].index, signals.loc[signals[‘mavgS’] == 1][‘temp’], size=[10], color="#99D594", line_width=0.5)

I’m wondering if it’s not because the previous three plots on the same figure are based on the complete dataset and the triangle on a subset? That would be a pain.

Thanks for your response,

J.

···

On Saturday, February 20, 2016 at 8:15:45 AM UTC+11, Dennis O’Brien wrote:

Hi Johan

x and y need to be the same length. If x is also a pandas Series, can you try filtering with the same .loc logic you are applying to y?

cheers,

Dennis

On Fri, Feb 19, 2016 at 11:44 AM [email protected] wrote:

Hi gurus,
I have a plot of a small moving average and large moving average over a scatter plot of the values. The data also contains a signal column indicating when the moving averages cross, either up or down (1 or -1, with 0 filling in the rest).

p.scatter(x, signals.temp, legend=‘Temperature’)

p.line(x, signals[‘smavg’], line_color=‘Blue’, line_width=0.5, legend=‘Smavg’ )

p.line(x, signals[‘lmavg’], line_color=‘Red’, line_width=0.5, legend=‘Lmavg’ )

I would like to plot a triangle glyph for the up signal (1) and an inverted triangle on the down signal (-1) by doing:

p.triangle(x, signals.loc[signals[‘mavgS’] == 1][‘temp’], size=[10], color="#99D594", line_width=0.5)

p.inverted_triangle(x, signals.loc[signals[‘mavgS’] == -1][‘temp’], size=[10], color="#DE2D26", line_width=0.5)

but I’m running in to this problem:

ColumnDataSource column lengths are not all the same: ColumnDataSource, ViewModel:ColumnDataSource

Any advice for a struggling noob?

J.

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/ff22f8e1-c1fc-407f-908e-5681f1c5092d%40continuum.io.

For more options, visit https://groups.google.com/a/continuum.io/d/optout.

Works fine using ray:

p.ray(signals.loc[signals[‘mavgS’] == 1].index, signals.loc[signals[‘mavgS’] == 1][‘temp’], length=50, angle=1.57, color=’#99D594’, line_width=1)

Other glyphs like x, asterisk or triangle doesn’t, they all throw the ColumnDataSource error.

J.

···

On Saturday, February 20, 2016 at 8:43:43 AM UTC+11, [email protected] wrote:

Thanks Dennis,
still getting the problem. Here’s the line of code just in case I’m making some noob mistake;

p.triangle(signals.loc[signals[‘mavgS’] == 1].index, signals.loc[signals[‘mavgS’] == 1][‘temp’], size=[10], color="#99D594", line_width=0.5)

I printed x & y and they line up.

Also tried making sure both have the same column just for fun/confirmation;

p.triangle(signals.loc[signals[‘mavgS’] == 1][‘temp’].index, signals.loc[signals[‘mavgS’] == 1][‘temp’], size=[10], color="#99D594", line_width=0.5)

I’m wondering if it’s not because the previous three plots on the same figure are based on the complete dataset and the triangle on a subset? That would be a pain.

Thanks for your response,

J.

On Saturday, February 20, 2016 at 8:15:45 AM UTC+11, Dennis O’Brien wrote:

Hi Johan

x and y need to be the same length. If x is also a pandas Series, can you try filtering with the same .loc logic you are applying to y?

cheers,

Dennis

On Fri, Feb 19, 2016 at 11:44 AM [email protected] wrote:

Hi gurus,
I have a plot of a small moving average and large moving average over a scatter plot of the values. The data also contains a signal column indicating when the moving averages cross, either up or down (1 or -1, with 0 filling in the rest).

p.scatter(x, signals.temp, legend=‘Temperature’)

p.line(x, signals[‘smavg’], line_color=‘Blue’, line_width=0.5, legend=‘Smavg’ )

p.line(x, signals[‘lmavg’], line_color=‘Red’, line_width=0.5, legend=‘Lmavg’ )

I would like to plot a triangle glyph for the up signal (1) and an inverted triangle on the down signal (-1) by doing:

p.triangle(x, signals.loc[signals[‘mavgS’] == 1][‘temp’], size=[10], color="#99D594", line_width=0.5)

p.inverted_triangle(x, signals.loc[signals[‘mavgS’] == -1][‘temp’], size=[10], color="#DE2D26", line_width=0.5)

but I’m running in to this problem:

ColumnDataSource column lengths are not all the same: ColumnDataSource, ViewModel:ColumnDataSource

Any advice for a struggling noob?

J.

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/ff22f8e1-c1fc-407f-908e-5681f1c5092d%40continuum.io.

For more options, visit https://groups.google.com/a/continuum.io/d/optout.

My guess would be because you used

      size=              [10]

in one and size=50 in the
other

            Most properties of a glyph you can "power"                                 with a data source

so it could be size=[1, 2, 3, 4,
5 ]
like it was ano ther
column of data.

                                          I                                                  f

you put a single value
l ike size=50,
we convert that to
be expli citly just
a singl e value
(the explicit
way wo uld be
size=bokeh.properties.value(50)).

                                                      So anywa                                                          y, I'm

almost certain
that the
problem is
size=[10], try
size=10.

                                                      Best,

                                                      Bird
···

On 2/19/16 2:09 PM,
wrote:

[email protected]

Works fine using ray:

p.ray(signals.loc[ signals[‘mavgS’] == 1].index,
signals.loc[signals[‘mavgS’] == 1][‘temp’], length=50,
angle=1.57, color=’#99D594’, line_width=1)

      Other glyphs like x, asterisk or triangle doesn't, they all

throw the ColumnDataSource error.

      J.





      On Saturday, February 20, 2016 at 8:43:43 AM UTC+11,

wrote:

  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/ba8ee3eb-fb38-4d5a-8e03-39da9fe7536a%40continuum.io?utm_medium=email&utm_source=footer)      .

For more options, visit .


Sarah Bird
Developer, Bokeh

    [
      ![Continuum Analytics](http://docs.continuum.io/_static/img/ContinuumWordmark.png)
    ](http://continuum.io)

[email protected]

Thanks Dennis,
still getting the problem. Here’s the line of code
just in case I’m making some noob mistake;

p.triangle(signals.loc[ signals[‘mavgS’] ==
1].index, signals.loc[signals[‘mavgS’] == 1][‘temp’],
size=[10], color="#99D594", line_width=0.5)

I printed x & y and they line up.

            Also tried making sure both have the same column just

for fun/confirmation;

p.triangle(signals.loc[ signals[‘mavgS’] ==
1][‘temp’].index, signals.loc[signals[‘mavgS’] ==
1][‘temp’], size=[10], color="#99D594",
line_width=0.5)

            I'm wondering if it's not because the previous three

plots on the same figure are based on the complete
dataset and the triangle on a subset? That would be a
pain.

Thanks for your response,

J.

            On Saturday, February 20, 2016 at 8:15:45 AM UTC+11,

Dennis O’Brien wrote:

Hi Johan

                  x and y need to be the same length.  If x is

also a pandas Series, can you try filtering with
the same .loc logic you are applying to y?

cheers,

Dennis

On Fri, Feb 19, 2016 at 11:44 AM < >
wrote:

Hi gurus,
I have a plot of a small moving average and
large moving average over a scatter plot of
the values. The data also contains a signal
column indicating when the moving averages
cross, either up or down (1 or -1, with 0
filling in the rest).

                        p.scatter(x, signals.temp,

legend=‘Temperature’)

                        p.line(x, signals['smavg'],

line_color=‘Blue’, line_width=0.5,
legend=‘Smavg’ )

                        p.line(x, signals['lmavg'],

line_color=‘Red’, line_width=0.5,
legend=‘Lmavg’ )

                      I would like to plot a triangle glyph for

the up signal (1) and an inverted triangle on
the down signal (-1) by doing:

                      p.triangle(x, signals.loc[signals['mavgS']

== 1][‘temp’], size=[10], color="#99D594",
line_width=0.5)

                      p.inverted_triangle(x,

signals.loc[signals[‘mavgS’] == -1][‘temp’],
size=[10], color="#DE2D26", line_width=0.5)

but I’m running in to this problem:

                      ColumnDataSource column lengths are not all

the same: ColumnDataSource,
ViewModel:ColumnDataSource

Any advice for a struggling noob?

J.

                  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 .
To post to this group, send email to .
To view this discussion on the web visit

[email protected]
[email protected]
[email protected]
https://groups.google.com/a/continuum.io/d/msgid/bokeh/ff22f8e1-c1fc-407f-908e-5681f1c5092d%40continuum.io.

                  For more options, visit [https://groups.google.com/a/continuum.io/d/optout](https://groups.google.com/a/continuum.io/d/optout).

                [https://groups.google.com/a/continuum.io/d/msgid/bokeh/ba8ee3eb-fb38-4d5a-8e03-39da9fe7536a%40continuum.io](https://groups.google.com/a/continuum.io/d/msgid/bokeh/ba8ee3eb-fb38-4d5a-8e03-39da9fe7536a%40continuum.io)

https://groups.google.com/a/continuum.io/d/optout