플로팅을 위해 matplotlib를 사용하여 Julia의 특정 지점을 중심으로 직사각형을 그리고 회전하려고합니다. 그러나 그 작업을 수행하려면 두 가지 변형을 결합해야하는 것 같습니다. 어떻게해야할지 모르겠습니다.
using PyPlot
using PyCall
@pyimport matplotlib.patches as patches
@pyimport matplotlib as mpl
fig = figure(1)
ax = gca()
axis([-4,4,-4,4])
# specify non-rotated rectangle
length = 4
width = 2
rect = patches.Rectangle([1,1],length,width,color="blue",alpha=0.3)
rect_rotated = patches.Rectangle([1,1],length,width,color="red",alpha=0.3)
# rotate about the following point
point = [3,2]
# try to rotate rectangle using matplotlib's transformations
t1 = mpl.transforms[:Affine2D]()
t1[:rotate_deg_around](point[1],point[2], -30)
# apparently one also has to transform between data coordinate system and display coordinate system
t2 = ax[:transData]
변환을 결합하기 위해 지금 수행하고 싶은 작업 :
t3 = t1 + t2
rect_rotated[:set_transform](t3)
ax[:add_patch](rect)
ax[:add_patch](rect_rotated)
그러나 다음과 같은 오류가 발생합니다.
오류 : LoadError : MethodError : + (:: PyCall.PyObject, :: PyCall.PyObject)와 일치하는 메서드가 없습니다.
기본 변환을 결합하기 위해 "+"기호를 지원하지 않는 PyPlot-Wrapper 때문이라고 생각합니다.
누구든지 이것을 작동시키는 방법을 알고 있습니까? 감사합니다
파이썬은 첫 번째 객체의 메서드를 사용하여 연산자 오버로딩을 구현 t3 = t1 + t2
합니다 t3 = t1.__add__(t2)
.
Julia에서 이것은 t3 = t1[:__add__](t2)
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다