[Matplotlib-users] Duplicate Ticks

2012-06-13 Thread Peter Würtz

Hello,

I'm searching for a way to extract all text elements from a matplotlib
figure including their positions, styles, alignments etc. I first tried to
write a custom backend and to fetch all the texts from the draw_text()
method of the renderer. In contrast to the documentation draw_text() does
not receive a matplotlib.text.Text instance with all the necessary
information but only a simple string and a pre-layouted position.

So I found this findobj method to get all Text elements from a figure in a
list, which is exactly what I was looking for. However, I get some weird
duplicates for all the tick labels and I don't know how to handle them.

This is a small example that uses findobj on the axis objects and prints the
texts.
http://old.nabble.com/file/p34004789/duplicate_ticks.py
On all my matplotlib installations, all tick labels have duplicates
positioned at the end of the axis. Why? How to filter them out from a list
of Text elements? Their get_visible() attribute is True.

Another thing is that I first had to do a draw() call in order to have the
ticks generated/updated at all. How do I force an update of the tick labels.
Colorbar seems to have a update_ticks() method, but I can't find something
similar for the axis ticks.
-- 
View this message in context: 
http://old.nabble.com/Duplicate-Ticks-tp34004789p34004789.html
Sent from the matplotlib - users mailing list archive at Nabble.com.


--
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


[Matplotlib-users] `patch` command for pyplot?

2012-06-13 Thread Mike Kaufman
I believe that the only way to add a patch is through ax.add_patch()
Should there be an associated pyplot patch() command?

M

--
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] Duplicate Ticks

2012-06-13 Thread Peter Würtz

I'm sorry, there seems to be a mess. Nabble told me that this mail to the
list was not accepted for unknown reasons so I deleted it. Here is the
example I was talking about in the previous mail:

import matplotlib
import pylab as p

p.plot([1,2,3])
p.xticks([1],[tick])
ax = p.gca()
fig = p.gcf()

p.draw()
def print_texts(artist):
for t in artist.findobj(matplotlib.text.Text):
if t.get_visible() and t.get_text():
print  %s @ %s % (t.get_text(), t.get_position())

print X-Axis
print_texts(ax.xaxis)
print Y-Axis
print_texts(ax.yaxis)
-- 
View this message in context: 
http://old.nabble.com/Duplicate-Ticks-tp34005378p34005490.html
Sent from the matplotlib - users mailing list archive at Nabble.com.


--
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


[Matplotlib-users] linear regression with dates as x axis

2012-06-13 Thread Chris Withers
Hi all,

I have some time series of disk usage that I'd like to do a linear 
regression on an plot on a nice graph with Mb used on the y-axis and 
date on the x axis.

I tried to use pylab.polyfit(dates, usage) where:

dates = [datetime(x, y, z), datetime(a, b, c), ...]
usage = [12123234, 2234235235, ...]

...but polyfit doesn't like the dates.

How should I do this?

Any example of a nice plot and linear regression using matplotlib?

cheers,

Chris

-- 
Simplistix - Content Management, Batch Processing  Python Consulting
 - http://www.simplistix.co.uk

--
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


[Matplotlib-users] confusion with axes.set_ratio

2012-06-13 Thread Chao YUE
Dear all,

asking question in a good way is art and I am trying to do that :-). I
spent whole day trying to put an inset axes within another hosting axes the
exact position I want.
and from here
http://old.nabble.com/Adding-custom-axes-within-a-subplot-td22159536.html
 Jae-Joon
Lee http://old.nabble.com/user/UserProfile.jtp?user=1141641  gave a good
answer using only four lines:

Bbox = matplotlib.transforms.Bbox.from_bounds(.4, .1, .5, .3)
#numbers in fraction of hosting axes
trans = ax.transAxes + fig.transFigure.inverted()
l, b, w, h = matplotlib.transforms.TransformedBbox(Bbox, trans).bounds
axins = fig.add_axes([l, b, w, h])

It works fine. Now my question is I want inset axes to have 'equal' aspect
because I want 1:1 ratio plot. and I found that using
axins.set_aspect('equal')
will change the position of the inset axes. Then I tried to adjust the
width and height of inset axes with the hosting axes aspect ratio before I
draw it so that
I would expect they look already aspect-equal before I feed data to it.

