[Matplotlib-users] AXES properties

2010-01-31 Thread kc106_2005-matplotlib
BTW: I tried to use set_position to change the position of the axes label as 
suggested by previous posting.  No effect.  

- Original Message 
  Hello,
  
  I am creating a plot with multiple y-axis (up to 6) and twinx 
 works pretty well. The problem is that there are too much wasted spaces used 
 up 
 by the axes. Since I have multiple axes, it cuts into the amount of space 
 available for the plot area. I need to know how I can squeeze some spaces out 
 of 
 the standard axes. First thing I discovered was that I can rotate the tick 
 labels to vertical by:
  
  plt.setp(ax.major_ticklabels, rotation=vertical)
  
  where ax is my y-axis. But then:
  
  (1) How to reduce the space between the tick and the axes label?
  
  First I tried to place the label on top but couldn't get that to work. Then 
  I 
 tried to change the position property of the axis label object and that have 
 no 
 effect. So, can somebody please tell me how I can do these 2 things?
  
  (2) How to avoid overlapping tick labels?
  
  With the way the standard x and y axis are drawn, after I do a vertical 
  rotate 
 of the y tick labels, the first y tick label overlaps with the last x tick 
 label 
 since they are both center aligned. Is there any way to change the alignment 
 of 
 only the first and last tick labels of an axes (while keeping the rest center 
 aligned)?
  
  Thanks,
  
 
 

 --
John Henry


--
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] how to add text below the legend

2010-01-31 Thread Ernest Adrogué
Hi,

I would like to add some text relative to the legend,
let's say below it, and I don't know how to get the legend
coordinates so I can pass them to the text() method.

Does anyone know how to do it?

Alternatively, if there was a way to add text inside the
legend itself, it would also do the trick.

Thank you in advance.

Ernest


--
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Problem formatting a 'step' histogram with a log scale and empty bins.

2010-01-31 Thread b9o2jnbm tsd71eam
Hi!

I want to create a histogram with the step scale and I am finding
an inconstancy when using a log scale. I have a very simple example without
a log scale which works just as expected creating alternating bins with
value one and value zero.

from pylab import *
hist([0.5,2.5,4.5],bins=[0,1,2,3,4,5,6],histtype='step',log=False)
ylim(0.1,1.1)
show()

When I change the keyword log=False to log=True, the line connecting the
bins with value one to the bins with value zero disappear. Is there any way
I can get them to reaper? Is this a bug that should be fixed or is there a
workaround?

Thanks!
attachment: log.pngattachment: regular.png--
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Problem formatting a 'step' histogram with a log scale and empty bins.

2010-01-31 Thread Eric Firing
b9o2jnbm tsd71eam wrote:
 Hi!
 
 I want to create a histogram with the step scale and I am finding 
 an inconstancy when using a log scale. I have a very simple example 
 without a log scale which works just as expected creating alternating 
 bins with value one and value zero.
 
 from pylab import *
 hist([0.5,2.5,4.5],bins=[0,1,2,3,4,5,6],histtype='step',log=False)
 ylim(0.1,1.1)
 show()
 
 When I change the keyword log=False to log=True, the line connecting the 
 bins with value one to the bins with value zero disappear. Is there any 
 way I can get them to reaper? Is this a bug that should be fixed or is 
 there a workaround?

It works for me using svn, and the problem sounds familiar, so I think 
this is a bug that was fixed.

Eric


--
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Values returned by axis() do not match the actual axis in the plot window

2010-01-31 Thread photonicsphan

Hello,

I have matplotlib widget set up in a PyQt 4 program.  The axis is set for
auto scaling.  I'm using the following command to determine the upper y
boundary:

self.plotWidget.canvas.ax.axis()[3]

where plotWidget is the name of the widget in my program.  I get a number
from this command just fine, but it doesn't always agree with the actual
axis on the plot window.  For instance, after plotting a curve with a
maximum y-value of 0.125, the command above gives me an upper y-limit of
0.14.  However, the plot window goes up to y=0.16.  Sometimes things work
out correctly, but they call above and the plot window do not typically
agree.  

I really need the plot window to match what comes from this call to axis(). 
Can anyone offer any suggestions on what might be going wrong?

Thanks,
Steve
-- 
View this message in context: 
http://old.nabble.com/Values-returned-by-axis%28%29-do-not-match-the-actual-axis-in-the-plot-window-tp27397234p27397234.html
Sent from the matplotlib - users mailing list archive at Nabble.com.


--
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] using subscripts and tex in labels

2010-01-31 Thread per freem
hi all,

two quick questions about labels. first, is there a way to make
subscripts/superscripts *without* using TeX in labels? For example, I
use helvetica in all my labels and I want to plot something like:
plt.xlabel(log10) where 10 is a subscript of log, but without
doing: plt.xlabel(r$\log_{10}$), since that will use LaTeX fonts
instead of my helvetica font.

second question, when using TeX, I tried the following TeX command in labels:
plt.annotate(r\frac{\sigma}{\sqrt{\mu}}, ) but it complains that
not all arguments converted during string formatting -- but it seems
like correct TeX to me. if I try r\frac{1}{2} then it works, but
using \sigma and \sqrt inside breaks it.. any idea how to fix this?

thanks.

--
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] using subscripts and tex in labels

