Hi Sandy,
I’m not sure exactly what you’re trying to achieve here.
Anyway, here is a working exemple. I hope it helps.
-
you need to add your textinput and button to the plot to display it
-
callback written with CustomJS
-
added an initial x_range and y_range to the plot
-
s2 ColumnDataSource is initially empty
Jean
from bokeh.models import CustomJS, Range1d
from bokeh.models.sources import ColumnDataSource
from bokeh.models.tools import HoverTool, PanTool, BoxSelectTool, WheelZoomTool, BoxZoomTool, ResetTool
from bokeh.models.widgets import TextInput, Button
from bokeh.plotting import figure, show, output_file, vplot, hplot
output_file(“adding_points.html”)
s2= ColumnDataSource( #the data is fetched and manipulated from a csv file
data=dict(
plsr1=[],
rw_prf1=[],
pd1=[],
pd_der1=[],
)
)
plsri = TextInput(value=" ", title=“Puls:”) #takes the input
rw_prfi= TextInput(value=" ", title=“Prof:”)
pdi = TextInput(value=" ", title=“Pd:”)
pd_deri = TextInput(value=" ", title=“Pd Derv:”)
callback = CustomJS(args=dict(source=s2,
plsr=plsri,
rw_prf=rw_prfi,
pd=pdi,
pd_der=pd_deri),
code="""
var data = source.get('data');
data['plsr1'].push(plsr.get('value'))
data['rw_prf1'].push(rw_prf.get('value'))
data['pd1'].push(pd.get('value'))
data['pd_der1'].push(pd_der.get('value'))
source.trigger('change');
""")
hover1 = HoverTool(tooltips=[
("Pulsar", "@plsr1"),
("Raw Profiles", "@rw_prf1"),
("Period","@pd1"),
("Period Derivative","@pd_der1"),
]
)
tool1=[PanTool(),BoxSelectTool(),hover1,WheelZoomTool(),BoxZoomTool(),ResetTool()]
p5= figure(plot_width=800, plot_height=500,tools=tool1, title=“Point Plot”,
x_range=Range1d(-10,10, bounds=None), y_range=Range1d(-10,10, bounds=None))
p5.circle(‘pd1’, ‘pd_der1’, size=15, color=‘green’, line_color=‘blue’, source=s2)
p5.xaxis.axis_label =“Period”
p5.yaxis.axis_label =“Period Derivative”
p5.background_fill_color=‘black’
p5.xaxis.major_label_text_color = “green”
p5.yaxis.major_label_text_color = “green”
toggle = Button(label=“Add Point”, type=“success”, callback=callback)
inputs = vplot(plsri, rw_prfi, pdi, pd_deri, toggle)
display= hplot(p5, inputs)
show(display)
Le 19/03/2016 23:59, Sandeep Bharti a écrit :
Hi,
I didn’t got any response from anyone regarding my issue. Here is the
pastebin for the piece of code in which I am facing problem
( http://pastebin.com/sEUqSgzD ). I will be really thankful for your help.
Sandy.
On Thu, Mar 17, 2016 at 10:13 PM, Sandeep Bharti
<[email protected] mailto:[email protected]> wrote:
Hi Bryan,
I have a plot for parameters say x and y with few other parameters
a,b and c. I want the user to input values for all the parameters
on a browser and with a click of a button it should plot the newly
added point in the plot on the browser itself. I used TextInput to
get the input from the user and also made a button to update the
plot but I am not able to achieve it. I need assistance on this one.
Tell me if you want more specific explanation.
Many Thanks,
Sandy
On Thu, Mar 17, 2016 at 6:59 PM, Bryan Van de Ven
<[email protected] <mailto:[email protected]>> wrote:
Hi Sandy,
This is pretty general and non-specific, it's hard to give any
concrete guidance. Can you provide more details, e.g. what sort
of data is to be input, what kind of user interaction you are
looking to have, and what exactly you have tried so far?
Thanks,
Bryan
> On Mar 16, 2016, at 5:28 PM, alphasandy
<[email protected] <mailto:[email protected]>> wrote:
>
> Hi,
>
> I have been trying to get the user input from the user and
trying to put it into the plot with a button click or so but I
am not able to do that. Also I want to update the point values
in the plot with the user given values. I tried various things
like CustomJS and callback but it did not worked for me. Can
anyone help me with this?
> I will be really thankful. :)
>
> Many Thanks,
> Sandy
>
> --
> 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]
<mailto:bokeh%[email protected]>.
> To post to this group, send email to [email protected]
<mailto:[email protected]>.
> To view this discussion on the web visit
[https://groups.google.com/a/continuum.io/d/msgid/bokeh/3c764290-ecd3-4cc3-96f1-fcef037da4ed%40continuum.io](https://groups.google.com/a/continuum.io/d/msgid/bokeh/3c764290-ecd3-4cc3-96f1-fcef037da4ed%40continuum.io).
> For more options, visit
[https://groups.google.com/a/continuum.io/d/optout](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 [email protected]
<mailto:bokeh%[email protected]>.
To post to this group, send email to [email protected]
<mailto:[email protected]>.
To view this discussion on the web visit
[https://groups.google.com/a/continuum.io/d/msgid/bokeh/1C9B12EA-B45F-4458-99D0-AED2CE963D59%40continuum.io](https://groups.google.com/a/continuum.io/d/msgid/bokeh/1C9B12EA-B45F-4458-99D0-AED2CE963D59%40continuum.io).
For more options, visit
[https://groups.google.com/a/continuum.io/d/optout](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 [email protected]
mailto:[email protected].
To post to this group, send email to [email protected]
mailto:[email protected].
To view this discussion on the web visit
https://groups.google.com/a/continuum.io/d/msgid/bokeh/CANecKMzRO40hmp2gGESS0YqAMhbqAtDxHc56J5AfGSMzeWqhrQ%40mail.gmail.com
<https://groups.google.com/a/continuum.io/d/msgid/bokeh/CANecKMzRO40hmp2gGESS0YqAMhbqAtDxHc56J5AfGSMzeWqhrQ%40mail.gmail.com?utm_medium=email&utm_source=footer>.
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 [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/56EFC3E4.2070604%40gmail.com.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.