2014-09-04 4 views
1

내가 Y 축, 밖으로 왼쪽 방향의 오른쪽 방향을 틱 설정하려고 틱. 여기 하기 matplotlib 설정 y 축이

당신은 내가

을하려고하고 무엇을 이해하는 데 도움이 될 코드의 조각이다
import wx 
from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg 
from matplotlib.figure import Figure 
from matplotlib.axes import Axes 

class Frame(wx.Frame): 
    def __init__(self): 
     # initialize 
     wx.Frame.__init__(self, None) 
     # create main sizer 
     mainSizer = wx.BoxSizer(wx.VERTICAL) 
     # create figure, canvas and matplotlib toolbar 
     self.figure = Figure(figsize=(4.5,4), dpi=None) 
     self.canvas = FigureCanvasWxAgg(self, -1, self.figure) 
     # add canvas to sizer 
     mainSizer.Add(self.canvas, proportion=1, flag=wx.ALL|wx.EXPAND) 
     self.SetSizer(mainSizer) 
     mainSizer.Fit(self) 
     self.Show(True) 

app = wx.App(0)   
frame = Frame() 
axes = frame.figure.add_axes((0.1,0.1,0.8,0.8)) 

axes.tick_params(reset=True) 
axes.tick_params(axis='y',which="major", direction="in", 
       left=True,reset=False, labelleft=True) 
axes.tick_params(axis='y',which="major", direction="out", 
       right=True,reset=False, labelright=True) 

frame.canvas.draw() 

app.MainLoop() 

enter image description here

는 일반적으로 난 왼쪽 축 내부로 틱 원하는 오른쪽 외부

답변

0

이 조금있을 수 틱 까다 롭고 다른 전문가들은 인터페이스를 실제로 발견하여 뭔가를 찾을 수 있습니다. 그 동안 왼쪽 틱에 영향을주지 않고도 올바른 틱 속성을 설정할 수 있도록 트윈 축을 사용하는 것이 하나의 옵션입니다. 예 : 다음은 (이 나는 코드의 관련 부분 꺼냈다) :

import matplotlib.pyplot as plt 

fig = plt.figure() 
axes = fig.add_axes((0.1,0.1,0.8,0.8)) 

axes.tick_params(axis='y',which="major", direction="in", 
       left=True,reset=False, labelleft=True) 

axes2 = axes.twinx() 
axes2.tick_params(axis='y', which='major', direction='out') 

plt.show() 

이 모든 시간을 할 경우, 그러나, 그것은 해킹 같은 느낌이 그래서 ... 최선의 선택이 될 수 없습니다를

+0

고마워요, 저는 이미 쌍둥이 축에 대해 생각해 봤지만 불행하게도 제 경우에는 도움이되지 않습니다. 필자가 작성한 코드는 내가하고 싶은 것을 설명하기위한 단순한 예입니다. – Cobry

+0

@Cobry 예, 완전히 이해가됩니다. 단지 내가 그것을 제공 할 줄 알았다. – Ajean