2010-01-31 Thread Gökhan Sever
On Sun, Jan 31, 2010 at 4:21 PM, per freem perfr...@gmail.com wrote:

 hi all,

 two quick questions about labels. first, is there a way to make
 subscripts/superscripts *without* using TeX in labels? For example, I
 use helvetica in all my labels and I want to plot something like:
 plt.xlabel(log10) where 10 is a subscript of log, but without
 doing: plt.xlabel(r$\log_{10}$), since that will use LaTeX fonts
 instead of my helvetica font.


Unicode strings might be the answer for this. Though needs someone's
confirmation.



 second question, when using TeX, I tried the following TeX command in
 labels:
 plt.annotate(r\frac{\sigma}{\sqrt{\mu}}, ) but it complains that
 not all arguments converted during string formatting -- but it seems
 like correct TeX to me. if I try r\frac{1}{2} then it works, but
 using \sigma and \sqrt inside breaks it.. any idea how to fix this?


Have you forgotten $ ? The following works correctly in my system.

plt.xlabel(r$\frac{\sigma}{\sqrt{\mu}}$)



 thanks.


 --
 The Planet: dedicated and managed hosting, cloud storage, colocation
 Stay online with enterprise data centers and the best network in the
 business
 Choose flexible plans and management services without long-term contracts
 Personal 24x7 support from experience hosting pros just a phone call away.
 http://p.sf.net/sfu/theplanet-com
 ___
 Matplotlib-users mailing list
 Matplotlib-users@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/matplotlib-users




-- 
Gökhan
--
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] using subscripts and tex in labels

2010-01-31 Thread Eric Firing
per freem wrote:
 hi all,
 
 two quick questions about labels. first, is there a way to make
 subscripts/superscripts *without* using TeX in labels? For example, I
 use helvetica in all my labels and I want to plot something like:
 plt.xlabel(log10) where 10 is a subscript of log, but without
 doing: plt.xlabel(r$\log_{10}$), since that will use LaTeX fonts
 instead of my helvetica font.

See the mathtext options in matplotlibrc.template.  It looks like what 
you need is

matplotlib.rc('mathtext', fontset='stixsans')

maybe with the additional kwarg, default='regular', if you don't want 
italics.

All this is with text.usetex=False (the default).


 
 second question, when using TeX, I tried the following TeX command in labels:
 plt.annotate(r\frac{\sigma}{\sqrt{\mu}}, ) but it complains that
 not all arguments converted during string formatting -- but it seems
 like correct TeX to me. if I try r\frac{1}{2} then it works, but
 using \sigma and \sqrt inside breaks it.. any idea how to fix this?

This is working for me with usetex=False or True but including dollar 
signs to signal the use of mathtext (or TeX) parsing.

Eric

--
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] How to calculate relative positions between objects

2010-01-31 Thread Renato Alves
Hi everyone

I've been going around matplotlib objects trying to find a way to
pre-calculate positions depending on input.

I'm trying to create a function that draws two barplots facing opposite
directions.

This is what I managed so far:

###

import numpy as np
import matplotlib.pyplot as plt
from scipy.stats import gamma
from mpl_toolkits.axes_grid import make_axes_locatable

fig = plt.figure(1, (10, 10))
ax1 = fig.add_subplot(1, 1, 1)

ax1.set_xlim(1,0)

labels = ('0-9', '10-19', '20-29', '30-39', '40-49',
'50-59', '60-69', '70-79', '80-89', '90-99')

pad = np.max([len(i) for i in labels]) * .15

divider = make_axes_locatable(ax1)
ax2 = divider.new_horizontal(size=100%, pad=pad, sharey=ax1)
fig.add_axes(ax2)

N = 10
ind = np.arange(N)  # the x locations for the groups
width = 0.35   # the width of the bars

x = [gamma.pdf(i, 1, scale=2) for i in range(N)]
y = [gamma.pdf(i, 5, scale=1) for i in range(N)]

ind = np.arange(N)

ax1.barh(ind, x)
ax2.barh(ind, y)

for loc, spine in ax1.spines.iteritems():
if loc in ['left','top']:
spine.set_color('none') # don't draw spine

for loc, spine in ax2.spines.iteritems():
if loc in ['right','top']:
spine.set_color('none') # don't draw spine

ax1.set_title('Men')
ax2.set_title('Women')

ax1.set_ylim(0, N)
ax2.set_ylim(0, N)

# Name bars
ax1.set_yticks(ind + width)
ax1.xaxis.set_ticks_position('bottom')
ax2.xaxis.set_ticks_position('bottom')
ax1.yaxis.set_ticks_position('right')
ax2.yaxis.set_ticks_position('left')

for tl in ax1.get_yticklabels():
tl.set_visible(False)

ax2.set_yticklabels(labels,
   horizontalalignment='center'
   )

for i in ax2.get_yticklabels():
i.set_position((-(pad * .12) , 0))

plt.show()

###

However I would like to generalize this function but he space between
the two plots and the position of the labels is giving me a hard time.

In particular, the lines:

pad = np.max([len(i) for i in labels]) * .15
i.set_position((-(pad * .12) , 0))

include two values (.15 and .12) that are completely arbitrary and
defined by trial and error for current labels.

However with different labels:
labels = ('-9000', '10-19', '20-29', '30-39', '40-49',
'50-59', '60-69', '70-79', '80-89', '9-99000')

the values are no longer valid and the final image is no longer properly
aligned.

I know my current approach is not the proper way but due to the
complexity of matplotlib, my very superficial knowledge about it and the
overwhelming documentation this was the closest I could get.

In the end I would like to contribute the final result as something to
be included in the gallery/examples section of the website as I'm
positive that it will be helpful to others.

Any comment or suggestion is extremely welcome.

Cheers,
Renato

--
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users