File tree 2 files changed +28
-6
lines changed
2 files changed +28
-6
lines changed Original file line number Diff line number Diff line change 1
1
"""
2
- matplotlib is fairly rigid about how and where it draws it xaxis and
3
- yaxis, and it is a frequent request to be able to place these in other
4
- locations. While it is not possible to customize matplotlib's
5
- internal axis objects in this way, it is not too hard to simply turn
6
- them off and draw your own axis lines, tick lines, and tick labels
7
- where and how you want them
2
+ The techniques here are no longer required with the new support for
3
+ spines in matplotlib -- see
4
+ http://matplotlib.sourceforge.net/examples/pylab_examples/spine_placement_demo.html.
5
+
6
+ This example should be considered deprecated and is left just for demo
7
+ purposes for folks wanting to make a pseudo-axis
8
+
8
9
"""
9
10
10
11
import numpy as np
Original file line number Diff line number Diff line change 80
80
:class:`NullFormatter`
81
81
no labels on the ticks
82
82
83
+ :class:`IndexFormatter`
84
+ set the strings from a list of labels
85
+
83
86
:class:`FixedFormatter`
84
87
set the strings manually for the labels
85
88
@@ -203,6 +206,24 @@ def fix_minus(self, s):
203
206
"""
204
207
return s
205
208
209
+ class IndexFormatter :
210
+ """
211
+ format the position x to the nearest i-th label where i=int(x+0.5)
212
+ """
213
+ def __init__ (self , labels ):
214
+ self .labels = labels
215
+ self .n = len (labels )
216
+ def __call__ (self , x , pos = None ):
217
+ 'Return the format for tick val x at position pos; pos=None indicated unspecified'
218
+ i = int (x + 0.5 )
219
+ if i < 0 :
220
+ return ''
221
+ elif i >= self .n :
222
+ return ''
223
+ else :
224
+ return self .labels [i ]
225
+
226
+
206
227
class NullFormatter (Formatter ):
207
228
'Always return the empty string'
208
229
def __call__ (self , x , pos = None ):
You can’t perform that action at this time.
0 commit comments