Adding Color to Plots not working with ColumnDataSource

Hello,

Can anyone help me out here? Am I doing something wrong? I believe ColumnDataSource behaves differently if plotting multiple plots in one plot, correct?

source = ColumnDataSource(data=dict(Dt=,Census=,CountAtStart=))

plot = figure(plot_width=1100, plot_height=600, x_axis_type = ‘datetime’)

CAHplot.line(x=‘Dt’, y=‘Census’, source=source, line_dash=[4, 4], line_color=‘purple’, alpha = 0.8, line_width=2, legend=‘Predicted’)

CAHplot.line(x=‘Dt’, y=‘CountAtStart’, source=source, line_color=‘blue’, alpha = 0.3, line_width=2, legend=‘Actual’)

Thank you,

Pratik

I would not say that is correct, at least not any way I can interpret it. ColumnDataSources don't know how many glyphs or plots they are used in, so there is no way for them to behave differently based on that. What is your actual question? You haven't stated what is happening vs what you are expecting to happen, so it's hard to know what you are wanting help with. Offhand, at least in the code you have supplied, your ColumnDataSource is completely empty, so I would not expect anything to be plotted.

Thanks,

Bryan

···

On Jan 7, 2017, at 11:54 PM, [email protected] wrote:

Hello,

Can anyone help me out here? Am I doing something wrong? I believe ColumnDataSource behaves differently if plotting multiple plots in one plot, correct?

source = ColumnDataSource(data=dict(Dt=,Census=,CountAtStart=))

plot = figure(plot_width=1100, plot_height=600, x_axis_type = 'datetime')

CAHplot.line(x='Dt', y='Census', source=source, line_dash=[4, 4], line_color='purple', alpha = 0.8, line_width=2, legend='Predicted')
CAHplot.line(x='Dt', y='CountAtStart', source=source, line_color='blue', alpha = 0.3, line_width=2, legend='Actual')

Thank you,
Pratik

--
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/c9615f95-8605-467f-b22d-5f3d760c72ea%40continuum.io\.
For more options, visit https://groups.google.com/a/continuum.io/d/optout\.

Hi Bryan,

So the ColumnDataSource here is an example just to show that it is ColumnDataSource. It has some values, that are selected based on the Select option. May be the following will be more clear?

source = ColumnDataSource(data=dict(Dt=,Census=,CountAtStart=))

current = df[df['Census'] <= 25].dropna()


**        source.data = {
'Dt' : current['Dt'],
'Census' : current['Census'],
'CountAtStart' : current['CountAtStart'],
}**


CAHplot = figure(plot_width=1100, plot_height=600, x_axis_type = ‘datetime’)

CAHplot.line(x=‘Dt’, y=‘Census’, source=source, line_dash=[4, 4], line_color=‘purple’, alpha = 0.8, line_width=2, legend=‘Predicted’)

CAHplot.line(x=‘Dt’, y=‘CountAtStart’, source=source, line_color=‘blue’, alpha = 0.3, line_width=2, legend=‘Actual’)

And the graph should look like the attachment here.

Let me know if this woulf help or not. Thank you!

···

On Sunday, 8 January 2017 01:20:58 UTC-5, Bryan Van de ven wrote:

I would not say that is correct, at least not any way I can interpret it. ColumnDataSources don’t know how many glyphs or plots they are used in, so there is no way for them to behave differently based on that. What is your actual question? You haven’t stated what is happening vs what you are expecting to happen, so it’s hard to know what you are wanting help with. Offhand, at least in the code you have supplied, your ColumnDataSource is completely empty, so I would not expect anything to be plotted.

Thanks,

Bryan

On Jan 7, 2017, at 11:54 PM, [email protected] wrote:

Hello,

Can anyone help me out here? Am I doing something wrong? I believe ColumnDataSource behaves differently if plotting multiple plots in one plot, correct?

source = ColumnDataSource(data=dict(Dt=,Census=,CountAtStart=))

plot = figure(plot_width=1100, plot_height=600, x_axis_type = ‘datetime’)

CAHplot.line(x=‘Dt’, y=‘Census’, source=source, line_dash=[4, 4], line_color=‘purple’, alpha = 0.8, line_width=2, legend=‘Predicted’)

CAHplot.line(x=‘Dt’, y=‘CountAtStart’, source=source, line_color=‘blue’, alpha = 0.3, line_width=2, legend=‘Actual’)

Thank you,

Pratik


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/c9615f95-8605-467f-b22d-5f3d760c72ea%40continuum.io.

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

from bokeh.plotting import Figure, output_file

from bokeh.models import ColumnDataSource

from bokeh.resources import CDN

from bokeh.embed import file_html

source = ColumnDataSource(data={‘x’:range(10),‘y’:range(10),‘z’:range(10)[::-1]})

fig = Figure(plot_width=400,plot_height=400)

fig.line(x=‘x’,y=‘y’,line_color=‘purple’,source=source,line_dash=[4,4],alpha=0.8,line_width=2,legend=‘Predicted’)

fig.line(x=‘x’,y=‘z’,source=source,line_color=‘blue’,alpha=0.3,line_width=2,legend=‘Actual’)

outfile=open(‘colotest.html’,‘w’)

outfile.write(file_html(fig,CDN,‘test’))

outfile.close()

``

This simple example works fine, how does your plot look?

Thank you for your example. It is working now. :slight_smile:

···

On Thursday, 12 January 2017 12:17:19 UTC-5, [email protected] wrote:

from bokeh.plotting import Figure, output_file

from bokeh.models import ColumnDataSource

from bokeh.resources import CDN

from bokeh.embed import file_html

source = ColumnDataSource(data={‘x’:range(10),‘y’:range(10),‘z’:range(10)[::-1]})

fig = Figure(plot_width=400,plot_height=400)

fig.line(x=‘x’,y=‘y’,line_color=‘purple’,source=source,line_dash=[4,4],alpha=0.8,line_width=2,legend=‘Predicted’)

fig.line(x=‘x’,y=‘z’,source=source,line_color=‘blue’,alpha=0.3,line_width=2,legend=‘Actual’)

outfile=open(‘colotest.html’,‘w’)

outfile.write(file_html(fig,CDN,‘test’))

outfile.close()

``

This simple example works fine, how does your plot look?