Hi All,
I am trying to modify tick sizes and labels. Reading documents and examples, I have found an easy way to modify the labels,
import matplotlib.pyplot as plt
ax = plt.axes()
font_size = 24
plt.setp(ax.get_xticklabels(),fontsize=font_size)
but I am struggling to find such a nice solution for the tick size. I would like to change the size of the major and minor ticks independently. But the best I have come up with so far is a brute force double loop (I tried calling "major=False" but "major" is not a recognized kwarg)
for tick in ax.xaxis.get_ticklines(minor=True):
tick.set_markersize(5)
for tick in ax.xaxis.get_ticklines(minor=False):
tick.set_markersize(10)
I assume there is some nice solution like for the tick labels, but I have not found it.
Anyone figured this one out yet?
Thanks,
Andre
Hi Andre,
You should be able to set the size with the following:
params = {‘length’: 10}
axis = plt.axes().xaxis
axis.set_tick_params(which=‘major’, **params)
You can also use ‘minor’ instead of ‘major’ to set the minor ticks. There are a number of different valid values for the params dict, including direction, width, and color.
Ben
···
On Thu, Jul 28, 2011 at 2:22 PM, Andre’ Walker-Loud <walksloud@…287…> wrote:
Hi All,
I am trying to modify tick sizes and labels. Reading documents and examples, I have found an easy way to modify the labels,
import matplotlib.pyplot as plt
ax = plt.axes()
font_size = 24
plt.setp(ax.get_xticklabels(),fontsize=font_size)
but I am struggling to find such a nice solution for the tick size. I would like to change the size of the major and minor ticks independently. But the best I have come up with so far is a brute force double loop (I tried calling “major=False” but “major” is not a recognized kwarg)
for tick in ax.xaxis.get_ticklines(minor=True):
tick.set_markersize(5)
for tick in ax.xaxis.get_ticklines(minor=False):
tick.set_markersize(10)
I assume there is some nice solution like for the tick labels, but I have not found it.
Anyone figured this one out yet?
Thanks,
Andre
Got Input? Slashdot Needs You.
Take our quick survey online. Come on, we don’t ask for help often.
Plus, you’ll get a chance to win $100 to spend on ThinkGeek.
http://p.sf.net/sfu/slashdot-survey
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Hi Ben,
Would you expect this to work on Matplotlib 0.99.3?
I get the following error
AttributeError: ‘XAxis’ object has no attribute ‘set_tick_params’
Thanks,
Andre
···
On Jul 28, 2011, at 12:18 PM, Ben Breslauer wrote:
Hi Andre,
You should be able to set the size with the following:
params = {‘length’: 10}
axis = plt.axes().xaxis
axis.set_tick_params(which=‘major’, **params)
You can also use ‘minor’ instead of ‘major’ to set the minor ticks. There are a number of different valid values for the params dict, including direction, width, and color.
Ben
On Thu, Jul 28, 2011 at 2:22 PM, Andre’ Walker-Loud <walksloud@…287…> wrote:
Hi All,
I am trying to modify tick sizes and labels. Reading documents and examples, I have found an easy way to modify the labels,
import matplotlib.pyplot as plt
ax = plt.axes()
font_size = 24
plt.setp(ax.get_xticklabels(),fontsize=font_size)
but I am struggling to find such a nice solution for the tick size. I would like to change the size of the major and minor ticks independently. But the best I have come up with so far is a brute force double loop (I tried calling “major=False” but “major” is not a recognized kwarg)
for tick in ax.xaxis.get_ticklines(minor=True):
tick.set_markersize(5)
for tick in ax.xaxis.get_ticklines(minor=False):
tick.set_markersize(10)
I assume there is some nice solution like for the tick labels, but I have not found it.
Anyone figured this one out yet?
Thanks,
Andre
Got Input? Slashdot Needs You.
Take our quick survey online. Come on, we don’t ask for help often.
Plus, you’ll get a chance to win $100 to spend on ThinkGeek.
http://p.sf.net/sfu/slashdot-survey
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Hmm, no, it looks like the tick_params were added in 1.0. I can also get it to work using
plt.setp(ax.xaxis.get_ticklines(minor=False), markersize=10)
but I’m using matplotlib 1.0.1. I’m not sure if neither of those solutions work.
Ben
···
On Thu, Jul 28, 2011 at 3:30 PM, Andre’ Walker-Loud <walksloud@…287…> wrote:
Hi Ben,
Would you expect this to work on Matplotlib 0.99.3?
I get the following error
AttributeError: ‘XAxis’ object has no attribute ‘set_tick_params’
Thanks,
Andre
On Jul 28, 2011, at 12:18 PM, Ben Breslauer wrote:
Hi Andre,
You should be able to set the size with the following:
params = {‘length’: 10}
axis = plt.axes().xaxis
axis.set_tick_params(which=‘major’, **params)
You can also use ‘minor’ instead of ‘major’ to set the minor ticks. There are a number of different valid values for the params dict, including direction, width, and color.
Ben
On Thu, Jul 28, 2011 at 2:22 PM, Andre’ Walker-Loud <walksloud@…287…> wrote:
Hi All,
I am trying to modify tick sizes and labels. Reading documents and examples, I have found an easy way to modify the labels,
import matplotlib.pyplot as plt
ax = plt.axes()
font_size = 24
plt.setp(ax.get_xticklabels(),fontsize=font_size)
but I am struggling to find such a nice solution for the tick size. I would like to change the size of the major and minor ticks independently. But the best I have come up with so far is a brute force double loop (I tried calling “major=False” but “major” is not a recognized kwarg)
for tick in ax.xaxis.get_ticklines(minor=True):
tick.set_markersize(5)
for tick in ax.xaxis.get_ticklines(minor=False):
tick.set_markersize(10)
I assume there is some nice solution like for the tick labels, but I have not found it.
Anyone figured this one out yet?
Thanks,
Andre
Got Input? Slashdot Needs You.
Take our quick survey online. Come on, we don’t ask for help often.
Plus, you’ll get a chance to win $100 to spend on ThinkGeek.
http://p.sf.net/sfu/slashdot-survey
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users
well I knew there was a better solution, thanks.
I guess I’ll just have to upgrade my installation.
Andre
···
On Jul 28, 2011, at 12:44 PM, Ben Breslauer wrote:
Hmm, no, it looks like the tick_params were added in 1.0. I can also get it to work using
plt.setp(ax.xaxis.get_ticklines(minor=False), markersize=10)
but I’m using matplotlib 1.0.1. I’m not sure if neither of those solutions work.
Ben
On Thu, Jul 28, 2011 at 3:30 PM, Andre’ Walker-Loud <walksloud@…287…> wrote:
Hi Ben,
Would you expect this to work on Matplotlib 0.99.3?
I get the following error
AttributeError: ‘XAxis’ object has no attribute ‘set_tick_params’
Thanks,
Andre
On Jul 28, 2011, at 12:18 PM, Ben Breslauer wrote:
Hi Andre,
You should be able to set the size with the following:
params = {‘length’: 10}
axis = plt.axes().xaxis
axis.set_tick_params(which=‘major’, **params)
You can also use ‘minor’ instead of ‘major’ to set the minor ticks. There are a number of different valid values for the params dict, including direction, width, and color.
Ben
On Thu, Jul 28, 2011 at 2:22 PM, Andre’ Walker-Loud <walksloud@…287…> wrote:
Hi All,
I am trying to modify tick sizes and labels. Reading documents and examples, I have found an easy way to modify the labels,
import matplotlib.pyplot as plt
ax = plt.axes()
font_size = 24
plt.setp(ax.get_xticklabels(),fontsize=font_size)
but I am struggling to find such a nice solution for the tick size. I would like to change the size of the major and minor ticks independently. But the best I have come up with so far is a brute force double loop (I tried calling “major=False” but “major” is not a recognized kwarg)
for tick in ax.xaxis.get_ticklines(minor=True):
tick.set_markersize(5)
for tick in ax.xaxis.get_ticklines(minor=False):
tick.set_markersize(10)
I assume there is some nice solution like for the tick labels, but I have not found it.
Anyone figured this one out yet?
Thanks,
Andre
Got Input? Slashdot Needs You.
Take our quick survey online. Come on, we don’t ask for help often.
Plus, you’ll get a chance to win $100 to spend on ThinkGeek.
http://p.sf.net/sfu/slashdot-survey
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users