I have a semilogx plot that I have zoomed into, so that there are no xticks visible. I can't seem to set the xticks to something that isn't an integer power of 10. I would actually prefer to set it to a number that isn't displayed as 10^xxx, but I don't know how. For example: y=3Dsin(2*pi*f) semilogx(f,y) xlim([1.5,2.5]) xticks([1.75,2.0]) show() has no xticks. How do I fix this? Thanks, Ryan
I'm a dork. help xticks told me the solution (imagine that) - RTFdocstring. make sure to include xticks([1.75,2.0],['1.75','2.0']) On 4/28/06, Ryan Krauss <rya...@gm...> wrote: > I have a semilogx plot that I have zoomed into, so that there are no > xticks visible. I can't seem to set the xticks to something that > isn't an integer power of 10. I would actually prefer to set it to a > number that isn't displayed as 10^xxx, but I don't know how. > > For example: > > y=3Dsin(2*pi*f) > semilogx(f,y) > xlim([1.5,2.5]) > xticks([1.75,2.0]) > show() > > has no xticks. > > How do I fix this? > > Thanks, > > Ryan >
>>>>> "Ryan" == Ryan Krauss <rya...@gm...> writes: Ryan> I'm a dork. help xticks told me the solution (imagine that) Ryan> - RTFdocstring. Ryan> make sure to include xticks([1.75,2.0],['1.75','2.0']) At first this example confused me, because normally xticks([1.75,2.0]) w/o the labels will do the right thing, ie put labels on 1.75 and 2.0. The reason it doesn't in your example is that you are using a semilogx plot, and thus the default formatter is ticker.LogFormatterMathtext , which only places labels on the decades. This may be considered a bug, wart, or minor annoyance. As you note, there is an easy workaround. Alternatively, it might be better to change the formatter when there is a call to set_ticks just as we currently change the locator def set_ticks(self, ticks): """ Set the locations of the tick marks from sequence ticks ACCEPTS: sequence of floats """ self.set_major_locator( FixedLocator(ticks) ) self.get_view_interval().update(ticks,0) return self.get_major_ticks() JDH