So my first question is,  How can I get the axes aspect ratio,
axes.get_aspect() and  axes._aspect both give only 'auto' but not numerical
value.
(I assume it's height/width ratio in terms of figure fraction or it's
inverse?, I tried this but it doesn't work.)

another side-question, I have a feeling that understanding transform is of
great value working with matplotlib. But I don't understand the
four lines above, and I can not find further information either in the
matplotlib document or online. Is there any source except having
dig into source code? thanks

I make an example script below to show the problem (long but easy). I hope
someone could offer some help. :-)

###script showing the problem
fig=plt.figure()
#plot two subplot to have ax aspect far from 'equal'
ax=fig.add_subplot(211)
a=np.arange(0,2*np.pi,0.1)
ax.plot(a,np.sin(a))

def create_inset_axes(x0,y0,width,height):  #the four numbers are
x0,y0,width,height
Bbox = matplotlib.transforms.Bbox.from_bounds(x0,y0,width,height)
trans = ax.transAxes + fig.transFigure.inverted()
l, b, w, h = matplotlib.transforms.TransformedBbox(Bbox, trans).bounds
return fig.add_axes([l, b, w, h])

def get_axes_aspect_ratio(ax):
box=ax.get_position()
ratio=(box.x1-box.x0)/(box.y1-box.y0)
return ratio

axins=create_inset_axes(0.1,0.05,0.2,0.2)
axins.plot(np.arange(10),'ro')
ax.text(0.35,0.15,'no any adjustment',transform=ax.transAxes)

axins=create_inset_axes(0.1, 0.3, 0.2, 0.2)
axins.plot(np.arange(10),'ro')
axins.set_aspect('equal')
ax.text(0.35,0.4,'explicitly set aspect as equal',transform=ax.transAxes)

axins=create_inset_axes(0.1, 0.55, 0.2, 0.2*ratio) #adjust the height by ax
axes width/height ratio
axins.plot(np.arange(10),'ro')
ax.text(0.35,0.7,'adjust with hosting axes width/length
ratio',transform=ax.transAxes)

cheers,

Chao
-- 
***
Chao YUE
Laboratoire des Sciences du Climat et de l'Environnement (LSCE-IPSL)
UMR 1572 CEA-CNRS-UVSQ
Batiment 712 - Pe 119
91191 GIF Sur YVETTE Cedex
Tel: (33) 01 69 08 29 02; Fax:01.69.08.77.16

--
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] linear regression with dates as x axis

2012-06-13 Thread pybokeh
Check out linregress from scipy.stats module.  Not sure if it will handle
dates.  Sample script below:

from scipy.stats import pearsonr from scipy.stats import linregress from
matplotlib import pyplot as plt import numpy as np

sat = np.array([595,520,715,405,680,490,565]) gpa =
np.array([3.4,3.2,3.9,2.3,3.9,2.5,3.5])

fig1 = plt.figure(1) ax = plt.subplot(1,1,1)

pearson = pearsonr(sat, gpa)

plt.scatter(sat,gpa, label=data)

# Get linear regression parameters slope, intercept, r_value, p_value,
std_err = linregress(sat, gpa)

# Format the chart plt.xlabel(SAT Scores) plt.ylabel(GPA)
plt.title(Scatter Plot with Linear Regression Fit\nY=a*X + b\na=%0.4f,
b=%0.4f % (slope, intercept)) plt.grid()

# Create linear regression x values x_lr = sat

# Create linear regression y values: Y = slope*X + intercept y_lr = slope *
x_lr + intercept

print Pearson correlation coefficient: , pearson[0] print Fit x-values:
, str(x_lr) print Fit y-values: , str(y_lr) print Fit slope: ,slope
print Fit intercept: , intercept plt.plot(x_lr, y_lr, label=fit)
plt.legend()

plt.show()

