[Matplotlib-users] position of xtick labels

2012-04-27 Thread Nils Wagner
Hi all,

I would like to add different xtick labels on the top and 
bottom of a figure. The number and position of the xticks 
is the same.
How can I do that ?

An example would be appreciated.

Nils

--
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] position of xtick labels

2012-04-27 Thread Francesco Montesano
Dear Nils,

you can try to play with
i) ax.axis[right, top, bottom, left] and their methods (see
setup_axis3 here
http://matplotlib.sourceforge.net/examples/axes_grid/demo_floating_axes.html
for an example)
ii) twinx and twiny axes (example
http://matplotlib.sourceforge.net/examples/api/two_scales.html )

The first one can be a bit confusing with orientations. Once I found
an explanation about it on matplotlib website, but I cannot find it
right now.
The second way creates a second axis that you probably don't need.

Cheers,
Francesco

Il 27 aprile 2012 11:48, Nils Wagner nwag...@iam.uni-stuttgart.de ha scritto:
 Hi all,

 I would like to add different xtick labels on the top and
 bottom of a figure. The number and position of the xticks
 is the same.
 How can I do that ?

 An example would be appreciated.

 Nils

 --
 Live Security Virtual Conference
 Exclusive live event will cover all the ways today's security and
 threat landscape has changed and how IT managers can respond. Discussions
 will include endpoint security, mobile security and the latest in malware
 threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
 ___
 Matplotlib-users mailing list
 Matplotlib-users@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/matplotlib-users

--
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] position of xtick labels

2012-04-27 Thread Francesco Montesano
Dear Nils,

I think that I've found what you need (example adapted from
http://notes.brooks.nu/2008/03/plotting-on-left-and-right-axis-simulateously-using-matplotlib-and-numpy/
)

import matplotlib.pyplot as plt
import numpy as np

#data to plot
x = np.linspace(0,5,num=100)
y = np.sinc(x)

fig   = plt.figure(figsize=(16,10))  #figure
ax= fig.add_subplot(111)#axis containing the figure
ax1 = fig.add_subplot(111, sharex=ax, sharey=ax, frameon=False)
#axis that shares both x and y and without frame (so ax is visible)

ax.plot(x, y)   #plot the data

ax1.xaxis.tick_top()  #show ticks on top
ax1.yaxis.tick_right()  #show ticks on the right

Now if you do any modification on the ax limits should reflect on ax1.

Might be that there is some smarter way of doing it, but if the
project is not too long and efficiency is not a problem, I think that
this example will suffice

Cheers,
Francesco

Il 27 aprile 2012 14:50, Nils Wagner nils...@googlemail.com ha scritto:
 Dear Francesco,

 Thank you for your prompt reply !
 My incomplete example is below.

 import matplotlib.pyplot as plt
 fig   = plt.figure(figsize=(16,10))
 ax    = fig.add_subplot(111)
 ind = np.arange(nfreq)
 yoff = np.array([0.0]*nfreq)
 for row in range(nsets):

    ax.bar(ind,A[row,:],width,bottom=yoff, 
 color=colours[row],label=elabel[row])
    yoff = yoff + A[row,:]

 plt.legend(loc=upper left, bbox_to_anchor=(1,1))
 plt.xticks(ind+0.5*width,np.arange(nfreq)+1,rotation=90)
 ax.set_xlim(0.,nfreq)
 ax.set_ylim(0.,102.)
 plt.subplots_adjust(left=0.075, right=0.85, top=0.9, bottom=0.05)
 plt.show()

 How can I add xtick labels on the top of my figure ?

 Cheers,
               Nils


 On 4/27/12, Francesco Montesano franz.berges...@googlemail.com wrote:
 Dear Nils,

 you can try to play with
 i) ax.axis[right, top, bottom, left] and their methods (see
 setup_axis3 here
 http://matplotlib.sourceforge.net/examples/axes_grid/demo_floating_axes.html
 for an example)
 ii) twinx and twiny axes (example
 http://matplotlib.sourceforge.net/examples/api/two_scales.html )

 The first one can be a bit confusing with orientations. Once I found
 an explanation about it on matplotlib website, but I cannot find it
 right now.
 The second way creates a second axis that you probably don't need.

 Cheers,
 Francesco

 Il 27 aprile 2012 11:48, Nils Wagner nwag...@iam.uni-stuttgart.de ha
 scritto:
 Hi all,

 I would like to add different xtick labels on the top and
 bottom of a figure. The number and position of the xticks
 is the same.
 How can I do that ?

 An example would be appreciated.

 Nils

 --
 Live Security Virtual Conference
 Exclusive live event will cover all the ways today's security and
 threat landscape has changed and how IT managers can respond. Discussions
 will include endpoint security, mobile security and the latest in malware
 threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
 ___
 Matplotlib-users mailing list
 Matplotlib-users@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/matplotlib-users




-- 
personals: monty...@yahoo.it, monte_...@hotmail.com (messenger),
franz.berges...@googlemail.com.
work: monte...@mpe.mpg.de

http://picasaweb.google.it/franz.bergesund

--
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users