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
Stick
inside the loop. You’ll find that the arrows cease to be drawn when
primer_ybecomes negative.self.axes.annotatewhile labeling thearrow with
self.fig.text. The axis and the figure use differentcoordinate systems. Changing
self.fig.texttoself.axes.textwill allow you to use the same coordinate system, which will make it
easier for you to position the text under the arrows.
hard-coded numbers (“magic numbers”) in your code. It makes it very
hard to fix because when one number changes, the rest to do not change
in a logical way along with it. If you can use formulas to define
the relationship between some of those magic numbers, your life will
be a lot easier.
For example, if you change the for-loop to
instead of decrementing
primer_yby a fixed amount with each pass through the loop, thenprimer_ywill automatically space itself between 0.95 down to 0.0 no matter how many items there are indata.If you find the arrows are squished (vertically), you can expand the
figure by changing the
figsizeon this line: