Amitava Maity | 1 Nov 15:49
Favicon

how to plot curve between two points

Hello,

Given a set of points: (x1, y1), (x2, y2), (x3, y3), (x4, y4), 
....

How do plot a curve y = sinh(x) between (x1, y1) and (x2, y2) and 
then
between (x2, y2) and (x3, y3) and so on .....?

Thanks in advance,
AMaity.

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
sandric ionut | 1 Nov 20:53
Picon
Favicon

cumulative percentage

 
Hello everbody:
 
How can I plot cumulative percentage with matplotlib?
 
Please, can someone give me an example?
 
Thank you,
 
Ionut

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@...
https://lists.sourceforge.net/lists/listinfo/matplotlib-users
John Hunter | 1 Nov 21:12
Picon
Gravatar

Re: cumulative percentage

On Sat, Nov 1, 2008 at 2:53 PM, sandric ionut <sandricionut@...> wrote:

> How can I plot cumulative percentage with matplotlib?
>
> Please, can someone give me an example?

Take a look at the "extended" histogram examples at

  http://matplotlib.sourceforge.net/examples/pylab_examples/histogram_demo_extended.html

You can also search the docs for histogram:

  http://matplotlib.sourceforge.net/search.html?q=histogram

JDH

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
sandric ionut | 1 Nov 21:35
Picon
Favicon

Re: cumulative percentage

Hi:
 
I did had a look before, but I couldn't find a good example
I was hoping to get an example from the list
 
I.

From: John Hunter <jdh2358-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: sandric ionut <sandricionut-/E1597aS9LQAvxtiuMwx3w@public.gmane.org>
Cc: matplotlib-users-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
Sent: Saturday, November 1, 2008 10:12:29 PM
Subject: Re: [Matplotlib-users] cumulative percentage

On Sat, Nov 1, 2008 at 2:53 PM, sandric ionut <sandricionut-/E1597aS9LQAvxtiuMwx3w@public.gmane.org> wrote:

> How can I plot cumulative percentage with matplotlib?
>
> Please, can someone give me an example?

Take a look at the "extended" histogram examples at

  http://matplotlib.sourceforge.net/examples/pylab_examples/histogram_demo_extended.html

You can also search the docs for histogram:

  http://matplotlib.sourceforge.net/search.html?q=histogram

JDH

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@...
https://lists.sourceforge.net/lists/listinfo/matplotlib-users
John Hunter | 1 Nov 21:50
Picon
Gravatar

Re: cumulative percentage

On Sat, Nov 1, 2008 at 3:35 PM, sandric ionut <sandricionut@...> wrote:
> Hi:
>
> I did had a look before, but I couldn't find a good example
> I was hoping to get an example from the list
>

The example is in the link I posted

http://matplotlib.sourceforge.net/examples/pylab_examples/histogram_demo_extended.html

but I will include it here for your convenience

  n, bins, patches = P.hist(x, 50, normed=1, histtype='step', cumulative=True)

  # add a line showing the expected distribution
  y = P.normpdf( bins, mu, sigma).cumsum()
  y /= y[-1]
  l = P.plot(bins, y, 'k--', linewidth=1.5)

See the link for the full example code

JDH

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
Edin Salkovic | 3 Nov 21:52
Picon

Re: Setting the axis of an imshow plot

On Mon, Nov 3, 2008 at 9:08 PM, Edin Salkovic
<edin.salkovic@...> wrote:
> On Mon, Nov 3, 2008 at 8:23 PM, Edin Salkovic
<edin.salkovic@...> wrote:
>> Am I missing something obvious?
>
> xticklabels/yticklabels did the job.
>
> Sorry for the noise.

Actually, with xticklabels/yticklabels the zoom functionality for the
image is broken, so I still need a better solution.

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
Ryan May | 3 Nov 22:47
Picon
Gravatar

Re: Setting the axis of an imshow plot

