How do I make matplotlib line graphs in my TKinter app interactive? - python

I've been making an application that uses matplotlib to make a line graph, but the issue I've been having is that when I try and hover over the graph, it is a static image that I can pan around, but I'm unable to get the values on my graph when I hover my mouse. I'm not looking to make a scatter graph, but a line graph that annotates over the values when I hover my mouse over it. I understand that matplotlib graphs can be made interactive with Dash/Plotly, but the issue is that they only work on webapps, and I am looking for a way to make my mpl graph look more like a plotly one on a Tk GUI app. Any way that this is possible?

Related

Create a Candlestick Chart with PySimpleGUI Canvas Object

I am trying to create a Candlestick chart using PySimpleGUI and display it in a Canvas. I am having trouble finding an example of how to do this. I have tried using Matplotlib and Plotly but have encountered errors. I would like to know if anyone has successfully created a Candlestick chart using PySimpleGUI Canvas and could share their code or point me in the right direction. Tried many ways with pysimplegui, none worked.

converting matplotlib figure into a plotly figure

I am currently working in a project where i need to display Enthalpy/Pressure diagram which look like this:
Diagram enthalpy/Pressure
I am doing it with matplotlib & Coolprop using this kind of code:code diagram
I want an interactive figure where i can see the values of all the points i draw just by passing my mouse on them.
I know that plotly allow this kind of thing, so my question is how can i convert my matplotlib figure into a plotly one or how can i change my code to use plotly instead of matplotlib ?
Thank you

Is there a way to draw matplotlib plots to a window in some other 2D rendering library?

The idea would be that you'd have some 2D library for your GUI like PyGame and then draw the plots into the window generated by the library instead of an independent window generated by matplotlib. Allowing for user input and plot viewing in the same window.
I don't have any specific 2D library in mind, I'm not super familiar with Python libraries.
The only way I could find is by saving the plots to a file and then rendering that, but that seems extremely costly for real-time rendering (which is what I'm considering).
You can embed a plot from matplotlib into a tkinter app, check out their documentation here!
https://matplotlib.org/3.1.0/gallery/user_interfaces/embedding_in_tk_sgskip.html
Tkinter is a built-in package with cross platform support.

Attach matplot.figure.Figure to pyplot

TL;DR:
I would like to output a matplotlib.figure.Figure instance with matplotlib.pyplot.
Long version:
I have a function that returns a matplotlib.figure.Figure instance. The function adds some data to the figure, but does not yet show the graph. Thus, it is possible to decide afterwards what backend should be used to output the figure. I was able to find out how to do draw the graph with tkinter, and it shouldn't be much of a problem to do the same with other backends. But, and that is my problem, I couldn't find out how to draw the figure with a simple pyplot command. How should I do this?

Plotly moveable/draggable legends, python

Is it possible to make the plotly legends draggable? Currently I have my legend positioned outside the graph. I want to move it inside the graph, which is covered in the documentation, but I want to be able to make it draggable.
There is no direct way to drag the legend on a Plotly chart as far as I know.
You could find a workround by creating your legend in a HTML canvas and binding the onclick() function for each legend item to the Plotly PostMessage API restyle task.
There's a live example of the PostMessage API here which you should be able to hack apart. Let me know how you get on, this sounds interesting!
You can set "editable": True in the plot config.
https://github.com/plotly/plotly.js/blob/master/src/plot_api/plot_config.js#L46-L54

Categories

Resources