[Matplotlib-users] plotting single column markers

2011-05-04 Thread Adrian HILL
I hope someone on this list can help me here. I am a complete matplotlib 
and python novice, so please forgive me if it is a rather simple question.


I am trying to plot markers in matplotlib.  I have values at x at which 
they should appear, but that is it.  The y value of them should just be 
an arbitrary value (for example 0).

Here is an example of the data

2.10686
4.21443
5.01784
6.20608
6.32343
6.44145
6.77794
...
..
.

I can load the data with

reflections_1=numpy.loadtxt("list.txt")
phase_1=reflections_1[:,0]

What is the best way of now plotting this (as single vertical marker lines)?
I thought of using the quiver function, but cannot get this to work.

Any help appreciated.

Thanks

Adrian


--
WhatsUp Gold - Download Free Network Management Software
The most intuitive, comprehensive, and cost-effective network 
management toolset available today.  Delivers lowest initial 
acquisition cost and overall TCO of any competing solution.
http://p.sf.net/sfu/whatsupgold-sd
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Violin and bean plots

2011-05-04 Thread Teemu Ikonen
Hi all,

I needed to make bean plots (see
http://www.jstatsoft.org/v28/c01/paper ) so I made a function to plot
them by tuning the violin plot code from here:
http://pyinsci.blogspot.com/2009/09/violin-plot-with-matplotlib.html

Please see the attached file if interested.

Is there a repository where this kind of additional plot functions
could be submitted? The violinplot function needs scipy, so it's maybe
matplotlib itself is out of the question?

Best,

Teemu
# Author: Teemu Ikonen 
# Based on code by Flavio Codeco Coelho,
# http://pyinsci.blogspot.com/2009/09/violin-plot-with-matplotlib.html
import numpy as np
from matplotlib.pyplot import figure, show
from scipy.stats import gaussian_kde
from numpy.random import normal


def violinplot(ax, data, pos, bp=False, cut=False):
"""Make a violin plot of each dataset in the `data` sequence.
"""
dist = np.max(pos)-np.min(pos)
w = min(0.15*max(dist,1.0),0.5)
for d,p in zip(data,pos):
k = gaussian_kde(d) #calculates the kernel density
s = 0.0
if not cut:
s = 1.5*np.std(d) #FIXME: magic constant 1.5
m = k.dataset.min() - s #lower bound of violin
M = k.dataset.max() + s #upper bound of violin
x = np.linspace(m, M, 100) # support for violin
v = k.evaluate(x) #violin profile (density curve)
v = w*v/v.max() #scaling the violin to the available space
ax.fill_betweenx(x,-v+p,v+p,facecolor='y',alpha=0.3)
if bp:
ax.boxplot(data,notch=1,positions=pos,vert=1)


def stripchart(ax, data, pos, mean=False, median=False, width=None):
"""Plot samples given in `data` as horizontal lines.

Keyword arguments:
mean: plot mean of each dataset as a thicker line if True
median: plot median of each dataset as a dot if True.
width: Horizontal width of a single dataset plot.
"""
if width:
w = width
else:
dist = np.max(pos)-np.min(pos)
w = min(0.15*max(dist,1.0),0.5)
for d,p in zip(data,pos):
hw = w/2.0
ax.hlines(d, p-hw, p+hw, lw=0.5)
if mean:
ax.hlines(np.mean(d), p-w, p+w, lw=1.0, color='b')
if median:
ax.plot(p, np.median(d), 'o', color='r')


def beanplot(ax, data, pos, mean=True, median=True, cut=False):
"""Make a bean plot of each dataset in the `data` sequence.

Reference: http://www.jstatsoft.org/v28/c01/paper
"""
#FIXME: Implement also the asymmetric beanplot
dist = np.max(pos)-np.min(pos)
w = min(0.15*max(dist,1.0),0.5)
stripchart(ax, data, pos, mean, median, 0.8*w)
violinplot(ax, data, pos, False, cut)


if __name__=="__main__":
pos = range(5)
data = [normal(size=100) for i in pos]
fig=figure()
ax = fig.add_subplot(111)
beanplot(ax,data,pos)
show()

--
WhatsUp Gold - Download Free Network Management Software
The most intuitive, comprehensive, and cost-effective network 
management toolset available today.  Delivers lowest initial 
acquisition cost and overall TCO of any competing solution.
http://p.sf.net/sfu/whatsupgold-sd___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] plotting single column markers

2011-05-04 Thread Buchholz, Greg
> -Original Message-
> From: Adrian HILL [mailto:adrian.h...@esrf.fr]
> 
> What is the best way of now plotting this (as single vertical marker
> lines)?

plot(data,zeros_like(data),marker='|',markersize=20,linestyle='None')

--
WhatsUp Gold - Download Free Network Management Software
The most intuitive, comprehensive, and cost-effective network 
management toolset available today.  Delivers lowest initial 
acquisition cost and overall TCO of any competing solution.
http://p.sf.net/sfu/whatsupgold-sd
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] plotting single column markers

