I'm trying to plot data with pyqtgraph and add an interactive widget that allows me to hover over the graph to see the timestamp. When I run the code, vscode refuses to display an interactive plot, nor does it open in another window. I'm using a jupyter notebook (.ipynb) inside vscode so I thought the interactivity would work. I've created a new env just with the core dependencies but it still doesn't show any widgets. I also installed several packages with pip but when I do which <package> it doesn't find it, but it's in the list when I do pip list.
#๐ Cannot get interactive plots to display in VSCode using any $matplotlib commands
6 messages ยท Page 1 of 1 (latest)
@median trout
Remember to:
- Ask your Python question, not if you can ask or if there's an expert who can help.
- Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
- Explain what you expect to happen and what actually happens.
:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.
Closes after a period of inactivity, or when you send !close.
import pytplot
import pyqtgraph as pg
window = pg.GraphicsLayoutWidget()
def text_window():
# Set up plotting window
window.setWindowTitle('Interactive Window')
plot = window.addPlot()
# Add the text item (with crazy HTML inserted, this was the textitem example on pyqtgraph's website)
textitem = pg.TextItem(html='<div style="text-align: center"><span style="color: #FFF;">This is the</span><br><span style="color: #FF0; font-size: 32pt;">PEAK</span></div>', anchor=(-0.3,0.5), border='w', fill=(0, 0, 255, 100))
plot.addItem(textitem)
textitem.setPos(1,1)
# Define what the plot will do when the user hovers over a new time
def update(time, name):
textitem.setText(str(time))
# Register to update function above to pytplot
pytplot.hover_time.register_listener(update)
pytplot.store_data("test_data", data={'x':[100,200,300,400,500], 'y':[1,2,3,4,5]})
pytplot.tplot("test_data", extra_functions=[text_window])
this is what shows up when i run the code. no widget to be found
@median trout
This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.