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

Images shifted relative to other plot feature in vector graphic output formats #1085

Closed
Assignees
mdboom
@technobauble

Description

@technobauble

When writing out plots in vector graphics formats, the image data can be shifted relative to the axes window.

Here is a list of things I've noticed about the problem:

  • When data is shifted outside the axes window, it is clipped. Sometimes the data will be shifted entirely outside the axes window and the plot will appear blank.
  • I've observed the problem in ps/eps/pdf/svg output files.
  • The interpolation method used seems to have an effect on the shifted result.
  • All of the image data is contained within the output file and can be retrieved using a program like inkscape (although some digging is required)
  • The shift seems to be different in different viewers. For example, pdf output looks okay in Okular but not in xpdf.

There have been a couple of emails about this on the users mailing list. Benjamin Root verified the problem. Eric Firing suggested that it might be a truncation error bug and suggested the following:

I thought it might come from the use of str() instead of repr() when
generating the concat matrix in the ps backend, but that's not it. I'm
suspecting it may be inherent in the ps language, when one uses a matrix
to make an enormous translation in one direction, and then uses
translate to sling everything back in the other direction. Either that,
or some sort of "snapping" is going on.

--Chad

Here are some scripts that can be used to reproduce the problem:

importmatplotlib.pyplotaspltfrommatplotlib.colorsimportLogNormimgData= [[1.0/(x)+1.0/(y)forxinrange(1,100)]foryinrange(1,100)]tMin=734717.945208tMax=734717.946366# Case 0: WorksCase0={"id":0,"interp":None,"extents":(tMin,tMax,1,100)}# Case 1: WorksCase1={"id":1,"interp":"none","extents":(1,100,1,100)}# Case 2: Doesn't workCase2={"id":2,"interp":"none","extents":(tMin,tMax,1,100)}forCasein (Case2,Case1,Case0):plt.figure(Case["id"])axImg=plt.subplot(111)axImg.imshow(imgData,norm=LogNorm(),interpolation=Case["interp"],extent=Case["extents"])axImg.set_aspect('auto')forfiletypein ["png","eps","pdf","svg"]:plt.savefig("imageshift-Case{0}.{1}".format(Case["id"],filetype))
# modified by Eric Firingimportmatplotlib.pyplotaspltfrommatplotlib.colorsimportLogNormimgData= [[1.0/x+1.0/yforxinrange(1,10)]foryinrange(1,10)]tMin=1000000066# Shifted by halftMin=100000066# Blank!tMin=10000066# OKtMax=tMin+10# The following combination is also shifted by halftMin=10000066.1# adding the 0.1 doesn't make a differencetMax=tMin+1printtMin,tMaxaxImg=plt.subplot(111)axImg.imshow(imgData,norm=LogNorm(),extent=(tMin,tMax,1,10),interpolation='none',origin="upper")axImg.set_aspect('auto')plt.savefig("imageshift.png")plt.savefig("imageshift.eps")plt.savefig("imageshift.pdf")

Metadata

Metadata

Assignees

Labels

No labels
No labels

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