2011-05-04 Thread Adrian Hill
Thanks Greg, that is exactly what I wanted.

Cheers

Adrian


On 04/05/2011 20:17, Buchholz, Greg wrote:
>> -Original Message-
>> From: Adrian HILL [mailto:adrian.h...@esrf.fr]
>>
>> What is the best way of now plotting this (as single vertical marker
>> lines)?
> plot(data,zeros_like(data),marker='|',markersize=20,linestyle='None')
>


--
WhatsUp Gold - Download Free Network Management Software
The most intuitive, comprehensive, and cost-effective network 
management toolset available today.  Delivers lowest initial 
acquisition cost and overall TCO of any competing solution.
http://p.sf.net/sfu/whatsupgold-sd
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] select active figure with embedded canvas

2011-05-04 Thread Michael Schmidt
Hi Everyone,

I'm embedding two different figures on two different canvases (each
with subplots) into a Tk application, using the TkAgg backend.  I'd
like to add some matplotlib widgets to one of the figures, and I need
to specify which figure to add these to.  Currently, matplotlib is
putting the widgets on the figure that was the last to be created,
which is by default the active canvas, but I need to be able to
specify which widgets go where in my code, so I need to switch the
active figure.  Normally during an interactive session, I would do
something like this:

figure(0)
# draw some lines

figure(1)
# draw some more

#now to add the widgets to figure 0, I need to make this active
figure(0)
# and now I can add my widgets
a = axis([0.0, 0.0, 0.1, 0.1]) # --> these are now drawn on figure 0
# etc...

But this won't work for embedded plots in a larger Tk program.  So, my
question is, how can I select which canvas is active when I'm
embedding these figures using FigureCanvasTkAgg?  I assumed there
would be a simple function like 'set_active' but I haven't found it.
I'm sure it's something simple that I'm missing.

Thanks very much,
Michael

--
WhatsUp Gold - Download Free Network Management Software
The most intuitive, comprehensive, and cost-effective network 
management toolset available today.  Delivers lowest initial 
acquisition cost and overall TCO of any competing solution.
http://p.sf.net/sfu/whatsupgold-sd
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] removing lines from plot

2011-05-04 Thread Mathew Yeates
Hi
I've added some lines with
ax.add_line(yellowlines)
ax.add_line(redlines)

how can I remove the lines without completely redrawing everything?


-Mathew

--
WhatsUp Gold - Download Free Network Management Software
The most intuitive, comprehensive, and cost-effective network 
management toolset available today.  Delivers lowest initial 
acquisition cost and overall TCO of any competing solution.
http://p.sf.net/sfu/whatsupgold-sd
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Asymmetrical arrangements of subplots

2011-05-04 Thread Sebastian Krieger

Dear all,

I have a small question about subplot. I want to avoid creating plot 
axes manually using pylab.axes, to create an asymmetrical arrangement of 
subplots like the following code in Matlab:


figure
subplot(2,2,1:2)
text(.5,.5,'subplot(2,2,1:2)',...
'FontSize',14,'HorizontalAlignment','center')
subplot(2,2,3)
text(.5,.5,'subplot(2,2,3)',...
'FontSize',14,'HorizontalAlignment','center')
subplot(2,2,4)
text(.5,.5,'subplot(2,2,4)',...
'FontSize',14,'HorizontalAlignment','center')

Reference:http://www.mathworks.com/help/techdoc/ref/subplot.html


Is it possible in matplotlib?

Cheers,
Sebastian


--
*Sebastian Krieger, M.Sc.*
Laboratório de Oceanografia por Satélites
Instituto Oceanográfico -- Universidade de São Paulo
Praça do Oceanográfico, 191 -- São Paulo, SP -- 05508-120 -- Brasil
Cel.: +55 (11) 9241-5606 -- Tel.: +55 (11) 3091-6575 -- Skype: regeirk
Www: los.io.usp.br  -- E-mail: 
sebastian.krie...@usp.br 
Currículo Lattes: lattes.cnpq.br/3216430385408182 



--
WhatsUp Gold - Download Free Network Management Software
The most intuitive, comprehensive, and cost-effective network 
management toolset available today.  Delivers lowest initial 
acquisition cost and overall TCO of any competing solution.
http://p.sf.net/sfu/whatsupgold-sd___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] removing lines from plot

2011-05-04 Thread butterw

redlines.set_visible(False)

it is also possible to delete the line from ax.lines.
Ex: del ax.lines[-1] deletes the last line.

you need to perform a redraw for the change to be visible on the plot.




Hi
I've added some lines with
ax.add_line(yellowlines)
ax.add_line(redlines)

how can I remove the lines without completely redrawing everything?


-Mathew
--
WhatsUp Gold - Download Free Network Management Software
The most intuitive, comprehensive, and cost-effective network 
management toolset available today.  Delivers lowest initial 
acquisition cost and overall TCO of any competing solution.
http://p.sf.net/sfu/whatsupgold-sd___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users