## matplotlib-users

 [Matplotlib-users] simple question about locator every 0.5 From: C M - 2011-07-20 20:23:23 ```Sorry, this is super-simple, but I'm lost in the whole locator/formatter part of the docs. How can I make a locator that just places a tick at every multiple of 0.5 around the data? So the y axis would look like: 3.5 -- 3.0 -- 2.5 -- 2.0 -- 1.5 -- 1.0 -- etc. Thanks, Che ```
 Re: [Matplotlib-users] simple question about locator every 0.5 From: Buchholz, Greg - 2011-07-20 23:39:46 ```>-----Original Message----- >From: C M [mailto:cmpython@...] > >Sorry, this is super-simple, but I'm lost in the whole >locator/formatter part of the docs. > >How can I make a locator that just places a tick at every multiple of >0.5 around the data? So the y axis would look like: > >3.5 -- >3.0 -- >2.5 -- >2.0 -- >1.5 -- >1.0 -- Do you want something like: ylim(1.0,3.5) yticks(arrange(1.0,4.0,0.5)) ```
 Re: [Matplotlib-users] simple question about locator every 0.5 From: C M - 2011-07-20 23:41:39 ```On Wed, Jul 20, 2011 at 7:24 PM, Buchholz, Greg wrote: >>-----Original Message----- >>From: C M [mailto:cmpython@...] >> >>Sorry, this is super-simple, but I'm lost in the whole >>locator/formatter part of the docs. >> >>How can I make a locator that just places a tick at every multiple of >>0.5 around the data?  So the y axis would look like: >> >>3.5 -- >>3.0 -- >>2.5 -- >>2.0 -- >>1.5 -- >>1.0 -- > > Do you want something like: > >    ylim(1.0,3.5) >    yticks(arrange(1.0,4.0,0.5)) I'm not sure, because I can't try it out--I'm using the OO matplotlib, not Pyplot. What's the equivalent of this in the OO API? Thanks, Che ```
 Re: [Matplotlib-users] simple question about locator every 0.5 From: Gökhan Sever - 2011-07-20 23:56:37 Attachments: Message as HTML ```On Wed, Jul 20, 2011 at 5:41 PM, C M wrote: > On Wed, Jul 20, 2011 at 7:24 PM, Buchholz, Greg > wrote: > >>-----Original Message----- > >>From: C M [mailto:cmpython@...] > >> > >>Sorry, this is super-simple, but I'm lost in the whole > >>locator/formatter part of the docs. > >> > >>How can I make a locator that just places a tick at every multiple of > >>0.5 around the data? So the y axis would look like: > >> > >>3.5 -- > >>3.0 -- > >>2.5 -- > >>2.0 -- > >>1.5 -- > >>1.0 -- > > > > Do you want something like: > > > > ylim(1.0,3.5) > > yticks(arrange(1.0,4.0,0.5)) > > I'm not sure, because I can't try it out--I'm using the OO matplotlib, > not Pyplot. What's the equivalent of this in the OO API? > ax.axis((xmin, xmax, ymin, ymax)) ax.yaxis.set_ticks(np.arange(1.0, 4.0, 0.5)) > > Thanks, > Che > > > ------------------------------------------------------------------------------ > 10 Tips for Better Web Security > Learn 10 ways to better secure your business today. Topics covered include: > Web security, SSL, hacker attacks & Denial of Service (DoS), private keys, > security Microsoft Exchange, secure Instant Messaging, and much more. > http://www.accelacomm.com/jaw/sfnl/114/51426210/ > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users@... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > -- Gökhan ```
 Re: [Matplotlib-users] simple question about locator every 0.5 From: C M - 2011-07-21 01:17:29 ```On Wed, Jul 20, 2011 at 7:56 PM, Gökhan Sever wrote: > > > On Wed, Jul 20, 2011 at 5:41 PM, C M wrote: >> >> On Wed, Jul 20, 2011 at 7:24 PM, Buchholz, Greg >> wrote: >> >>-----Original Message----- >> >>From: C M [mailto:cmpython@...] >> >> >> >>Sorry, this is super-simple, but I'm lost in the whole >> >>locator/formatter part of the docs. >> >> >> >>How can I make a locator that just places a tick at every multiple of >> >>0.5 around the data?  So the y axis would look like: >> >> >> >>3.5 -- >> >>3.0 -- >> >>2.5 -- >> >>2.0 -- >> >>1.5 -- >> >>1.0 -- >> > >> > Do you want something like: >> > >> >    ylim(1.0,3.5) >> >    yticks(arrange(1.0,4.0,0.5)) >> >> I'm not sure, because I can't try it out--I'm using the OO matplotlib, >> not Pyplot.  What's the equivalent of this in the OO API? > > >     ax.axis((xmin, xmax, ymin, ymax)) >     ax.yaxis.set_ticks(np.arange(1.0, 4.0, 0.5)) Thanks. But in order to use this, I have to know ymin and ymax, based on the data. But I thought this was the point of the locators--that they could assign the ticks based on the range of the data and then some rule about placement of ticks in that range. But when I look at the various kinds of locators in the docs, none have a parameter that is equivalent to the 0.5 above in set_ticks. Or do they and I just missed it? ```
 Re: [Matplotlib-users] simple question about locator every 0.5 From: Gökhan Sever - 2011-07-21 01:20:05 Attachments: Message as HTML ```On Wed, Jul 20, 2011 at 7:17 PM, C M wrote: > On Wed, Jul 20, 2011 at 7:56 PM, Gökhan Sever > wrote: > > > > > > On Wed, Jul 20, 2011 at 5:41 PM, C M wrote: > >> > >> On Wed, Jul 20, 2011 at 7:24 PM, Buchholz, Greg > >> wrote: > >> >>-----Original Message----- > >> >>From: C M [mailto:cmpython@...] > >> >> > >> >>Sorry, this is super-simple, but I'm lost in the whole > >> >>locator/formatter part of the docs. > >> >> > >> >>How can I make a locator that just places a tick at every multiple of > >> >>0.5 around the data? So the y axis would look like: > >> >> > >> >>3.5 -- > >> >>3.0 -- > >> >>2.5 -- > >> >>2.0 -- > >> >>1.5 -- > >> >>1.0 -- > >> > > >> > Do you want something like: > >> > > >> > ylim(1.0,3.5) > >> > yticks(arrange(1.0,4.0,0.5)) > >> > >> I'm not sure, because I can't try it out--I'm using the OO matplotlib, > >> not Pyplot. What's the equivalent of this in the OO API? > > > > > > ax.axis((xmin, xmax, ymin, ymax)) > > ax.yaxis.set_ticks(np.arange(1.0, 4.0, 0.5)) > > Thanks. > > But in order to use this, I have to know ymin and ymax, based on the > data. But I thought this was the point of the locators--that they > could assign the ticks based on the range of the data and then some > rule about placement of ticks in that range. But when I look at the > various kinds of locators in the docs, none have a parameter that is > equivalent to the 0.5 above in set_ticks. > > Or do they and I just missed it? > You can call min and max functions on your data arrays and make adjustments in your tick placement accordingly. -- Gökhan ```
 Re: [Matplotlib-users] simple question about locator every 0.5 From: Eric Firing - 2011-07-21 01:37:21 ```On 07/20/2011 03:17 PM, C M wrote: > On Wed, Jul 20, 2011 at 7:56 PM, Gökhan Sever wrote: >> >> >> On Wed, Jul 20, 2011 at 5:41 PM, C M wrote: >>> >>> On Wed, Jul 20, 2011 at 7:24 PM, Buchholz, Greg >>> wrote: >>>>> -----Original Message----- >>>>> From: C M [mailto:cmpython@...] >>>>> >>>>> Sorry, this is super-simple, but I'm lost in the whole >>>>> locator/formatter part of the docs. >>>>> >>>>> How can I make a locator that just places a tick at every multiple of >>>>> 0.5 around the data? So the y axis would look like: >>>>> >>>>> 3.5 -- >>>>> 3.0 -- >>>>> 2.5 -- >>>>> 2.0 -- >>>>> 1.5 -- >>>>> 1.0 -- >>>> >>>> Do you want something like: >>>> >>>> ylim(1.0,3.5) >>>> yticks(arrange(1.0,4.0,0.5)) >>> >>> I'm not sure, because I can't try it out--I'm using the OO matplotlib, >>> not Pyplot. What's the equivalent of this in the OO API? >> >> >> ax.axis((xmin, xmax, ymin, ymax)) >> ax.yaxis.set_ticks(np.arange(1.0, 4.0, 0.5)) > > Thanks. > > But in order to use this, I have to know ymin and ymax, based on the > data. But I thought this was the point of the locators--that they > could assign the ticks based on the range of the data and then some > rule about placement of ticks in that range. But when I look at the > various kinds of locators in the docs, none have a parameter that is > equivalent to the 0.5 above in set_ticks. > > Or do they and I just missed it? Try MultipleLocator: from matplotlib.ticker import MultipleLocator halflocator = MultipleLocator(base=0.5) ax.xaxis.set_major_locator(halflocator) etc. > > ------------------------------------------------------------------------------ > 5 Ways to Improve& Secure Unified Communications > Unified Communications promises greater efficiencies for business. UC can > improve internal communications as well as offer faster, more efficient ways > to interact with customers and streamline customer service. Learn more! > http://www.accelacomm.com/jaw/sfnl/114/51426253/ > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users@... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users ```
 Re: [Matplotlib-users] simple question about locator every 0.5 From: C M - 2011-07-21 03:34:04 ```> Try MultipleLocator: > > from matplotlib.ticker import MultipleLocator > halflocator = MultipleLocator(base=0.5) > ax.xaxis.set_major_locator(halflocator) > > etc. Thanks, that works for me. I didn't think I could use non-integers (0.5) because the docs said, "Set a tick on every integer that is multiple of base in the view interval". Earlier in that page, though, it does say base can be an integer or float. Che ```