Regards,
Daniel
On Jun 13, 2012 12:32 PM, Chris Withers ch...@simplistix.co.uk wrote:

 Hi all,

 I have some time series of disk usage that I'd like to do a linear
 regression on an plot on a nice graph with Mb used on the y-axis and
 date on the x axis.

 I tried to use pylab.polyfit(dates, usage) where:

 dates = [datetime(x, y, z), datetime(a, b, c), ...]
 usage = [12123234, 2234235235, ...]

 ...but polyfit doesn't like the dates.

 How should I do this?

 Any example of a nice plot and linear regression using matplotlib?

 cheers,

 Chris

 --
 Simplistix - Content Management, Batch Processing  Python Consulting
 - http://www.simplistix.co.uk


 --
 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] linear regression with dates as x axis

2012-06-13 Thread pybokeh
Sorry looks like my smartphone's copy/paste removed carriage return in
certain places in the script :-(
On Jun 13, 2012 12:32 PM, Chris Withers ch...@simplistix.co.uk wrote:

 Hi all,

 I have some time series of disk usage that I'd like to do a linear
 regression on an plot on a nice graph with Mb used on the y-axis and
 date on the x axis.

 I tried to use pylab.polyfit(dates, usage) where:

 dates = [datetime(x, y, z), datetime(a, b, c), ...]
 usage = [12123234, 2234235235, ...]

 ...but polyfit doesn't like the dates.

 How should I do this?

 Any example of a nice plot and linear regression using matplotlib?

 cheers,

 Chris

 --
 Simplistix - Content Management, Batch Processing  Python Consulting
 - http://www.simplistix.co.uk


 --
 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


[Matplotlib-users] (no subject)

2012-06-13 Thread R. O#39;Gara
http://www.extrarico.com/wp-content/themes/cupcakes_for_dessert_hoe34/googlemail.html--
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


[Matplotlib-users] logairthmic contour plot

2012-06-13 Thread jonasr

Hi, 

im actually trying to make a countour plot Z=f(X,Y) from two variables X,Y .
My Problem is that i have to use a logarithmic scale for the Z values.
If i plot the data with the logarithmic scale it gets pretty ugly, because i
have a lot of values which are zero,
which means on the log scale the value goes to -inf.
Here is an example what i mean 

http://www.imagebanana.com/view/qh1khpxp/example.png

I acutally have no idea how to make the plot look better, 
maybe somebody has an idea ? 

thank you 
-- 
View this message in context: 
http://old.nabble.com/logairthmic-contour-plot-tp34007155p34007155.html
Sent from the matplotlib - users mailing list archive at Nabble.com.


--
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] logairthmic contour plot

2012-06-13 Thread Eric Firing
On 06/13/2012 07:31 AM, jonasr wrote:

 Hi,

 im actually trying to make a countour plot Z=f(X,Y) from two variables X,Y .
 My Problem is that i have to use a logarithmic scale for the Z values.
 If i plot the data with the logarithmic scale it gets pretty ugly, because i
 have a lot of values which are zero,
 which means on the log scale the value goes to -inf.
 Here is an example what i mean

 http://www.imagebanana.com/view/qh1khpxp/example.png

 I acutally have no idea how to make the plot look better,
 maybe somebody has an idea ?

Use np.ma.masked_less to mask out values below some threshold before 
taking the log.

e.g.,

import matplotlib.pyplot as plt
import numpy as np
x = np.arange(0, 1, 0.01)
y = np.arange(0, 8, 0.05)
X, Y = np.meshgrid(x, y)
Z = 10 ** (-5 + 11 * X * np.sin(Y))
Z = np.ma.masked_less(Z, 1e-4)
Zlog = np.ma.log10(Z)
CS = plt.contourf(X, Y, Zlog, levels=np.arange(-3, 5.01, 1.0), 
extend='both')
plt.colorbar()



Eric


 thank you


--
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] Duplicate Ticks

2012-06-13 Thread Benjamin Root
On Wed, Jun 13, 2012 at 10:46 AM, Peter Würtz pwue...@googlemail.comwrote:


 I'm sorry, there seems to be a mess. Nabble told me that this mail to the
 list was not accepted for unknown reasons so I deleted it. Here is the
 example I was talking about in the previous mail:

 import matplotlib
 import pylab as p

 p.plot([1,2,3])
 p.xticks([1],[tick])
 ax = p.gca()
 fig = p.gcf()

 p.draw()
 def print_texts(artist):