Edin Salkovic wrote:
> On Mon, Nov 3, 2008 at 9:08 PM, Edin Salkovic
<edin.salkovic@...> wrote:
>> On Mon, Nov 3, 2008 at 8:23 PM, Edin Salkovic
<edin.salkovic@...> wrote:
>>> Am I missing something obvious?
>> xticklabels/yticklabels did the job.
>>
>> Sorry for the noise.
> 
> Actually, with xticklabels/yticklabels the zoom functionality for the
> image is broken, so I still need a better solution.

Try the extent kwarg for imshow:

      *extent*: [ None | scalars (left, right, bottom, top) ]
        Eata values of the axes.  The default assigns zero-based row,
        column indices to the *x*, *y* centers of the pixels.

So you would do:

imshow(data, extent=(l, r, b, t))

Ryan

--

-- 
Ryan May
Graduate Research Assistant
School of Meteorology
University of Oklahoma

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
Edin Salkovic | 3 Nov 23:12
Picon

Re: Setting the axis of an imshow plot

On Mon, Nov 3, 2008 at 10:47 PM, Ryan May <rmay31@...> wrote:
> Try the extent kwarg for imshow:
>
>      *extent*: [ None | scalars (left, right, bottom, top) ]
>        Eata values of the axes.  The default assigns zero-based row,
>        column indices to the *x*, *y* centers of the pixels.
>
> So you would do:
>
> imshow(data, extent=(l, r, b, t))

Yes, this works, thanks!  The weird thing is that the first time I
tried "extent" it didn't work (i.e. I messed up something :) ).

Edin

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
Jae-Joon Lee | 4 Nov 11:01
Picon
Gravatar

Re: no canvas reinitialization between calls to savefig

> I spent some time working on it and came to the following conclusion:
> if the mpl figure is fully transparent, you see whatever is in the gui
> rendering buffer, which may be unintiialized memory.   In some sense,
> mpl is doing what is asked of it, making a fully transparent figure.
> Clearing the agg buffer is not enough if it is transparent -- you also
> have to init the canvas buffer.  The question is: with what?
>

I think what we may want is to let the the gui backend do the
compositing, i.e., showing a composite image of the background (of the
canvas widget) and what is in the agg buffer.
In recent version of GTK(2.8 and later), you can do it with cairo.

The attached is a test patch for the gtkagg backend. It includes a
small example which sets an image as a background of the canvas (see
the attached image).

I found this patch make the mpl quite slowed down in my unix box, but
fine in my macbook (my guess is it depends on whether cairo uses the
hardware acceleration or not).

Regards,

-JJ
Index: lib/matplotlib/backends/backend_agg.py
===================================================================
--- lib/matplotlib/backends/backend_agg.py	(revision 6360)
+++ lib/matplotlib/backends/backend_agg.py	(working copy)
@@ -280,6 +280,7 @@
         if __debug__: verbose.report('FigureCanvasAgg.draw', 'debug-annoying')

         self.renderer = self.get_renderer()
+        self.renderer.clear()
         self.figure.draw(self.renderer)

     def get_renderer(self):
Index: lib/matplotlib/backends/backend_gtkagg.py
===================================================================
--- lib/matplotlib/backends/backend_gtkagg.py	(revision 6360)
+++ lib/matplotlib/backends/backend_gtkagg.py	(working copy)
@@ -10,7 +10,7 @@
 from matplotlib.backends.backend_gtk import gtk, FigureManagerGTK, FigureCanvasGTK,\
      show, draw_if_interactive,\
      error_msg_gtk, NavigationToolbar, PIXELS_PER_INCH, backend_version, \
-     NavigationToolbar2GTK
+     NavigationToolbar2GTK, GTK_WIDGET_DRAWABLE
 from matplotlib.backends._gtkagg import agg_to_gtk_drawable

 
@@ -48,6 +48,11 @@
     filetypes = FigureCanvasGTK.filetypes.copy()
     filetypes.update(FigureCanvasAgg.filetypes)

