Display some points by mouse in a plot
This is the code for the plotting what economist call the portfolio frontier
pp=parametric_plot((s(x),x), (x,-5, 6), fill=True,color='grey',alpha=0.01,axes_labels=['$\sigma_p$','$\mathbb{E}_p$'],axes_labels_size=1)
pp+=parametric_plot((s(x),x), (x,0, 6),color='red',)
pp+=parametric_plot((s(x),x), (x,-5, 0),linestyle='--',color='red',)
pp+=points([(5,1),(10,2),(20,-2)],color='blue')
pp+=text("$Pechiney$", (5,.6), alpha=1, fontsize='xx-small', fontweight='bold', color='green')
pp+=text("$LVMH$", (10,1.6), alpha=1, fontsize='xx-small', fontweight='bold', color='green')
pp+=text("$Peugeot$", (20,-2.4), alpha=1, fontsize='xx-small', fontweight='bold', color='green',)
show(pp,aspect_ratio='automatic')
I wonder
1) if it would be possible to display the point and there label, only when the mice is on them ?
2) to click on the grey part of the graph, to make appear a point which display its coordinates ?
3) I have tried some tricks to supress the "DeprecationWarning" which arise with this code without success. Why does it appears, how to suppress it ?
NB There is no accessible points outside of the grey zone.
Add I have seen a Python package PyAutoGui. I would like to know if anay body's has an experimetn of it's interaction with Sage.
For the deprecation warning, use raw strings when your label contains
\
by adding the letter r before the string, for exampler"$\mathbb{E}$"
Thanks. The problerm with
r
is that sometimes it must be placed before the command which must be 'rowed' sometimes after.look at this web page: event_handling
maybe that will help you, (not sure), but the examples don't work in Jupyter notebook, only with sage in terminal.
in the examples above x, y are displayed at the bottom of the figure. I know it's not quite what you wanted ;-(