Discussion:
[Matplotlib-users] custom x axis integers boxplot
pb89
2015-06-12 22:10:09 UTC
Permalink
hi guys,

i guess thats an easy one for you:

fig=plt.figure()
rect=fig.patch
rect.set_facecolor('white')
ax1=fig.add_subplot(111)
bp=boxplot(array)

xlabel('case ID')
ylabel('registration time, sec')
show()

whereas array is a list of lists with 25 entries.

i want to have the axis not from 0 to 25 but from 11 to 36. How can i do
that?

thanks
peter




--
View this message in context: http://matplotlib.1069221.n5.nabble.com/custom-x-axis-integers-boxplot-tp45769.html
Sent from the matplotlib - users mailing list archive at Nabble.com.

------------------------------------------------------------------------------
Jeff Blackburne
2015-06-12 23:14:22 UTC
Permalink
Try adding these lines before your call to plt.show():

locs, labels = plt.xticks()
plt.xticks(locs, np.arange(11, 36))
Post by pb89
hi guys,
fig=plt.figure()
rect=fig.patch
rect.set_facecolor('white')
ax1=fig.add_subplot(111)
bp=boxplot(array)
xlabel('case ID')
ylabel('registration time, sec')
show()
whereas array is a list of lists with 25 entries.
i want to have the axis not from 0 to 25 but from 11 to 36. How can i do
that?
thanks
peter
--
http://matplotlib.1069221.n5.nabble.com/custom-x-axis-integers-boxplot-tp45769.html
Sent from the matplotlib - users mailing list archive at Nabble.com.
------------------------------------------------------------------------------
_______________________________________________
Matplotlib-users mailing list
https://lists.sourceforge.net/lists/listinfo/matplotlib-users
pb89
2015-06-12 23:36:37 UTC
Permalink
thanks for the quick answer Jeffrey, its working!

-peter



--
View this message in context: http://matplotlib.1069221.n5.nabble.com/custom-x-axis-integers-boxplot-tp45769p45771.html
Sent from the matplotlib - users mailing list archive at Nabble.com.

------------------------------------------------------------------------------
Paul Hobson
2015-06-13 14:46:19 UTC
Permalink
Probably a better way would be to the the "pos" arguments to boxplot
(bp=boxplot(array,
pos=range(11, 36)). That *should* work. Let me know if it doesn't.
Post by pb89
thanks for the quick answer Jeffrey, its working!
-peter
--
http://matplotlib.1069221.n5.nabble.com/custom-x-axis-integers-boxplot-tp45769p45771.html
Sent from the matplotlib - users mailing list archive at Nabble.com.
------------------------------------------------------------------------------
_______________________________________________
Matplotlib-users mailing list
https://lists.sourceforge.net/lists/listinfo/matplotlib-users
pb89
2015-06-13 14:49:27 UTC
Permalink
it tried this before, but it throws an exception:

TypeError: boxplot() got an unexpected keyword argument 'pos'





--
View this message in context: http://matplotlib.1069221.n5.nabble.com/custom-x-axis-integers-boxplot-tp45769p45774.html
Sent from the matplotlib - users mailing list archive at Nabble.com.

------------------------------------------------------------------------------
Paul Hobson
2015-06-13 14:58:49 UTC
Permalink
Oh sorry that should be "... positions=np.arange(11, 36))
Post by pb89
TypeError: boxplot() got an unexpected keyword argument 'pos'
--
http://matplotlib.1069221.n5.nabble.com/custom-x-axis-integers-boxplot-tp45769p45774.html
Sent from the matplotlib - users mailing list archive at Nabble.com.
------------------------------------------------------------------------------
_______________________________________________
Matplotlib-users mailing list
https://lists.sourceforge.net/lists/listinfo/matplotlib-users
pb89
2015-06-13 15:03:43 UTC
Permalink
yes, that works as well! thanks for your suggestion



--
View this message in context: http://matplotlib.1069221.n5.nabble.com/custom-x-axis-integers-boxplot-tp45769p45776.html
Sent from the matplotlib - users mailing list archive at Nabble.com.

------------------------------------------------------------------------------
pb89
2015-06-16 01:16:39 UTC
Permalink
hey guys, is it also possible to only show every 5th number of that array?
Its a little too much right now:
<Loading Image...>



--
View this message in context: http://matplotlib.1069221.n5.nabble.com/custom-x-axis-integers-boxplot-tp45769p45784.html
Sent from the matplotlib - users mailing list archive at Nabble.com.

------------------------------------------------------------------------------
Paul Hobson
2015-06-16 15:52:39 UTC
Permalink
You want to use a MultipleLocator:
http://matplotlib.org/examples/pylab_examples/major_minor_demo1.html

-paul
Post by pb89
hey guys, is it also possible to only show every 5th number of that array?
<
http://matplotlib.1069221.n5.nabble.com/file/n45784/computationTime_slicer4_final.png
--
http://matplotlib.1069221.n5.nabble.com/custom-x-axis-integers-boxplot-tp45769p45784.html
Sent from the matplotlib - users mailing list archive at Nabble.com.
------------------------------------------------------------------------------
_______________________________________________
Matplotlib-users mailing list
https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Loading...