Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Bug in the HiDPI support in the qt5agg backend #8717

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
djpine opened this issue Jun 4, 2017 · 3 comments
Closed

Bug in the HiDPI support in the qt5agg backend #8717

djpine opened this issue Jun 4, 2017 · 3 comments

Comments

@djpine
Copy link

djpine commented Jun 4, 2017

Bug report

Bug summary

The interactive plot window is too small, but the text remains at the size that would be correct for a larger properly sized window.

It works if you go through pyplot:

fig, ax = plt.subplots(figsize=(6,4))
ax.plot([1,2,3])

but not in this example, which uses the pure OO interface.

The version of the plot saved to the file text.pdf is correctly sized.

Code for reproduction

from matplotlib.backends.backend_qt5agg \
     import FigureCanvasQTAgg as FigureCanvas
from matplotlib.figure import Figure

fig = Figure(figsize=(6, 4))
canvas = FigureCanvas(fig)
ax = fig.add_subplot(111)
ax.plot([1, 2, 3, 2, 3, 4, 3, 4, 5])
ax.set_title('A simple plot')
ax.grid(True)
ax.set_xlabel('time')
ax.set_ylabel('volts')
canvas.print_figure('test.pdf')
canvas.show()

Actual outcome

screen shot 2017-06-04 at 2 43 05 pm

Expected outcome

screen shot 2017-06-04 at 2 52 48 pm

Matplotlib version

  • Operating System: MacOS Sierra 10.12.5
  • Matplotlib Version: 2.0.2
  • Python Version: 3.6.1
  • Jupyter Version (if applicable):
  • Other Libraries:

Installed with conda (default)

@tacaswell tacaswell added this to the 2.1 (next point release) milestone Jun 5, 2017
@tacaswell
Copy link
Member

😞 I thought we had this sorted out.

There is a bunch of jiggery-pokery to double the DPI under the hood. Does it help if you set the figure size after your create and add the canvas?

attn @efiring

@djpine
Copy link
Author

djpine commented Jun 5, 2017 via email

@QuLogic
Copy link
Member

QuLogic commented Jun 5, 2017

The FigureCanvas sets a (non-binding) sizeHint; the FigureManager takes the hint + the toolbar size and sets the window to the correct size. I think if you want to use the canvas directly, you'll need to read the size and set it as a hard requirement, or maybe set the QSizePolicy to require the hinted size.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants