Re: [Matplotlib-users] axis on top for barh plot

2009-11-29 Thread Mike Anderson
Hi!

 How can I put the bottom axis on top (or on top AND on bottom) for a barh 
 plot?

 It's somewhat counter-intuitive, but it can be done.
 You have to create some twin axes with the twiny option,
 then make the plot on the twin axes so it will use the
 top axis. The bottom axis still have to be adjusted manually
 to make it match the top one and remove the labels.
 
 See this example:
 

Thanks for your example.  With your help I was able to finally create this with 
matplotlib,
  http://www.hep.wisc.edu/cms/comp/cmsprod/diskUserUsage.png
and this is my final script,
  http://www.hep.wisc.edu/cms/comp/cmsprod/plotDiskUse.py



One thing that surprised me was to shrink the font for the names required 
changing ax1 even though the barh plot is on ax2.  See these lines:

--
  ax2.barh(pos, listUse, color=listColors, height=1.0, align='center')
 ...
  for tick in ax1.yaxis.get_major_ticks():
tick.label1.set_fontsize(8)
--

Surprising.
Mike

--
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] axis on top for barh plot

2009-11-28 Thread Ernest Adrogué
28/11/09 @ 00:17 (+0100), thus spake Mike Anderson:
 Hi,
 
 How can I put the bottom axis on top (or on top AND on bottom) for a barh 
 plot?
 
 I'm trying to mimic this, made with gnuplot:
 
   http://www.hep.wisc.edu/cms/comp/cmsprod/dCacheUserUsage.png
 
 within matplotlib, and I've come close,
 
   http://www.hep.wisc.edu/cms/comp/cmsprod/diskUserUsage.png
 
 
 Also, is it possible to just have grid lines in one direction (say, 
 vertical), I don't think the horizontal grid is necessary.

It's somewhat counter-intuitive, but it can be done.
You have to create some twin axes with the twiny option,
then make the plot on the twin axes so it will use the
top axis. The bottom axis still have to be adjusted manually
to make it match the top one and remove the labels.

See this example:

import matplotlib.pyplot as plt
import matplotlib.ticker as ticker

data = [21, 17, 18, 15, 14, 11, 9, 8, 4, 6, 7, 4, 5, 1, 3, 2, 0, 0]
names = ['%s%s' % (a, b)
 for a in 'abcdefg' for b in 'abcdefg'][:len(data)]

xlim = (0, max(data)+2)

fig = plt.figure()
ax1 = fig.add_subplot(1,1,1)
ax2 = ax1.twiny()

# actual plot
ax2.barh(range(len(data)), data[::-1], 1, align='center', color='red')

# x-axis
ax2.set_xlim(xlim)
ax1.set_xlim(xlim)
ax1.xaxis.set_major_formatter(ticker.NullFormatter())

# y-axis
ax2.set_ylim(-0.5, len(data)-1+0.5)
ax2.yaxis.set_major_locator(ticker.FixedLocator(range(len(data
ax2.yaxis.set_major_formatter(ticker.FixedFormatter(names[::-1]))

# grid
ax2.set_axisbelow(True)
ax1.set_axisbelow(True)
ax1.grid(True)

plt.show()


If you want only a vertical grid, use
ax1.xaxis.grid(True) instead of ax1.grid(True).

Bye.

--
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] axis on top for barh plot

2009-11-27 Thread Mike Anderson
Hi,

How can I put the bottom axis on top (or on top AND on bottom) for a barh plot?

I'm trying to mimic this, made with gnuplot:

  http://www.hep.wisc.edu/cms/comp/cmsprod/dCacheUserUsage.png

within matplotlib, and I've come close,

  http://www.hep.wisc.edu/cms/comp/cmsprod/diskUserUsage.png


Also, is it possible to just have grid lines in one direction (say, vertical), 
I don't think the horizontal grid is necessary.

Thanks for any help,
Mike



PS: Anyone who is interested, my script for making that is here,
  http://www.hep.wisc.edu/cms/comp/cmsprod/plotDiskUse.py

--
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] axis on top for barh plot

2009-11-27 Thread Gökhan Sever
On Fri, Nov 27, 2009 at 5:17 PM, Mike Anderson mbander...@wisc.edu wrote:

 Hi,

 How can I put the bottom axis on top (or on top AND on bottom) for a barh
 plot?

 I'm trying to mimic this, made with gnuplot:

  http://www.hep.wisc.edu/cms/comp/cmsprod/dCacheUserUsage.png

 within matplotlib, and I've come close,

  http://www.hep.wisc.edu/cms/comp/cmsprod/diskUserUsage.png


 Also, is it possible to just have grid lines in one direction (say,
 vertical), I don't think the horizontal grid is necessary.

 Thanks for any help,
 Mike


This example might work for your case:

http://matplotlib.sourceforge.net/examples/axes_grid/simple_axisline4.html?highlight=subplothost

You can disable lower x-axis ticks and labels by using --assuming you will
try the example in an ipython -pylab

run simple_axisline4.py

ax = gca()

ax.xaxis.set_major_locator(pylab.NullLocator())

However this disable vertical grids as well. Maybe someone else can point
you in the right direction for this.






 PS: Anyone who is interested, my script for making that is here,
  http://www.hep.wisc.edu/cms/comp/cmsprod/plotDiskUse.py


 --
 Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
 trial. Simplify your report design, integration and deployment - and focus
 on
 what you do best, core application coding. Discover what's new with
 Crystal Reports now.  http://p.sf.net/sfu/bobj-july
 ___
 Matplotlib-users mailing list
 Matplotlib-users@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/matplotlib-users




-- 
Gökhan
--
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users