Skip to content

Use higher-resolution icons on HiDPI-friendly backends #4978

Closed

Description

@astrofrog

On the MacOS X backend, the canvas is rendered at high resolution, but the icons are still low-res:

screen shot 2015-08-22 at 4 22 26 pm

It would be nice to use higher-res icons on backends that support HiDPI (at least MacOS X, PyQt5, and maybe others)

It looks like the icons are in SVG in lib/matplotlib/mpl-data/images/ so it should be easy to generate new ones.

Activity

  1. added this to the milestone on Aug 22, 2015
  2. astrofrog commented on Aug 28, 2015

    @astrofrog
    ContributorAuthor

    I started working on this, but was just curious if anyone knows how to find out whether one is using a HiDPI display? (figure.dpi returns 72 even on HiDPI). Also, the subplots.svg file is missing from mpl-data/images - does anyone have this, or will we need to re-make it?

  3. astrofrog commented on Aug 28, 2015

    @astrofrog
    ContributorAuthor

    @mdehoon - since you commented on this in #4977, do you have any ideas for how to decide which icons to use? (i.e. is there an easy way to know the monitor resolution?) Or should we just always use the HiDPI ones?

  4. mdehoon commented on Aug 29, 2015

    @mdehoon
    Contributor

    For the MacOSX backend, it's a Mac-specific API call. See https://github.com/mdehoon/matplotlib/blob/fixForIssue4977MacOSX/src/_macosx.m between line 4972 and 4992. For other backends I don't know; this will have to come from PyQt5.

  5. astrofrog commented on Aug 29, 2015

    @astrofrog
    ContributorAuthor

    @mdehoon - what would be the best way to expose this at the Python level (since it would be easier to choose the correct icons there)? Should I try adding a method to FigureCanvas or FigureManager in _macosx.m?

  6. mdehoon commented on Aug 31, 2015

    @mdehoon
    Contributor

    I am thinking to load the icon from a PDF file instead of a PNG file (unfortunately SVG is not available in Apple's API). Then the icon file to use is independent of the resolution. If so, do we still need to expose this at the Python level? And if so, how would you use it?

  7. tacaswell commented on Aug 31, 2015

    @tacaswell
    Member

    I think this would be useful to expose at the python layer because of partially done/upcoming reworking of the toolbar so exposing this to user specified icons would be good.

  8. mdehoon commented on Sep 2, 2015

    @mdehoon
    Contributor

    @astrofrog or @tacaswell can you suggest an API for this? Then I can have a look at how to implement it.

  9. tacaswell commented on Sep 2, 2015

    @tacaswell
    Member

    I defer to @OceanWolf and @fariza who are working on the new toolbar with regards to the API for setting icons.

  10. OceanWolf commented on Sep 2, 2015

    @OceanWolf
    Member

    With the new toolbar, each tool encapsulates the path to the icon (if none provided it just uses the text) has a class attribute image, but can get overridden by setting it on the object the_tool.image = 'the_filename.png'.

    Perhaps we could extend this, either to a preference list... but I have been thinking what do with WebAgg (and NbAgg though I haven't looked at the code there``, so now I think we should have an icon theme dictionary? Something like...

    image = {
      'default-theme': 'default_icon.png',
      'hires-theme': 'hires_icon.png',
      'web-theme': 'web_icon.png'
    }

    I think I prefer this method, because when we get onto WebAgg, we will have the issue of how to do the icons with the new-toolbar, and I think this method solves it in a very general way and thus highly extendible. What do others think?

  11. mdehoon commented on Sep 3, 2015

    @mdehoon
    Contributor

    I would suggest to leave out the extension of the image file name. Different backends may want to use different file formats; especially for HiDPI-friendly backends it makes sense to use a pdf or svg file, as they can be scaled to any resolution.

  12. OceanWolf commented on Sep 3, 2015

    @OceanWolf
    Member

    Also possible, but I still like the themes idea, something for 2.1 :). Can't wait!

  13. astrofrog commented on Sep 9, 2015

    @astrofrog
    ContributorAuthor

    @mdehoon - what is required to switch the MacOS X icons to PDF? There are SVG icons so it would be easy to generate the PDF, but what is required code-wise? (or will the PDF icons be automatically recongized?)

  14. mdehoon commented on Sep 10, 2015

    @mdehoon
    Contributor

    See https://github.com/mdehoon/matplotlib/tree/fixForIssue4977MacOSX
    Very little is needed. The only remaining point is to have a PDF version of the icon in the same directory as where the PNG, SVG etc. versions are located. Once those are there, I can switch the code to load the PDF instead of the PNG.

  15. fariza commented on Sep 10, 2015

    @fariza
    Member

    I was wondering, who uses the ppm and the xpm files?
    Is it possible to use the pdf or svg file for all backends?

  16. astrofrog commented on Sep 13, 2015

    @astrofrog
    ContributorAuthor

    See #5057 for updated icons for PyQt5

  17. QuLogic commented on Nov 24, 2016

    @QuLogic
    Member

    On #5057 @jenshnielsen noted that both the PyQt5 and macOS backends use HiDPI icons with the new icons; are there any other backends that need this?

  18. modified the milestones: , on Oct 3, 2017
  19. QuLogic commented on Feb 9, 2018

    @QuLogic
    Member

    I'm going to close this as it appears to work on the backends for which we support HiDPI, at least.

  20. modified the milestones: , v2.0.0 on Feb 9, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions