From: John H. <jdh...@ac...> - 2005-01-26 19:57:41
|
>>>>> "Baptiste" == Baptiste Carvello <bap...@al...> writes: Baptiste> Hello, I tried to improve the way of plotting two scales Baptiste> (cf examples/two_scales.py). The attached patch contains Baptiste> the following changes: Hi Baptiste -- I applied your patch and am very impressed. It takes a lot of hacking through matplotlib internals to get everything working right together with transform, axis limits and the like. Your approach is also a significant improvement over what we currently have. Here is what I think would be ideal, and I wanted to sketch some of these ideas in hopes that you might have some ideas on how to apply them. Basically, the idea is that we want one axes to be able to share the x or y limits with another axes in a more general way. Your approach works fine as long as the two axes are overlayed. It would be nice if we could do something like # separate axes ax1 = subplot(211) plot([1,2,3]) ax2 = subplot(212, twinx=ax1) plot([4,5,6]) To do overlayed axes, you could do # overalyed axes ax1 = subplot(111) plot([1,2,3]) ax2 = subplot(111, twinx=ax1, yticks='right') plot([4,5,6]) I think this would be a nice consistent interface and in both cases ax2 would share the xlim with ax1. As far as I can see, the only thing getting in the way of extending your approach to handle this case are the tick labels, since they would be in the wrong place for ax2 in the separate axes case. For the separate axes case, you would typically want tick labeling on the lower axes, but it would be ideal to be able to control that as well. I've been meaning to decouple the axis line and tick locations from the main axes frame so that you could have offset labels and ticks. Perhaps this would be a good time to make both changes together. The other problem in the current implementation (and in your patch) stems from the fact that for event handling, only one axes gets the event. So in your two_scales.py example, if you pan/zoom the xlimits behave correctly but only one axes gets the pan/zoom event for y. It would be nice to pass these events on to all the axes the user is over to handle the case of overlapping axes. Just some thoughts on what I think the proper behavior should be. If you have any ideas on how to handle these, let me know. I just applied your two scales patch to CVS as an improved interim solution. Thanks! JDH |