+    def __init__(self, *kl, **kw):
+        FigureCanvasGTK.__init__(self, *kl, **kw)
+        FigureCanvasAgg.__init__(self, *kl, **kw)
+        self.set_double_buffered(True)
+
     def configure_event(self, widget, event=None):

         if DEBUG: print 'FigureCanvasGTKAgg.configure_event'
@@ -87,6 +92,42 @@
                            gtk.gdk.RGB_DITHER_NONE, 0, 0)
         if DEBUG: print 'FigureCanvasGTKAgg.render_figure done'

+
+    def _render_figure(self, pixmap, width, height):
+
+        FigureCanvasAgg.draw(self)
+
+        buf = self.buffer_rgba(0,0)
+        ren = self.get_renderer()
+        w = int(ren.width)
+        h = int(ren.height)
+
+        pixbuf = gtk.gdk.pixbuf_new_from_data(
+            buf, gtk.gdk.COLORSPACE_RGB,  True, 8, w, h, w*4)
+        self._pixbuf = pixbuf
+
+        if DEBUG: print 'FigureCanvasGTKAgg.render_figure done'
+
+    def expose_event(self, widget, event):
+        """Expose_event for all GTK backends. Should not be overridden.
+        """
+
+        if GTK_WIDGET_DRAWABLE(self):
+            if self._need_redraw:
+                x, y, w, h = self.allocation
+                self._render_figure(None, w, h)
+                self._need_redraw = False
+
+            x, y, w, h = event.area
+            cairo_ctx = self.window.cairo_create()
+            cairo_ctx.set_source_pixbuf(self._pixbuf, 0., 0.)
+            cairo_ctx.rectangle(x, y, w, h)
+            cairo_ctx.clip()
+            cairo_ctx.paint()
+            
+        return False  # finish event propagation?
+
+
     def blit(self, bbox=None):
         if DEBUG: print 'FigureCanvasGTKAgg.blit'
         if DEBUG: print 'FigureCanvasGTKAgg.blit', self._pixmap
Index: examples/user_interfaces/embedding_in_gtkagg_w_bg.py
===================================================================
--- examples/user_interfaces/embedding_in_gtkagg_w_bg.py	(revision 0)
+++ examples/user_interfaces/embedding_in_gtkagg_w_bg.py	(revision 0)
@@ -0,0 +1,54 @@
+#!/usr/bin/env python
+"""
+show how to add a matplotlib FigureCanvasGTK or FigureCanvasGTKAgg widget and
+a toolbar to a gtk.Window
+"""
+import gtk
+
+from matplotlib.figure import Figure
+from numpy import arange, sin, pi
+
+# uncomment to select /GTK/GTKAgg/GTKCairo
+#from matplotlib.backends.backend_gtk import FigureCanvasGTK as FigureCanvas
+from matplotlib.backends.backend_gtkagg import FigureCanvasGTKAgg as FigureCanvas
+#from matplotlib.backends.backend_gtkcairo import FigureCanvasGTKCairo as FigureCanvas
+
+# or NavigationToolbar for classic
+#from matplotlib.backends.backend_gtk import NavigationToolbar2GTK as NavigationToolbar
+from matplotlib.backends.backend_gtkagg import NavigationToolbar2GTKAgg as NavigationToolbar
+
+
+win = gtk.Window()
+win.connect("destroy", lambda x: gtk.main_quit())
+win.set_default_size(400,300)
+win.set_title("Embedding in GTK")
+
+vbox = gtk.VBox()
+win.add(vbox)
+
+fig = Figure(figsize=(5,4), dpi=100, frameon=False)
+ax = fig.add_subplot(111)
+ax.patch.set_visible(False)
+
+t = arange(0.0,3.0,0.01)
+s = sin(2*pi*t)
+
+ax.plot(t,s)
+
+
+canvas = FigureCanvas(fig)  # a gtk.DrawingArea
+vbox.pack_start(canvas)
+toolbar = NavigationToolbar(canvas, win)
+vbox.pack_start(toolbar, False, False)
+
+imagename = "../data/lena.jpg"
+pixbuf = gtk.gdk.pixbuf_new_from_file(imagename)
+pixmap, mask = pixbuf.render_pixmap_and_mask()
+
+style = canvas.get_style().copy()
+style.bg_pixmap[gtk.STATE_NORMAL]=pixmap
+canvas.set_style(style)
+
+
+win.show_all()
+gtk.main()
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@...
https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Michael Droettboom | 4 Nov 14:29