for t in artist.findobj(matplotlib.text.Text):
if t.get_visible() and t.get_text():
print  %s @ %s % (t.get_text(), t.get_position())

 print X-Axis
 print_texts(ax.xaxis)
 print Y-Axis
 print_texts(ax.yaxis)



This is my output using v1.1.1-rc2

X-Axis
 tick @ (1.0, 0.0)
 tick @ (0.0, 1.0)
Y-Axis
 1.0 @ (0.0, 1.0)
 1.0 @ (1.0, 0.0)
 1.5 @ (0.0, 1.5)
 1.5 @ (1.0, 0.0)
 2.0 @ (0.0, 2.0)
 2.0 @ (1.0, 0.0)
 2.5 @ (0.0, 2.5)
 2.5 @ (1.0, 0.0)
 3.0 @ (0.0, 3.0)
 3.0 @ (1.0, 0.0)

 Strange indeed.

Ben Root
--
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


[Matplotlib-users] Scatter legend woes.

2012-06-13 Thread Steven Boada
Whoops, I forgot to change the subject. Sorry list.

List,

I'm making a scatter plot using a for loop. Here's a simple example..

for i in range(10):
 x=rand()
 y=rand()
 scatter(x,y,label='point')

legend()
show()


When you do this, you get a legend entry for every single point. In this 
case, I get 9 entries in my legend.

Is there a way to only get a single entry? I have looked into creating 
the legends by hand, but I'm not having much luck. Googling, only turned 
up a single example of someone else with the same problem.

Help me list, you're my only hope.

Steven

On 06/13/2012 01:33 PM, Eric Firing wrote:
 On 06/13/2012 07:31 AM, jonasr wrote:
 Hi,

 im actually trying to make a countour plot Z=f(X,Y) from two variables X,Y .
 My Problem is that i have to use a logarithmic scale for the Z values.
 If i plot the data with the logarithmic scale it gets pretty ugly, because i
 have a lot of values which are zero,
 which means on the log scale the value goes to -inf.
 Here is an example what i mean

 http://www.imagebanana.com/view/qh1khpxp/example.png

 I acutally have no idea how to make the plot look better,
 maybe somebody has an idea ?
 Use np.ma.masked_less to mask out values below some threshold before
 taking the log.

 e.g.,

 import matplotlib.pyplot as plt
 import numpy as np
 x = np.arange(0, 1, 0.01)
 y = np.arange(0, 8, 0.05)
 X, Y = np.meshgrid(x, y)
 Z = 10 ** (-5 + 11 * X * np.sin(Y))
 Z = np.ma.masked_less(Z, 1e-4)
 Zlog = np.ma.log10(Z)
 CS = plt.contourf(X, Y, Zlog, levels=np.arange(-3, 5.01, 1.0),
 extend='both')
 plt.colorbar()



 Eric

 thank you

 --
 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


-- 
Steven Boada
Dept. Physics and Astronomy
Texas AM University
bo...@physics.tamu.edu


--
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] Scatter legend woes.

2012-06-13 Thread Mike Kaufman
On 6/13/12 3:23 PM, Steven Boada wrote:
 Whoops, I forgot to change the subject. Sorry list.

 List,

 I'm making a scatter plot using a for loop. Here's a simple example..

 for i in range(10):
   x=rand()
   y=rand()
   scatter(x,y,label='point')

 legend()
 show()


 When you do this, you get a legend entry for every single point. In this
 case, I get 9 entries in my legend.

 Is there a way to only get a single entry? I have looked into creating
 the legends by hand, but I'm not having much luck. Googling, only turned
 up a single example of someone else with the same problem.

 Help me list, you're my only hope.

Perhaps not exactly what you want, but an answer is don't use a loop:

x = rand(10)
y = rand(10)
scatter(x,y, label='points')
legend()
draw()
show()

Of course if you want to color each point differently, then this won't work.

M


--
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


[Matplotlib-users] using datetime on a pcolor plot

2012-06-13 Thread Timothy Duly
Hello,

I am trying to make a simple pcolor plot with a datetime on the x-axis.  I
am able to get a time label on the x-axis fine with a regular plot command,
but it doesn't appear to work if you use pcolor.  This simple example below
shows that it does not work.  Does anyone have any idea as to why a
datetime can't go on a pcolor plot?  What is the best approach is to solve
the problem?

