SourceForge logo
SourceForge logo
Menu

matplotlib-users

From: Ryan K. <rya...@gm...> - 2006年04月28日 22:32:54
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
From: Ryan K. <rya...@gm...> - 2006年04月28日 22:35:25
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
>
From: John H. <jdh...@ac...> - 2006年04月29日 15:17:33
>>>>> "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
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.
Thanks for helping keep SourceForge clean.
X





Briefly describe the problem (required):
Upload screenshot of ad (required):
Select a file, or drag & drop file here.
Screenshot instructions:

Click URL instructions:
Right-click on the ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)

More information about our ad policies

Ad destination/click URL:

AltStyle によって変換されたページ (->オリジナル) /