On Wed, Sep 26, 2012 at 5:58 AM, Pierre Haessig <pierre.haes...@crans.org>wrote:

> Hello,
>
> In relation to the recent thread on pareto chart, I have a question with
> regards to the synchronization of ticks location when using twinx plots.
> This question may have been adressed in the past, but my Google search
> on this topic was unfruitful. Sorry if this question was already answered.
>
> Basically, when using twinx two plot two different data sets, the scale
> of the data, in the general case, is to be different (thus the need for
> twinx). However, adding a grid to such a twinx plot leads to a very
> irregular placement because the ticks positions are not "synchronized".
> (I pasted a quick example to illustrate the tick placement issue at the
> end of this message)
>
> Ideally, I would like that both axis share a common placement for the
> ticks. Is there a way to do that ?
>
> I guess this would require that the two ticks Locators share "some
> algorithm" so that they would "agree" on the placement instead of
> working separetely. Other option may be that one Locator could work as a
> slave of the other one. (I'm just trying to draw a rough picture)
>
> Best,
> Pierre
>
> quick example to illustrate the tick placement issue :
>
> import matplotlib.pyplot as plt
>
> ax1 = plt.subplot(111)
> ax1.plot([1,2,3], 'bo-')
> ax1.grid(True)
>
> ax2 = plt.twinx(ax1)
> ax2.plot([11,12], 'rs-')
> ax2.grid(True)
>
> ax1.set_xlim(-0.5,2.5)
>
> plt.show()
>
>
>
Probably could have the two axes listen for an "xlim_changed" event, check
to see if it belongs to its twin, and update itself accordingly (without
emitting).

Ben Root
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to