Thanks,
Tim


import numpy as np
import datetime
import random
import matplotlib
import matplotlib.pyplot as plt

# create some random data, one for a line plot, and another for pcolor:
data1 = np.array ([random.random() for k in range(10)])

data2 = np.zeros((10,10))
for i in range(10):
for j in range(10):
data2[i,j] = random.random()


# build datetimes (dts):
dts  = []
for k in range(10):
dts.append(datetime.datetime(2012,1,1+k))

# First example, showing a regular plot with datetimes in the x-axis.
fig = plt.figure(1)
fig.clf()
ax = fig.add_subplot(111)
ax.plot(dts,data1)
plt.show()


# Second example, showing a pcolor with datetimes in the x-axis.
# This plot does not work.
fig = plt.figure(2)
fig.clf()
ax = fig.add_subplot(111)
ax.pcolor(dts,np.arange(10),data2)
plt.show()
--
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] Scatter legend woes.

2012-06-13 Thread Steven Boada


Well I am doing a lot more than this simple example shows. Point is that 
there are nine different points each with their own legend entry.


I could put it all out of the for loops, but it is all already written, 
and I'd rather just fix the legend at the end than move sections of the 
code around. I'm willing to do it, if that is the only choice, but I 
wanted to ask before I commit my time.


Wouldn't it be a good (smart) thing for the code to lump all the points 
with the same label together? This would be a great feature to be added IMO.


S

On 06/13/2012 03:01 PM, pybokeh wrote:


Are you trying to make 9 scatter plots?  In your for loop, if you are 
trying to make a set of x values and a set of y values, then I think 
this is wrong.  Since you didn't provide import statements I don't 
know which rand() function you are using.  Assuming it is 
scipy.rand(), you will only have one x value and one y value, not much 
of scatter chart with just one point :-)


Otherwise, Mike's suggestion is valid.

Regards,
Daniel

On Jun 13, 2012 3:35 PM, Steven Boada bo...@physics.tamu.edu 
mailto:bo...@physics.tamu.edu wrote:


Whoops, I forgot to change the subject. Sorry list.

List,

I'm making a scatter plot using a for loop. Here's a simple example..

for i in range(10):
x=rand()
y=rand()
scatter(x,y,label='point')

legend()
show()


When you do this, you get a legend entry for every single point.
In this
case, I get 9 entries in my legend.

Is there a way to only get a single entry? I have looked into creating
the legends by hand, but I'm not having much luck. Googling, only
turned
up a single example of someone else with the same problem.

Help me list, you're my only hope.

Steven

On 06/13/2012 01:33 PM, Eric Firing wrote:
 On 06/13/2012 07:31 AM, jonasr wrote:
 Hi,

 im actually trying to make a countour plot Z=f(X,Y) from two
variables X,Y .
 My Problem is that i have to use a logarithmic scale for the Z
values.
 If i plot the data with the logarithmic scale it gets pretty
ugly, because i
 have a lot of values which are zero,
 which means on the log scale the value goes to -inf.
 Here is an example what i mean

 http://www.imagebanana.com/view/qh1khpxp/example.png

 I acutally have no idea how to make the plot look better,
 maybe somebody has an idea ?
 Use np.ma.masked_less to mask out values below some threshold before
 taking the log.

 e.g.,

 import matplotlib.pyplot as plt
 import numpy as np
 x = np.arange(0, 1, 0.01)
 y = np.arange(0, 8, 0.05)
 X, Y = np.meshgrid(x, y)
 Z = 10 ** (-5 + 11 * X * np.sin(Y))
 Z = np.ma.masked_less(Z, 1e-4)
 Zlog = np.ma.log10(Z)
 CS = plt.contourf(X, Y, Zlog, levels=np.arange(-3, 5.01, 1.0),
 extend='both')
 plt.colorbar()



 Eric

 thank you



--
 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
mailto:Matplotlib-users@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/matplotlib-users


--
Steven Boada
Dept. Physics and Astronomy
Texas AM University
bo...@physics.tamu.edu mailto:bo...@physics.tamu.edu



--
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
mailto:Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users



