Reputation: 2520
I'm using matplotlib in my wx.Frame to draw some arrows and text at a certain position. The number and position of the arrows is based on previously created data. I do some calculations but basically it's like this:
arrow = primer for each primer: draw one arrow at position y - 0.05 to the previos arrow (primer_y - 0.05). The x position of the arrow comes from the data, which is calculated and scaled (not so important know, it's just to now where the arrow should be at primer_x).
Everything works fine until I have many arrows to draw. E.g. in my code example the data contain 62 arrows, where 18 are drawn correctly, the next 3 are missing but the text is there and the rest is completly missing.
Does anyone knows what could be the problem? I tried allready to change the FigureSize but it's only stretch the arrows.
Here's a quick and dirty working example, data is included in the code: http://pastebin.com/7mQmZm2c
Any help is highly appreciated! Thanks in advance! Stefanie
Upvotes: 1
Views: 207
Reputation: 879461
Stick
print((primer_x+0.06, primer_y))
inside the loop. You'll find that the arrows cease to be drawn when
primer_y
becomes negative.
self.axes.annotate
while labeling the
arrow with self.fig.text
. The axis and the figure use different
coordinate systems. Changing self.fig.text
to self.axes.text
will allow you to use the same coordinate system, which will make it
easier for you to position the text under the arrows.For example, if you change the for-loop to
for primer,primer_y in zip(data,np.linspace(0.95,0.0,len(data))):
instead of decrementing primer_y
by a fixed amount with each pass through the loop, then primer_y
will automatically space itself between 0.95 down to 0.0 no matter how many items there are in data
.
If you find the arrows are squished (vertically), you can expand the
figure by changing the figsize
on this line:
self.fig = matplotlib.figure.Figure(figsize=(20, 30), facecolor='white')
Upvotes: 3