Repository navigation
Closed as not planned
Labels
GUI: gtkOS: Applebackend: cairostatus: closed as inactiveIssues closed by the "Stale" Github Action. Please comment on any you think should still be open.Issues closed by the "Stale" Github Action. Please comment on any you think should still be open.status: inactiveMarked by the “Stale” Github ActionMarked by the “Stale” Github Action
Description
Bug report
Bug summary
I tried to use Gtk3Cairo backend to display a matplotlib figure on my Gtk3 window.
When the FigureCanvas is added and drawn by Gtk, the rendered size of objects seems to double (see figures).
Code for reproduction
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk, Gdk
from matplotlib.figure import Figure
import random as Rdm
from matplotlib.backends.backend_gtk3cairo import FigureCanvas
def getDiagram():
f = Figure(figsize=(100, 100))
plot = f.add_subplot(1, 1, 1)
# Add figure
labels = ['Mo', 'Tu', 'We', 'Th', 'Fr','Sa', 'Su']
width = 0.93 # the width of the bars
data = [[1,15],[17,22], [3,7]]
for i in range(0,len(data)):
plotColor = Gdk.RGBA(Rdm.random(),Rdm.random(),Rdm.random(),1)
plot.bar(labels, data[i][0], width, yerr=None, bottom=data[i][1],
color=(plotColor.red, plotColor.green, plotColor.blue))
plot.set_frame_on(True)
plot.yaxis.set_visible(True)
plot.set_ylim(0.0,24.0)
return f
#END getDiagram
class testWin(Gtk.Window):
def __init__(self):
Gtk.Window.__init__(self)
self.set_default_size(500,600)
self.show()
grid = Gtk.Grid()
self.add(grid)
fig = getDiagram()
canvas = FigureCanvas(fig)
canvas.set_size_request(200,200)
topButton = Gtk.Button(label="Button Top")
grid.attach(topButton,0,0,2,1)
grid.attach(canvas,0,1,2,1)
#grid.attach(Gtk.Label("Test"),0,1,2,1)
botButton = Gtk.Button(label="Button Bottom")
grid.attach(botButton,0,2,2,1)
self.show_all()
#END testWin
win = testWin()
win.connect("destroy",Gtk.main_quit)
win.show_all()
Gtk.main()Actual outcome
Expected outcome
The size of rendered objects shouldn't change when I add the FigureCanvas.
Matplotlib version
- Operating system: macOS 10.13.4
- Matplotlib version: 3.3.0
- Matplotlib backend (
print(matplotlib.get_backend())): MacOSX - Python version: 3.8.4
- Other libraries:
pycairo: 1.19.1
PyGObject: 3.36.1
I installed matplotlib and the other Python libraries with pip3
Metadata
Metadata
Assignees
Labels
GUI: gtkOS: Applebackend: cairostatus: closed as inactiveIssues closed by the "Stale" Github Action. Please comment on any you think should still be open.Issues closed by the "Stale" Github Action. Please comment on any you think should still be open.status: inactiveMarked by the “Stale” Github ActionMarked by the “Stale” Github Action


Activity
QuLogic commentedon Jul 29, 2020
I guess you have a HiDPI/retina screen? I can't reproduce on Linux, but don't have HiDPI, and setting
GDK_SCALE=2scales everything else correctly.jeremydufour commentedon Jul 29, 2020
Yes I have a Retina screen which is HiDPI. I tried exporting GDK_SCALE and GDK_DPI_SCALE before running my script but nothing changes. Maybe those two parameters can be accessed with Python ?
tacaswell commentedon Jul 29, 2020
I can not reproduce this on linux and I see that
GDK_SCALE=2scales things correctly.How did you install Python and gtk?
jeremydufour commentedon Jul 29, 2020
I installed Python 3.8 with the installer from python.org (no homebrew/macports). I installed Gtk, Cairo, GLib and Gobject-introspection with homebrew.
QuLogic commentedon Sep 8, 2021
Maybe #20988 will fix this?
In experimenting with that, I see that
GDK_SCALEonly has an effect with X11 and not Wayland. Perhaps the same is true of the Quartz backend?github-actions commentedon Aug 14, 2023
This issue has been marked "inactive" because it has been 365 days since the last comment. If this issue is still present in recent Matplotlib releases, or the feature request is still wanted, please leave a comment and this label will be removed. If there are no updates in another 30 days, this issue will be automatically closed, but you are free to re-open or create a new issue if needed. We value issue reports, and this procedure is meant to help us resurface and prioritize issues that have not been addressed yet, not make them disappear. Thanks for your help!