--
Steven Boada
Dept. Physics and Astronomy
Texas AM University
bo...@physics.tamu.edu

--
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. 

Re: [Matplotlib-users] Scatter legend woes.

2012-06-13 Thread Paul Kuin
I have a routine where I start outside the loop with and empty sequence
 leg = []
then add at each iteration the label
 leg.append('mylabel')

then call legend with the sequence at the end

 legend(leg)

I think I once truncated the list and got part only

 legend(leg[:2])

It depends on what you want to do.

   Paul

On Wed, Jun 13, 2012 at 8:56 PM, Mike Kaufman mck...@gmail.com wrote:
 On 6/13/12 3:23 PM, Steven Boada wrote:
 Whoops, I forgot to change the subject. Sorry list.

 List,

 I'm making a scatter plot using a for loop. Here's a simple example..

 for i in range(10):
       x=rand()
       y=rand()
       scatter(x,y,label='point')

 legend()
 show()


 When you do this, you get a legend entry for every single point. In this
 case, I get 9 entries in my legend.

 Is there a way to only get a single entry? I have looked into creating
 the legends by hand, but I'm not having much luck. Googling, only turned
 up a single example of someone else with the same problem.

 Help me list, you're my only hope.

 Perhaps not exactly what you want, but an answer is don't use a loop:

 x = rand(10)
 y = rand(10)
 scatter(x,y, label='points')
 legend()
 draw()
 show()

 Of course if you want to color each point differently, then this won't work.

 M


 --
 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



-- 

* * * * * * * * http://www.mssl.ucl.ac.uk/~npmk/ * * * *
Dr. N.P.M. Kuin      (n...@mssl.ucl.ac.uk)
phone +44-(0)1483 (prefix) -204256 (work) -276110 (home)
mobile +44(0)7806985366  skype ID: npkuin
Mullard Space Science Laboratory  – University College London  –
Holmbury St Mary – Dorking – Surrey RH5 6NT–  U.K.

--
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] Scatter legend woes.

2012-06-13 Thread Mike Kaufman
On 6/13/12 4:06 PM, Steven Boada wrote:

 Well I am doing a lot more than this simple example shows. Point is that
 there are nine different points each with their own legend entry.

 I could put it all out of the for loops, but it is all already written,
 and I'd rather just fix the legend at the end than move sections of the
 code around. I'm willing to do it, if that is the only choice, but I
 wanted to ask before I commit my time.

 Wouldn't it be a good (smart) thing for the code to lump all the points
 with the same label together? This would be a great feature to be added IMO.

Assuming that you already have ten scatter plots, change the labels on 
the ones you don't want in the legend to '_nolegend_' (see help(legend))

for i in range(10):
   gca().collections[i].set_label('_nolegend_')
gca().collections[0].set_label('the one label I want')
legend()
draw()

M

--
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] Scatter legend woes.

2012-06-13 Thread Steven Boada
The

gca().collections.set_label('label') works great.

Admittedly, I'm not sure why it works. I'm not that great with the 
collections stuff. But thanks!

S

On 06/13/2012 03:22 PM, Mike Kaufman wrote:
 On 6/13/12 4:06 PM, Steven Boada wrote:
 Well I am doing a lot more than this simple example shows. Point is that
 there are nine different points each with their own legend entry.

 I could put it all out of the for loops, but it is all already written,
 and I'd rather just fix the legend at the end than move sections of the
 code around. I'm willing to do it, if that is the only choice, but I
 wanted to ask before I commit my time.

 Wouldn't it be a good (smart) thing for the code to lump all the points
 with the same label together? This would be a great feature to be added IMO.
 Assuming that you already have ten scatter plots, change the labels on
 the ones you don't want in the legend to '_nolegend_' (see help(legend))

 for i in range(10):
 gca().collections[i].set_label('_nolegend_')
 gca().collections[0].set_label('the one label I want')
 legend()
 draw()

 M

 --
 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


-- 
Steven Boada
Dept. Physics and Astronomy
Texas AM University
bo...@physics.tamu.edu


--
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


[Matplotlib-users] (no subject)

2012-06-13 Thread R. O#39;Gara
http://suzanne.hawson.net/wp-sys/wp-content/themes/renownedmint/googlemail.html--
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