From: Ryan K. <rya...@gm...> - 2006-04-13 15:50:35
Attachments:
tickmarks.png
|
My love of large fonts is causing a problem. If you look at the attached figure, I typically have x and y tick marks that nearly collide in the lower left hand corner of each subplot. I typically end up setting the yticks by hand, but this isn't super convienent for each plot. I am about to right a function to drop the lowest ytick label, but is there a better approach? Thanks, Ryan |
From: John H. <jdh...@ac...> - 2006-04-13 16:10:57
|
>>>>> "Ryan" == Ryan Krauss <rya...@gm...> writes: Ryan> My love of large fonts is causing a problem. If you look at Ryan> the attached figure, I typically have x and y tick marks Ryan> that nearly collide in the lower left hand corner of each Ryan> subplot. I typically end up setting the yticks by hand, but Ryan> this isn't super convienent for each plot. I am about to Ryan> right a function to drop the lowest ytick label, but is Ryan> there a better approach? Increase the xtick.major.pad and/or ytick.major.pad rc settings by a couple of points. Alternatively, if you do want to drop the leftmost xtick label, for instance, you can easily derive a custom formatter. Here you are using the LogFormatterMathtext from matplotlib.ticker import LogFormatterMathtext class MyFormatter(LogFormatterMathtext): def __call__(self, x, pos=None): if pos==0: return '' # pos=0 is the first tick else: return LogFormatterMathtext(self, x, pos) ax.xaxis.set_major_formatter(MyFormatter()) Nice looking figure! JDH |
From: Ryan K. <rya...@gm...> - 2006-04-13 18:25:05
|
The new formatter works pretty well. One change though, the last line should be: else: return LogFormatterMathtext.__call__(self, x, pos) Thanks, John On 4/13/06, John Hunter <jdh...@ac...> wrote: > >>>>> "Ryan" =3D=3D Ryan Krauss <rya...@gm...> writes: > > Ryan> My love of large fonts is causing a problem. If you look at > Ryan> the attached figure, I typically have x and y tick marks > Ryan> that nearly collide in the lower left hand corner of each > Ryan> subplot. I typically end up setting the yticks by hand, but > Ryan> this isn't super convienent for each plot. I am about to > Ryan> right a function to drop the lowest ytick label, but is > Ryan> there a better approach? > > Increase the xtick.major.pad and/or ytick.major.pad rc settings by a > couple of points. > > Alternatively, if you do want to drop the leftmost xtick label, for > instance, you can easily derive a custom formatter. Here you are using > the LogFormatterMathtext > > from matplotlib.ticker import LogFormatterMathtext > > class MyFormatter(LogFormatterMathtext): > def __call__(self, x, pos=3DNone): > if pos=3D=3D0: return '' # pos=3D0 is the first tick > else: return LogFormatterMathtext(self, x, pos) > > ax.xaxis.set_major_formatter(MyFormatter()) > > Nice looking figure! > JDH > |
From: Malte M. <Mal...@cs...> - 2006-04-18 03:30:34
|
Hi, I have a related question. How do I change the (font)size of the ticklabels, without having to step through them? I have "ganged" plots and am scaling fonts by a factor depending on nrows and ncolumns. I also need this for the size of the legend "labels" Cheers, Malte On Friday 14 April 2006 04:25, Ryan Krauss wrote: > The new formatter works pretty well. One change though, the last line > should be: > > else: return LogFormatterMathtext.__call__(self, x, pos) > > Thanks, > > John > > On 4/13/06, John Hunter <jdh...@ac...> wrote: > > >>>>> "Ryan" == Ryan Krauss <rya...@gm...> writes: > > > > Ryan> My love of large fonts is causing a problem. If you look at > > Ryan> the attached figure, I typically have x and y tick marks > > Ryan> that nearly collide in the lower left hand corner of each > > Ryan> subplot. I typically end up setting the yticks by hand, but > > Ryan> this isn't super convienent for each plot. I am about to > > Ryan> right a function to drop the lowest ytick label, but is > > Ryan> there a better approach? > > > > Increase the xtick.major.pad and/or ytick.major.pad rc settings by a > > couple of points. > > > > Alternatively, if you do want to drop the leftmost xtick label, for > > instance, you can easily derive a custom formatter. Here you are using > > the LogFormatterMathtext > > > > from matplotlib.ticker import LogFormatterMathtext > > > > class MyFormatter(LogFormatterMathtext): > > def __call__(self, x, pos=None): > > if pos==0: return '' # pos=0 is the first tick > > else: return LogFormatterMathtext(self, x, pos) > > > > ax.xaxis.set_major_formatter(MyFormatter()) > > > > Nice looking figure! > > JDH > |
From: John H. <jdh...@ac...> - 2006-04-18 03:52:23
|
>>>>> "Malte" == Malte Marquarding <Mal...@cs...> writes: Malte> Hi, I have a related question. How do I change the Malte> (font)size of the ticklabels, without having to step Malte> through them? What is wrong with stepping through them? JDH |
From: Malte M. <Mal...@cs...> - 2006-04-18 04:08:06
|
Laziness ;-) Thanks, I just needed to know if there is something I might have overlooked. I just couldn't think of a case where you would want to change the tick label size on an individual basis, so I thought there would be a method in "axes.xaxis/axes.yaxis" to do this to the whole list. Is this something which could be added to the Formatter classes, or maybe a Styler Class to change Font properties and colors. Cheers, Malte. On Tuesday 18 April 2006 13:48, you wrote: > >>>>> "Malte" == Malte Marquarding <Mal...@cs...> writes: > > Malte> Hi, I have a related question. How do I change the > Malte> (font)size of the ticklabels, without having to step > Malte> through them? > > What is wrong with stepping through them? > > JDH |
From: John H. <jdh...@ac...> - 2006-04-18 11:32:33
|
>>>>> "Malte" == Malte Marquarding <Mal...@cs...> writes: Malte> Laziness ;-) Thanks, I just needed to know if there is Malte> something I might have overlooked. I just couldn't think Malte> of a case where you would want to change the tick label Malte> size on an individual basis, so I thought there would be a Malte> method in "axes.xaxis/axes.yaxis" to do this to the whole Malte> list. Malte> Is this something which could be added to the Formatter Malte> classes, or maybe a Styler Class to change Font properties Malte> and colors. You can change the default tick label size by setting an rc configuration parameter -- http://matplotlib.sf.net/matplotlibrc. See the properties xtick.major.size : 4 # major tick size in points xtick.minor.size : 2 # minor tick size in points xtick.major.pad : 4 # distance to major tick label in points xtick.minor.pad : 4 # distance to the minor tick label in points xtick.color : k # color of the tick labels xtick.labelsize : 12 # fontsize of the tick labels xtick.direction : in # direction: in or out and ditto for yaxis. Also, if you like to save typing, you can use the setp functionality to set multiple properties for multiple objects w/o changing the defaults setp(ax.get_xticklabels(), fontsize=12, color='red') JDH |