Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Keep exact bitmap data when saving to vector file #16268

Open
Labels
keepItems to be ignored by the “Stale” Github Actiontopic: images
@Synxis

Description

@Synxis

I sometimes annotate plots using images (png format), and I want the image data not to be touched when saving to pdf: just put the data and the correct transformation in the pdf, if possible.
So instead of having a "fixed" dpi (which does not really make sense for vector formats anyway), passing something likedpi ='raw' (for example) would simply do what I explained before.

Even when explicitely addingresample = False, matplotlib still resample the image (I know this value is the default, but still). I don't know if this is a bug report or a feature request, I'm enclined to the former.

importnumpyasnpimportmatplotlibmatplotlib.use("agg")importmatplotlib.pyplotaspltdefadd_image(axe,filename,position,zoom):img=plt.imread(filename)off_img=matplotlib.offsetbox.OffsetImage(img,zoom=zoom,resample=False)art=matplotlib.offsetbox.AnnotationBbox(off_img,position,xybox= (0,0),xycoords=axe.transAxes,boxcoords="offset points",frameon=False)axe.add_artist(art)# ==========fig=plt.figure()axe=plt.axes()fig.set_size_inches(3,1.5)axe.plot(np.arange(10),np.arange(10))add_image(axe,"image.png",position= (0.2,0.7),zoom=0.07)fig.savefig("temp.pdf",bbox_inches="tight",pad_inches=0)

Use it withthis image from wikipedia asimage.png.

Actual outcome (screenshot):

actual

Expected outcome (screenshot):

expected

Matplotlib:

  • Version: 3.1.2
  • Backend: PDF
  • Python: 3.7 64bit
  • Installed via:pip
  • OS: Windows 10

Thank you

Metadata

Metadata

Assignees

No one assigned

    Labels

    keepItems to be ignored by the “Stale” Github Actiontopic: images

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp