Re: [Matplotlib-users] sensible tick labels for log scale?
On Jan 12, 2011, at 10:33 PM, Paul Ivanov wrote: In [50]: plt.loglog(1,1) Out[50]: [matplotlib.lines.Line2D object at 0x108dde4c] In [51]: ax = plt.gca() In [52]: loc = ax.xaxis.get_major_locator() In [53]: loc.numticks Out[53]: 15 In [54]: loc.numticks = 10 Also, this approach does not seem to work in general for me. As an example: In [49]: loglog([1.341, 0.1034, 0.6076, 1.4278, 0.0374], : [0.37, 0.12, 0.22, 0.4, 0.08], 'o') In [50]: loc = ax.xaxis.get_minor_locator() In [51]: loc.numticks=10 In [52]: loc.numticks=5 This does nothing to change the number of minor ticks, and I tried the same thing for get_major_locator(), with the same result. The plot does not change at all. Thanks, cf -- Protect Your Site and Customers from Malware Attacks Learn about various malware tactics and how to avoid them. Understand malware threats, the impact they can have on your business, and how you can protect your company and customers by using code signing. http://p.sf.net/sfu/oracle-sfdevnl ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] sensible tick labels for log scale (rephrased)
Chris Fonnesbeck, on 2011-01-13 14:07, wrote: I was hoping (and still hope) that Matplotlib is able to choose reasonable ticks on the log scale that do not overlap, but are more informative than just powers of 10. Chris, Sorry, I'm no expert with the locators, I rarely find myself needing to mess with them. The cleaner way to get something other than decades is to specify basex and basey. To do this for a plot already created, you'll need to set the base of the LogLocator and LogFormatter of your minor and major axes, like: fmat = plt.gca().xaxis.get_major_formatter() fmat.base(2) loc = plt.gca().xaxis.get_major_locator() loc.base(2) I'm afraid I'm quite out of my element with these guys, maybe someone else chimes in with another approach. Do post again to clarify what you want. Note that by default, the minor_formatter is set to be a NullFormatter, thus no labels will be placed at the minor tick locations. That would be a reasonable way to proceed - set the major ticks to be non-overlapping, and put the minor ones everywhere else. You've probably already found it, but just in case: http://matplotlib.sourceforge.net/api/ticker_api.html -- Paul Ivanov 314 address only used for lists, off-list direct email at: http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7 signature.asc Description: Digital signature -- Protect Your Site and Customers from Malware Attacks Learn about various malware tactics and how to avoid them. Understand malware threats, the impact they can have on your business, and how you can protect your company and customers by using code signing. http://p.sf.net/sfu/oracle-sfdevnl___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] sensible tick labels for log scale?
I'm wondering if there is a way of automating tick labeling on log-scale axes, so that labels do not overlap. Specifically, when the values get large, they overlap which makes the labels unreadable. I would expect them to automatically get more sparse with the axis value, as they do when you generate such plots in R, for example. Thanks in advance, cf -- Protect Your Site and Customers from Malware Attacks Learn about various malware tactics and how to avoid them. Understand malware threats, the impact they can have on your business, and how you can protect your company and customers by using code signing. http://p.sf.net/sfu/oracle-sfdevnl ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] sensible tick labels for log scale?
Christopher Fonnesbeck, on 2011-01-12 20:12, wrote: I'm wondering if there is a way of automating tick labeling on log-scale axes, so that labels do not overlap. Specifically, when the values get large, they overlap which makes the labels unreadable. I would expect them to automatically get more sparse with the axis value, as they do when you generate such plots in R, for example. Hi Christopher, can you provide a small code example that demonstrates the problem you're having? The ticks get placed by a ticklocator. You can change the number of ticks that get placed by setting the appropriate locators numticks parameter. In [50]: plt.loglog(1,1) Out[50]: [matplotlib.lines.Line2D object at 0x108dde4c] In [51]: ax = plt.gca() In [52]: loc = ax.xaxis.get_major_locator() In [53]: loc.numticks Out[53]: 15 In [54]: loc.numticks = 10 IIRC, the variable name changes slightly from locator to locator, but you can quickly figure it out in ipython using tab completion in IPython once you grab a given locator object. best, -- Paul Ivanov 314 address only used for lists, off-list direct email at: http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7 signature.asc Description: Digital signature -- Protect Your Site and Customers from Malware Attacks Learn about various malware tactics and how to avoid them. Understand malware threats, the impact they can have on your business, and how you can protect your company and customers by using code signing. http://p.sf.net/sfu/oracle-sfdevnl___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users