how to add background image to matplotlib figure or figurecanvas - python

I am working on a project where I am using PYgtk to build UI which make use of matplotlib library for plotting purpose. Plot window is packed in UI using PYgtk scrolled window container widget as the actual plot will be very big in size.
I want to put an image as a background to figure or figurecanvas, but not to subplot. I want subplot to scroll but not background image.
I am trying with slider option in matplotlib. but still no success.
Can anyone help me to solve this issue?

Related

Using vispy canvas within pyqtgaph viewbox

I am using pyqtgraph.ImageView to visualize data.
I need to smooth transition in my image with vispy like in this photo:
Do you know any way to get this kind of result with pyqtgraph or any way to integrate vispy canvas into pyqtgraph.ImageView?

Hide the window frame around image plotted with matplotlib

I'm using matplotlib to show a picture but I want to hide the window frame.
I tried the code frameon=False in plt.figure() but the window frame is still there. Just the background color turns to grey.
Here is the code and running result. The picture was showing with the window even I add the "frameon=False" in the code.
frameon suppresses the figure frame. What you want to do is show the figure canvas in a frameless window, which cannot be managed from within matplotlib, because the window is an element of the GUI that shows the canvas. Whether it is possible to suppress the frame and how to do that will depend on the operating system and the matplotlib backend in use.
Let's consider the tk backend.
import matplotlib
# make sure Tk backend is used
matplotlib.use("TkAgg")
import matplotlib.pyplot as plt
# turn navigation toolbar off
plt.rcParams['toolbar'] = 'None'
# create a figure and subplot
fig, ax = plt.subplots(figsize=(2,2))
#remove margins
fig.subplots_adjust(0,0,1,1)
# turn axes off
ax.axis("off")
# show image
im = plt.imread("https://upload.wikimedia.org/wikipedia/commons/8/87/QRCode.png")
ax.imshow(im)
# remove window frame
fig.canvas.manager.window.overrideredirect(1)
plt.show()

matplotlib application issue by python [duplicate]

I'm using matplotlib to show a picture but I want to hide the window frame.
I tried the code frameon=False in plt.figure() but the window frame is still there. Just the background color turns to grey.
Here is the code and running result. The picture was showing with the window even I add the "frameon=False" in the code.
frameon suppresses the figure frame. What you want to do is show the figure canvas in a frameless window, which cannot be managed from within matplotlib, because the window is an element of the GUI that shows the canvas. Whether it is possible to suppress the frame and how to do that will depend on the operating system and the matplotlib backend in use.
Let's consider the tk backend.
import matplotlib
# make sure Tk backend is used
matplotlib.use("TkAgg")
import matplotlib.pyplot as plt
# turn navigation toolbar off
plt.rcParams['toolbar'] = 'None'
# create a figure and subplot
fig, ax = plt.subplots(figsize=(2,2))
#remove margins
fig.subplots_adjust(0,0,1,1)
# turn axes off
ax.axis("off")
# show image
im = plt.imread("https://upload.wikimedia.org/wikipedia/commons/8/87/QRCode.png")
ax.imshow(im)
# remove window frame
fig.canvas.manager.window.overrideredirect(1)
plt.show()

Python Plotting and displaying multiple objects in same GUI window

I have a 2 part question:
what is the best method for plotting data in Python? I only need to plot data in 2d.
I have a canvas GUI that I built using Tkinter's canvas function. It draws an 8x8 grid of rectangles and also has some code to allow you to scroll the window. (I've attached a picture).
Is it possible to include a plot in the same window as this canvas object? I need to be able to display plotted data and hopefully add buttons to my GUI that will allow me to update the plot during the run of the GUI.
Thanks in advance!
Matplotlib is the de-facto way to plot data with Python. It's really wonderful. It can also be embedded in Tk.

Matplotlib zooming work in conjunction with wxPython ScrolledWindow

I've got a Matplotlib canvas (FigureCanvasWxAgg) that I'm displaying inside of a wx.ScrolledWindow. The problem is that I'd like to have the default zooming and panning functionality of Matplotlib work in conjunction with the ScrolledWindow, so that when the user zooms the image within the canvas, the ScrolledWindow should become larger to accommodate for the zooming (scrollbars become smaller). Similarly for panning, I'd like the default matplotlib panning tool to work in conjunction with our ScrolledWindow, so that when the user pans the image on the canvas, the ScrolledWindow's scrollbars should move accordingly.
I've been searching for a while now and have not seen anyone even mention if this is possible. Could anyone point me in the right direction?
Thank you for any help/tips.
The problem is that the default Zoom and Pan don't resize the figure, they just change the limits and redraw the plot.
What you want is the Zoom to resize (keeping the same limits) and the Pan to work as in a normal Scrolled window. I have never tried this, fig.set_size_inches(w,h) should do the trick.

Categories