2013-05-17 5 views
7

방사형 축의 시작을 오프셋하거나 그래프 외부로 이동할 수 있는지 궁금합니다.Matplotlib 극좌표 방사형 축 오프셋

이 내가 달성하기 바라고 있어요 무엇 :

Goal

을 그리고 이것은 내가 지금 가지고있는 것입니다.

CurRes

나는 SO에 대한 설명서 및 다른 주제를 읽고,하지만 난 도움이 아무것도 찾을 수 없습니다. 그것이 아무 곳에도 언급되지 않는다면 그것은 가능하지 않다는 것을 의미합니까?

미리 감사드립니다.

EDIT (플롯을 만드는 데 사용되는 코드의 추가 조각) 다음 polar plot 그런 조정할 수있는 경우

ax = fig.add_subplot(111, projection='polar') 
ax.set_theta_zero_location('N') 
ax.set_theta_direction(-1)  
ax.plot(X,lines[li]*yScalingFactor,label=linelabels[li],color=color,linestyle=ls) 
+0

다이어그램을 작성한 코드를 게시하십시오. –

+0

코드는 극좌표 플로팅의 표준이지만, 그럼에도 게시글을 편집하고 코드를 추가했습니다. 그리고 데이터는 수식이 아니라 데이터 집합입니다. – Renesis

답변

6

나는 확실하지 않다. 그러나 the last example given here: Floating Axes을 기반으로 한 해결 방법이 있습니다. 당신이 그것을 붙여 복사/경우

나는, 그것을 실행해야합니다, 코드에 설명 주석을 포함했다있는 그대로 :

pseudo polar plot

:

import mpl_toolkits.axisartist.floating_axes as floating_axes 
from matplotlib.projections import PolarAxes 
from mpl_toolkits.axisartist.grid_finder import FixedLocator, \ 
    MaxNLocator, DictFormatter 
import numpy as np 
import matplotlib.pyplot as plt 

# generate 100 random data points 
# order the theta coordinates 

# theta between 0 and 2*pi 
theta = np.random.rand(100)*2.*np.pi 
theta = np.sort(theta) 

# "radius" between 0 and a max value of 40,000 
# as roughly in your example 
# normalize the r coordinates and offset by 1 (will be clear later) 
MAX_R = 40000. 
radius = np.random.rand(100)*MAX_R 
radius = radius/np.max(radius) + 1. 

# initialize figure: 
fig = plt.figure() 

# set up polar axis 
tr = PolarAxes.PolarTransform() 

# define angle ticks around the circumference: 
angle_ticks = [(0, r"$0$"), 
       (.25*np.pi, r"$\frac{1}{4}\pi$"), 
       (.5*np.pi, r"$\frac{1}{2}\pi$"), 
       (.75*np.pi, r"$\frac{3}{4}\pi$"), 
       (1.*np.pi, r"$\pi$"), 
       (1.25*np.pi, r"$\frac{5}{4}\pi$"), 
       (1.5*np.pi, r"$\frac{3}{2}\pi$"), 
       (1.75*np.pi, r"$\frac{7}{4}\pi$")] 

# set up ticks and spacing around the circle 
grid_locator1 = FixedLocator([v for v, s in angle_ticks]) 
tick_formatter1 = DictFormatter(dict(angle_ticks)) 

# set up grid spacing along the 'radius' 
radius_ticks = [(1., '0.0'), 
       (1.5, '%i' % (MAX_R/2.)), 
       (2.0, '%i' % (MAX_R))] 

grid_locator2 = FixedLocator([v for v, s in radius_ticks]) 
tick_formatter2 = DictFormatter(dict(radius_ticks)) 

# set up axis: 
# tr: the polar axis setup 
# extremes: theta max, theta min, r max, r min 
# the grid for the theta axis 
# the grid for the r axis 
# the tick formatting for the theta axis 
# the tick formatting for the r axis 
grid_helper = floating_axes.GridHelperCurveLinear(tr, 
                extremes=(2.*np.pi, 0, 2, 1), 
                grid_locator1=grid_locator1, 
                grid_locator2=grid_locator2, 
                tick_formatter1=tick_formatter1, 
                tick_formatter2=tick_formatter2) 

ax1 = floating_axes.FloatingSubplot(fig, 111, grid_helper=grid_helper) 
fig.add_subplot(ax1) 

# create a parasite axes whose transData in RA, cz 
aux_ax = ax1.get_aux_axes(tr) 

aux_ax.patch = ax1.patch # for aux_ax to have a clip path as in ax 
ax1.patch.zorder=0.9 # but this has a side effect that the patch is 
        # drawn twice, and possibly over some other 
        # artists. So, we decrease the zorder a bit to 
        # prevent this. 

# plot your data: 
aux_ax.plot(theta, radius) 
plt.show() 

이 다음 플롯을 생성합니다 당신은 당신의 요구를 충족시키기 위해 축 라벨을 조정해야합니다.
그렇지 않으면 플롯에서와 같은 문제가 발생했기 때문에 데이터 크기를 조정했습니다. 내부의 빈 원은 점으로 크기가 조정되었습니다. 극좌표를 사용해 스케일링을 시도하고 방사형 축에 맞춤 레이블을 붙여서 비슷한 효과를 얻을 수 있습니다.

+0

나는 한동안 활동적이지 않았기 때문에 누군가가 실제로 도움을 줄 것이라고 기대하지 않았습니다. 이것은 다소 도움이되며 필요할 때처럼 수정할 수 있기를 바랍니다. – Renesis

+0

나는 이것을 월요일에 수정하려고 노력할 것인데, 나는 결과를보고 할 것이다. 다시 한번 감사드립니다. – Renesis