'PyX' 태그가 지정된 글

PyX example – Typecurve, Reserve

Arps typecurve

Arps typecurve

위 그림을 그리기 위한 python code는 다음과 같습니다.

from pyx import *

g=graph.graphxy(width=10,
                x=graph.axis.log(
                        title='$t_{Dd}$',min=0.01,max=1000,
                        painter=graph.axis.painter.regular(gridattrs=[color.gray(0.5)],tickattrs=[color.gray(0.5)])
                        ),
                x2=graph.axis.log(min=0.01,max=1000,parter=None,
                        painter=graph.axis.painter.regular(gridattrs=[color.gray(0.5)])),
                y=graph.axis.log(
                        title='$q_{Dd}$',min=0.001,max=10,
                        painter=graph.axis.painter.regular(gridattrs=[color.gray(0.5)],tickattrs=[color.gray(0.5)]))
                ,y2=graph.axis.log(min=0.001,max=10,parter=None,
                        painter=graph.axis.painter.regular(gridattrs=[color.gray(0.5)]))
                        )
g.plot([graph.data.file("arps.dat",x=1,y=j) for j in [3,4,5,6,8,9,10,11]],
                [graph.style.line([style.linestyle.solid,style.linewidth.Thin,color.gray(0.3)])])
g.plot([graph.data.file("arps.dat",x=1,y=j) for j in [2,7,12]],[graph.style.line([style.linestyle.solid,style.linewidth.Thick])])

g.text(5,0.5,r"$b=0.0$")
g.text(6.7,0.5,r"$b=0.5$")
g.text(8.8,0.5,r"$b=1.0$")

g.writeEPSfile('typeCurve')

그리고 데이터를 만들기 위한 code는 다음과 같습니다.

import math
fout='arps.dat'
f=open(fout,'w')

for it in range(-30,40):
        tdd=10.0**(it/10.0)
        q=range(11)
        q[0]=math.exp(-tdd)
        for ib in range(1,11):
                b=ib*0.1
                q[ib]=(1+b*tdd)**(-1/b)

        f.write("%s"%tdd)
        for j in range(0,11):
                f.write(" %s"%q[j])
        f.write("\n")

f.close()

아래의 그림들은 다음의 data를 이용하여 그렸습니다.
계속 읽기 ‘PyX example – Typecurve, Reserve’

Python plotting libraries

제가 접해본 python을 이용한 그림 그리기 프로그램 중 쓸만한 것으로는 MatplotlibPyX가 있습니다. 둘 다 python으로 코드를 짜면 그림을 그려주는 프로그램으로, paper에 출판할 수 있을 정도의 그림을 그릴 수 있습니다. 그 외에 PyXPlot이라고, gnuplot과 유사한 interface를 이용하면 자체적으로 PyX를 이용해 그림을 그려주는 프로그램이 있습니다.

Matplotlib은 제일 처음에 접했는데, 잠깐 쓰다가 말았습니다. 당시에는 기능이 떨어졌는데, 얼마 전에 보니 많이 upgrade 되었더군요. 앞으로 많이 사용하게 될 듯 합니다.

PyX는 eps, pdf 파일을 만들어줍니다. 상당히 자세한 부분까지 수정할 수 있어서 개인적으로 좋아하는 프로그램입니다. 하지만 update가 잘 안 되고, contour 그리기 기능이 없네요.

PyXPlot은 gnuplot을 써 보신 분들께서는 쉽게 쓰실 수 있는 프로그램으로, 간편하게 (gnuplot에 비하면 훨씬) 고품질의 그림을 그릴 수 있습니다. 쉽긴 하지만, PyX를 직접 쓰는 경우처럼 자세한 수정은 힘들죠.

앞으로 제가 그림을 그리기 위해 사용했던 코드와 그림들을 나중에 다시 참고하기 위해 블로그에 올릴 생각입니다.



팔로우

모든 새 글을 수신함으로 전달 받으세요.

다른 39명의 팔로워와 함께 하세요