Re: twin / dual / two axis seems to confuse or break toolbar magnifier

Can you be more specific about what is going wrong?  The zoom magnifier 
seems to work fine for me with or without twinx, but perhaps we just 
have different expectations of how it works.  Could you perhaps provide 
screenshots?

I'm checking against SVN trunk.  I didn't check against 0.90.1, since it 
would require installing an older version of numpy, and other dependency 
dances etc.  But I'm happy to dig further once I have a better idea of 
what is going wrong for you.

This FAQ explains how to get the version number and other useful 
information for a bug report:

http://matplotlib.sourceforge.net/faq/troubleshooting_faq.html#report-a-problem

Cheers,
Mike

wet_colored)arch wrote:
> I am trying to code an application with two checkboxes, one associated with
> each axis on a simple plot.  I can then turn on and off lines in the plot
> that are scaled either to the left side or right side of the plot.
>
> This is working fine and patterned after some of the examples from
> matplotlib.
>
> However, when I use the toolbar feature with the "magnifier" the scaling is
> not usually correct.  More specifically, if I select an area with the
> magnifier, the next drawing of the information is not scaled right. 
> (ususally it is a smaller subset of the data selected)
>
> I have confirmed when I run without twinx , the magnifier works fine.    
>
> I also have noticed that when running the example from matplotlib the same
> thing happens. I have searched a bit looking for perhaps a bug or comment in
> forums on how to workaround this or perhaps I have done something wrong, but
> no luck.  Perhaps I don't understand how the magnifier is supposed to work
> but when I disable the twinx capability of my code, things seem to work
> fine.  (I'm still mostly a noob but I am persistent.)
>
> I believe I have 0.90 or perhaps one earlier.  I wasn't completely sure how
> to check but 0.90 is shown in the __init__.py file.
>
> I have attached the matplotlib provided example that I feel doesn't work
> right.  I also have a snippet of my code below. (which is structured a bit
> different than the example but when I run identical to the snippet, using
> the structure of my code I get an error due to twinx not being a method of
> subplot - as I recall)
>
> from two scales  example provided with matplotlib
>   
>
> from pylab import *
>
> ax1 = subplot(111)
> t = arange(0.01, 10.0, 0.01)
> s1 = exp(t)
> plot(t, s1, 'b-')
> xlabel('time (s)')
> ylabel('exp')
>
>
> # turn off the 2nd axes rectangle with frameon kwarg
> ax2 = twinx()
> s2 = sin(2*pi*t)
> plot(t, s2, 'r.')
> ylabel('sin')
> ax2.yaxis.tick_right()
> show()
>
>
> snippet from my code >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>
>         self.axL=subplot(132, position=[0.2,0.1,0.6,0.8])
>         self.axR=twinx(self.axL)
>         self.rax1=subplot(131, position=[0.01, 0.10, 0.14, 0.8])
>         self.rax2=subplot(133, position=[0.85, 0.10, 0.14, 0.8])
>             
>         for key in sorted(dict):
>             if dict[key][1]<>'N':  #~ providing key to allow for skipping
> data set
>                 visibility=dict[key][2]
>                 exec("self.l%s, =
> self.ax%s.plot(glbl.fusdata%s,visible=visibility,ls=dict[key][4],color=dict[key][3])"%
> (key,dict[key][1],key))
>         
>   

--

-- 
Michael Droettboom
Science Software Branch
Operations and Engineering Division
Space Telescope Science Institute
Operated by AURA for NASA

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/

Gmane