How can I click elements inside Dash Tooltip? - python

I have a scatter plot graph and a dcc.Tooltip which shows over points on hover, similar to the examples here.
I want to add some interactive components within the tooltip, e.g. a button, but I cannot click anything within the tooltip. I can't even highlight text. It seems I just click through the tooltip and interact with the graph behind it.
Is there a way to interact with components inside a dcc.Tooltip?

Related

How do I show plot zoomed in?

I'm using matplotlib to show a plot with %matplotlib widget in jupyter lab. Almost every time I show the plot, next thing I have to do is zoom in and examine one of the sections of the plot. I would like to be able to show the plot zoomed into that section, and if I want to examine the rest of the plot, as I sometimes do, I would press back button and see all of it.
This is similar to showing subplot with relevant data or using plt.xlim, except I would like to do it in a single plot so the data I'm looking at can occupy more screen space, and plt.xlim just shows relevant stretch of data without possibility to zoom out again.
How do I do this is jupyter lab?

How to create a user created textbox on top of matplotlib figure?

BackGround
I'm making this software right plot data as boxplots and scatter plots. To make the graph more informative and clear I wanted the user to be able to drag-create a textbox on top of the figure if they wanted to add notes. This way when people share the figure it can be explained through these notes.
Current Approach and Problem
I have used annotate function to create a textbox in the upper right corner of the screen to tell the user how many data points have been used, but there are of few problems with this approach.
This is the code I used to create a text box to tell the user how many data pts there are.
self.axes.text(.98, .98, 'Number of Data Points: {}'.format(len(self.cleanedY)),
verticalalignment='top', horizontalalignment='right',
transform=self.axes.transAxes,
color='black', fontsize=9.5)
Extensive input that would have to be asked of the user. This includes the position coordinates, the actual text box, type of alignment.
The only way I know how to collect this info would be to create a Qdialog window prompting for all these inputs, which would be too cumbersome.
User doesn't have much control over being able to freely position the textbox and would have to know exact decimals to position the text box on the figure.
This is incredibly inefficient and inflexible. I want a way for the user to EASILY create these notes on the plot figure.
TLDR: Is there any way to develop a simple drag and create textbox option on a plot figure?
I'm not sure if this is what your looking for, but i found this similar example online. It doesn't allow for user to create a textbox, but adds annotations to the figure and allows you to move them around.
here's the link
http://scipy-cookbook.readthedocs.io/items/Matplotlib_Drag_n_Drop_Text_Example.html

Adding data to particular data point on plot using mouse click

I have developed subplots in mayavi and I want to add data on a particular point on that graph after clicking on that point. I have used mayavi.mlab.text3d but the text is not present on the data point. How to fix this

Make a label / annotation appear, when hovering over an area (rectangle)

As you can see the question above, I was wondering, if it is possible to popup a label, when I hover on a rectangle-area.
I found this solution which helped me for popping up a label over a point.
But is it possible to popup a label, when the user hovers somewhere over an area?
On my plot, I'm using this code example for adding rectangles:
http://matthiaseisen.com/pp/patterns/p0203/
Let's use this as example:
(source: matthiaseisen.com)
When the user hovers (everywhere) over the blue area, a popup "You are hovering over the blue area" should appear.
Is this even possible in matplotlib? I can't find any solution for this problem.
Matplotlib by itself isn't going to give you this functionality. Bokeh (link), another python library, is what you want. Here is an example with the hovertool feature, which is what you're looking for. You can even export the image as html so you can put it on a website or blog.

adding tooltips to line plots in bokeh

Is there any way at the moment to add constant tooltips to a bokeh line plot in python? I did not find anything about it in the documention.
I am looking for a way to allow adding the tooltip interactively ala matlab. However, doing so via the code at first is acceptable.
thanks.
Currently (as of 0.8.1) the line glyph does not support hit testing, so it does not support a hover tool, either. However, if it suffices to have a hover tooltip on just the "points" of the line, then several people have uses a second set of transparent markers located at the same points as a workaround. Something like:
line(x, y)
circle(x, y, size=8, alpha=0)
There is an open issue for adding line hit testing, it should hopefully been in one of the next few releases.

Categories