SourceForge logo
SourceForge logo
Menu

matplotlib-users — Discussion related to using matplotlib

You can subscribe to this list here.

2003 Jan
Feb
Mar
Apr
May
(3)
Jun
Jul
Aug
(12)
Sep
(12)
Oct
(56)
Nov
(65)
Dec
(37)
2004 Jan
(59)
Feb
(78)
Mar
(153)
Apr
(205)
May
(184)
Jun
(123)
Jul
(171)
Aug
(156)
Sep
(190)
Oct
(120)
Nov
(154)
Dec
(223)
2005 Jan
(184)
Feb
(267)
Mar
(214)
Apr
(286)
May
(320)
Jun
(299)
Jul
(348)
Aug
(283)
Sep
(355)
Oct
(293)
Nov
(232)
Dec
(203)
2006 Jan
(352)
Feb
(358)
Mar
(403)
Apr
(313)
May
(165)
Jun
(281)
Jul
(316)
Aug
(228)
Sep
(279)
Oct
(243)
Nov
(315)
Dec
(345)
2007 Jan
(260)
Feb
(323)
Mar
(340)
Apr
(319)
May
(290)
Jun
(296)
Jul
(221)
Aug
(292)
Sep
(242)
Oct
(248)
Nov
(242)
Dec
(332)
2008 Jan
(312)
Feb
(359)
Mar
(454)
Apr
(287)
May
(340)
Jun
(450)
Jul
(403)
Aug
(324)
Sep
(349)
Oct
(385)
Nov
(363)
Dec
(437)
2009 Jan
(500)
Feb
(301)
Mar
(409)
Apr
(486)
May
(545)
Jun
(391)
Jul
(518)
Aug
(497)
Sep
(492)
Oct
(429)
Nov
(357)
Dec
(310)
2010 Jan
(371)
Feb
(657)
Mar
(519)
Apr
(432)
May
(312)
Jun
(416)
Jul
(477)
Aug
(386)
Sep
(419)
Oct
(435)
Nov
(320)
Dec
(202)
2011 Jan
(321)
Feb
(413)
Mar
(299)
Apr
(215)
May
(284)
Jun
(203)
Jul
(207)
Aug
(314)
Sep
(321)
Oct
(259)
Nov
(347)
Dec
(209)
2012 Jan
(322)
Feb
(414)
Mar
(377)
Apr
(179)
May
(173)
Jun
(234)
Jul
(295)
Aug
(239)
Sep
(276)
Oct
(355)
Nov
(144)
Dec
(108)
2013 Jan
(170)
Feb
(89)
Mar
(204)
Apr
(133)
May
(142)
Jun
(89)
Jul
(160)
Aug
(180)
Sep
(69)
Oct
(136)
Nov
(83)
Dec
(32)
2014 Jan
(71)
Feb
(90)
Mar
(161)
Apr
(117)
May
(78)
Jun
(94)
Jul
(60)
Aug
(83)
Sep
(102)
Oct
(132)
Nov
(154)
Dec
(96)
2015 Jan
(45)
Feb
(138)
Mar
(176)
Apr
(132)
May
(119)
Jun
(124)
Jul
(77)
Aug
(31)
Sep
(34)
Oct
(22)
Nov
(23)
Dec
(9)
2016 Jan
(26)
Feb
(17)
Mar
(10)
Apr
(8)
May
(4)
Jun
(8)
Jul
(6)
Aug
(5)
Sep
(9)
Oct
(4)
Nov
Dec
2017 Jan
(5)
Feb
(7)
Mar
(1)
Apr
(5)
May
Jun
(3)
Jul
(6)
Aug
(1)
Sep
Oct
(2)
Nov
(1)
Dec
2018 Jan
Feb
Mar
Apr
(1)
May
Jun
Jul
Aug
Sep
Oct
Nov
Dec
2020 Jan
Feb
Mar
Apr
May
(1)
Jun
Jul
Aug
Sep
Oct
Nov
Dec
2025 Jan
(1)
Feb
Mar
Apr
May
Jun
Jul
Aug
Sep
Oct
Nov
Dec
S M T W T F S

1
(2)
2
(32)
3
(26)
4
(29)
5
(41)
6
(2)
7
(1)
8
(13)
9
(15)
10
(23)
11
(23)
12
(16)
13
(6)
14
(15)
15
(4)
16
(18)
17
(28)
18
(17)
19
(11)
20
(6)
21
(2)
22
(4)
23
(1)
24
25
26
(1)
27
(2)
28
(2)
29
(3)
30
(10)
31
(2)



Showing results of 355

<< < 1 2 3 4 .. 15 > >> (Page 2 of 15)
From: fiolj <fi...@ya...> - 2012年10月21日 12:38:28
Hi, some time ago I needed the same thing and hacked the function
histogram (from numpy). Here goes my function, I hope it will result useful
Cheers,
	Juan
## Calculates the histogram allowing for overlapping bins, which are
given by
#
# @param a
# @param bins a sequence of pairs (left,right), limits for each bin
#
# @return hist (numpy array)
# bin_centers (numpy array)
def myhistogram(a, bins):
 """
 Compute the histogram of a set of data.
 Parameters
 ----------
 a : array_like
 Input data.
 bins : sequence of pairs
 It defines the bin edges (left,right), allowing for non-uniform
bin widths.
 Returns
 -------
 hist : array
 The values of the histogram. See `normed` and `weights` for a
 description of the possible semantics.
 bin_centers : array of dtype float
 Return the bin centers ``(length(hist))``.
 Notes
 -----
 All but the last (righthand-most) bin is half-open. In other words, if
 `bins` is::
 [1, 2, 3, 4]
 then the first bin is ``[1, 2)`` (including 1, but excluding 2) and the
 second ``[2, 3)``. The last bin, however, is ``[3, 4]``, which *includes*
 4.
 Examples
 --------
 >>> myhistogram([1,2,1], bins=[(0,1),(1,1.5),(1.5,2.5),(2,3)])
 (array([0.5, 1.25, 2, 2.5]), array([0, 0, 1, 2, 3]))
 """
 bins = np.asarray(bins) # bins are 2-dimensional arrays
of shape (n,2)
 if len(bins.shape) != 2 or bins.shape[1] != 2:
 raise AttributeError, 'bins must be a list/array of 2-tuples.'
 a = np.asarray(a)
 a = a.ravel()
 n = np.zeros(len(bins), int)
 block = 65536
 for i in np.arange(0, len(a), block):
 sa = np.sort(a[i:i+block])
 n += np.r_[sa.searchsorted(bins[:-1,1], 'left'),
sa.searchsorted(bins[-1,1], 'right')]\
 - np.r_[sa.searchsorted(bins[:-1,0], 'left'),
sa.searchsorted(bins[-1,0], 'right')]
 return n, (bins[:,0]+bins[:,1])/2.
Hi I am using
wxpython : 2.9.4.0
matplotlib : 1.3
osx Lion
In my application I have a number of matplotlib figure objects, one on
each page of the wx.aui.AuiNotebook .The pages are each a figure and
arranged as tabs on the top of the wxpython frame like embedding in wx5
example from the matplotlib gallery.
On Windows I can navigate from page to page of the Notebook using CTRL-TAB
and CTRL-SHIFT-TAB.
However on OSX -Lion , neither the CTRL-TAB, nor Alt/Tab navigate from
page to page.
Instead what happens is that the "mouse selection" moves from icon to icon
i.e from the "Home" to the "Pan-zoom " icon on the bottom of the matplotlib
figure. The wxAuiNotebook is oblvious of these mouse events.
Does anyone know how to restore the windows os behavior where CTRL-TAB
changes the page of the Notebook on OSX. How do I prevent the matplotlib
figure object from intercepting these events.
Thanks
Hari
From: Damon M. <dam...@gm...> - 2012年10月20日 22:46:45
All,
Several days ago I tested the waters and asked you guys, the
community, how useful you thought a command-line front-end to
matplotlib would be. The overwhelmingly positive feedback was enough
for me to sit down and figure out how to do this well, and in a way
that would mimic existing tools to achieve such tasks. One example
being the `graph` utility, which is a part of GNU plotutils. Though
there are subtle differences between mpl_binutils and GNU plotutils
they, in my opinion, improve the user experience and reduce the
ambiguity regarding the parsing of command-line options.
I am announcing that mpl_binutils is in a state ready to be tested by
you guys. Hopefully you'll find it useful. You can check out the
source code here: https://github.com/dmcdougall/mpl_binutils
Without getting into details, I ran into some serious limitations with
argparse. At the end of the day, nothing is perfect, but some tools
are better than others. One such tool, docopt, was shown to me by Mark
Lawrence. docopt will change the way I do any python from the
command-line in the future. docopt is a light-weight command-line
parsing library written in python with no dependencies.
mpl_binutils has two dependencies: docopt and matplotlib. Most of you
should already have one of these! For the other, a simple `pip install
docopt` should work but I had no problems installing it from source
(python setup.py install) on OS X. mpl_binutils is currently a single
script (a python script), called mpl-graph. There is example usage on
the github readme if you'd like to take a look.
Currently, mpl-graph doesn't fail gracefully. It should, but I wanted
to get something working first. Command-line option validation is next
on my todo list and since there are only a handful of command line
options implemented (albeit the most useful ones, in my opinion), this
shouldn't be too big of a job.
Go forth and fork!
-- 
Damon McDougall
http://www.damon-is-a-geek.com
B2.39
Mathematics Institute
University of Warwick
Coventry
West Midlands
CV4 7AL
United Kingdom
From: Damon M. <dam...@gm...> - 2012年10月20日 22:42:43
On Sat, Oct 20, 2012 at 11:37 PM, Benjamin Root <ben...@ou...> wrote:
>
>
> On Saturday, October 20, 2012, Damon McDougall wrote:
>>
>> On Sat, Oct 20, 2012 at 10:25 PM, Steven Boada <bo...@ph...>
>> wrote:
>> > It'd be cool if we could do something like
>> >
>> > bins = [(0.0,0.05,0.1),(0.05,0.1,0.15)...]
>> >
>> > Where I have specified the left edge, center and right edge of each
>> > bin. Yeah, that'd be pretty slick.
>> >
>> > S
>> >
>> > On Sat Oct 20 16:21:41 2012, Steven Boada wrote:
>> >> Let's say I generate a bunch of random numbers from 0-1. Then, I'd
>> >> like to make a histogram of it. But here's the clincher. I'd like my
>> >> bins to overlap a bit. For example, if the first bin is from 0 - 0.1,
>> >> centered on 0.05, I'd like the next (second) bin to be centered on 0.1
>> >> and range from 0.05 - 0.15.
>> >>
>> >> So basically, I want the width of each bin to be greater than the
>> >> spacing.
>> >>
>> >> Is this something that could be done with the histogram function? I
>> >> did a couple of google searches and couldn't come up with anything
>> >> meaningful. Apparently, 'rwidth' in the hist function just makes the
>> >> displayed bars bigger or smaller.
>> >>
>> >> Any thoughts?
>> >>
>> >
>> > --
>> >
>> > Steven Boada
>> >
>> > Doctoral Student
>> > Dept of Physics and Astronomy
>> > Texas A&M University
>> > bo...@ph...
>>
>> My thoughts are that this goes against everything a histogram is set
>> out to do; attempt to provide a 'discretised' probability distribution
>> function given a set of discrete samples. Lets say a sample lies in
>> the region where two bins overlap. How do you define which bin the
>> sample lies in? Both? If both, how do you define the value of the
>> approximated probability distribution on a bin? You could just take
>> the height of the bin, but some of the bin's mass lies in each of the
>> neighbouring bins.
>>
>> If you don't want to apply mass to the neighbouring bins for a sample
>> that lies in the region where two bins overlap, you could just pick
>> one. You then have the problem of non-uniqueness. If you'd picked the
>> other bin you'd have a different probability distribution function.
>> This a bad property to have.
>>
>> If you don't want to pick a neighbouring bin to apply more mass, and
>> just increase the width of the each bin's matplotlib.patches.Patch
>> object, then that is more sensible. Except now you have the problem of
>> displaying the histogram. Which bin gets displayed over its left
>> neighbour? And its right neighbour?
>>
>> I dread to think what this would imply if you also wanted to stack
>> such histograms. A potential can of worms.
>>
>
> The closest I could think of as something reasonable is to apply a
> convolution of some sort to the discrete pdf to produce an approximation of
> a continuous PDF.
>
> Cheers!
> Ben Root
Yes. That's possible. The issue here, though, is getting the discrete
case to start with. There are multiple ways to do it depending on your
choice of bin, and the result is not independent of this choice.
-- 
Damon McDougall
http://www.damon-is-a-geek.com
B2.39
Mathematics Institute
University of Warwick
Coventry
West Midlands
CV4 7AL
United Kingdom
From: Benjamin R. <ben...@ou...> - 2012年10月20日 22:37:10
On Saturday, October 20, 2012, Damon McDougall wrote:
> On Sat, Oct 20, 2012 at 10:25 PM, Steven Boada <bo...@ph...<javascript:;>>
> wrote:
> > It'd be cool if we could do something like
> >
> > bins = [(0.0,0.05,0.1),(0.05,0.1,0.15)...]
> >
> > Where I have specified the left edge, center and right edge of each
> > bin. Yeah, that'd be pretty slick.
> >
> > S
> >
> > On Sat Oct 20 16:21:41 2012, Steven Boada wrote:
> >> Let's say I generate a bunch of random numbers from 0-1. Then, I'd
> >> like to make a histogram of it. But here's the clincher. I'd like my
> >> bins to overlap a bit. For example, if the first bin is from 0 - 0.1,
> >> centered on 0.05, I'd like the next (second) bin to be centered on 0.1
> >> and range from 0.05 - 0.15.
> >>
> >> So basically, I want the width of each bin to be greater than the
> >> spacing.
> >>
> >> Is this something that could be done with the histogram function? I
> >> did a couple of google searches and couldn't come up with anything
> >> meaningful. Apparently, 'rwidth' in the hist function just makes the
> >> displayed bars bigger or smaller.
> >>
> >> Any thoughts?
> >>
> >
> > --
> >
> > Steven Boada
> >
> > Doctoral Student
> > Dept of Physics and Astronomy
> > Texas A&M University
> > bo...@ph... <javascript:;>
>
> My thoughts are that this goes against everything a histogram is set
> out to do; attempt to provide a 'discretised' probability distribution
> function given a set of discrete samples. Lets say a sample lies in
> the region where two bins overlap. How do you define which bin the
> sample lies in? Both? If both, how do you define the value of the
> approximated probability distribution on a bin? You could just take
> the height of the bin, but some of the bin's mass lies in each of the
> neighbouring bins.
>
> If you don't want to apply mass to the neighbouring bins for a sample
> that lies in the region where two bins overlap, you could just pick
> one. You then have the problem of non-uniqueness. If you'd picked the
> other bin you'd have a different probability distribution function.
> This a bad property to have.
>
> If you don't want to pick a neighbouring bin to apply more mass, and
> just increase the width of the each bin's matplotlib.patches.Patch
> object, then that is more sensible. Except now you have the problem of
> displaying the histogram. Which bin gets displayed over its left
> neighbour? And its right neighbour?
>
> I dread to think what this would imply if you also wanted to stack
> such histograms. A potential can of worms.
>
>
The closest I could think of as something reasonable is to apply a
convolution of some sort to the discrete pdf to produce an approximation of
a continuous PDF.
Cheers!
Ben Root
From: Damon M. <dam...@gm...> - 2012年10月20日 21:50:24
On Sat, Oct 20, 2012 at 10:25 PM, Steven Boada <bo...@ph...> wrote:
> It'd be cool if we could do something like
>
> bins = [(0.0,0.05,0.1),(0.05,0.1,0.15)...]
>
> Where I have specified the left edge, center and right edge of each
> bin. Yeah, that'd be pretty slick.
>
> S
>
> On Sat Oct 20 16:21:41 2012, Steven Boada wrote:
>> Let's say I generate a bunch of random numbers from 0-1. Then, I'd
>> like to make a histogram of it. But here's the clincher. I'd like my
>> bins to overlap a bit. For example, if the first bin is from 0 - 0.1,
>> centered on 0.05, I'd like the next (second) bin to be centered on 0.1
>> and range from 0.05 - 0.15.
>>
>> So basically, I want the width of each bin to be greater than the
>> spacing.
>>
>> Is this something that could be done with the histogram function? I
>> did a couple of google searches and couldn't come up with anything
>> meaningful. Apparently, 'rwidth' in the hist function just makes the
>> displayed bars bigger or smaller.
>>
>> Any thoughts?
>>
>
> --
>
> Steven Boada
>
> Doctoral Student
> Dept of Physics and Astronomy
> Texas A&M University
> bo...@ph...
My thoughts are that this goes against everything a histogram is set
out to do; attempt to provide a 'discretised' probability distribution
function given a set of discrete samples. Lets say a sample lies in
the region where two bins overlap. How do you define which bin the
sample lies in? Both? If both, how do you define the value of the
approximated probability distribution on a bin? You could just take
the height of the bin, but some of the bin's mass lies in each of the
neighbouring bins.
If you don't want to apply mass to the neighbouring bins for a sample
that lies in the region where two bins overlap, you could just pick
one. You then have the problem of non-uniqueness. If you'd picked the
other bin you'd have a different probability distribution function.
This a bad property to have.
If you don't want to pick a neighbouring bin to apply more mass, and
just increase the width of the each bin's matplotlib.patches.Patch
object, then that is more sensible. Except now you have the problem of
displaying the histogram. Which bin gets displayed over its left
neighbour? And its right neighbour?
I dread to think what this would imply if you also wanted to stack
such histograms. A potential can of worms.
-- 
Damon McDougall
http://www.damon-is-a-geek.com
B2.39
Mathematics Institute
University of Warwick
Coventry
West Midlands
CV4 7AL
United Kingdom
From: Steven B. <bo...@ph...> - 2012年10月20日 21:25:23
It'd be cool if we could do something like
bins = [(0.0,0.05,0.1),(0.05,0.1,0.15)...]
Where I have specified the left edge, center and right edge of each 
bin. Yeah, that'd be pretty slick.
S
On Sat Oct 20 16:21:41 2012, Steven Boada wrote:
> Let's say I generate a bunch of random numbers from 0-1. Then, I'd
> like to make a histogram of it. But here's the clincher. I'd like my
> bins to overlap a bit. For example, if the first bin is from 0 - 0.1,
> centered on 0.05, I'd like the next (second) bin to be centered on 0.1
> and range from 0.05 - 0.15.
>
> So basically, I want the width of each bin to be greater than the
> spacing.
>
> Is this something that could be done with the histogram function? I
> did a couple of google searches and couldn't come up with anything
> meaningful. Apparently, 'rwidth' in the hist function just makes the
> displayed bars bigger or smaller.
>
> Any thoughts?
>
--
Steven Boada
Doctoral Student
Dept of Physics and Astronomy
Texas A&M University
bo...@ph...
From: Steven B. <bo...@ph...> - 2012年10月20日 21:21:48
Let's say I generate a bunch of random numbers from 0-1. Then, I'd like 
to make a histogram of it. But here's the clincher. I'd like my bins to 
overlap a bit. For example, if the first bin is from 0 - 0.1, centered 
on 0.05, I'd like the next (second) bin to be centered on 0.1 and range 
from 0.05 - 0.15.
So basically, I want the width of each bin to be greater than the spacing.
Is this something that could be done with the histogram function? I did 
a couple of google searches and couldn't come up with anything 
meaningful. Apparently, 'rwidth' in the hist function just makes the 
displayed bars bigger or smaller.
Any thoughts?
-- 
Steven Boada
Doctoral Student
Dept of Physics and Astronomy
Texas A&M University
bo...@ph...
From: elmar w. <el...@ne...> - 2012年10月19日 21:51:57
Am 19.10.2012 23:26, schrieb Damon McDougall:
> Correct me if I'm wrong, but I don't even think you need them. I think
> the default cmap behaviour is to normalise to the min and max of the
> data.
yes, default cmap behaviour will normalise to the min and max of the
data.
From: Damon M. <dam...@gm...> - 2012年10月19日 21:26:12
On Fri, Oct 19, 2012 at 10:23 PM, Daπid <dav...@gm...> wrote:
> On Fri, Oct 19, 2012 at 11:08 PM, elmar werling <el...@ne...> wrote:
>> vmin=min(z), vmax=max(z)
>
> A suggestion, when dealing with arrays, it is generally faster to use
> the numpy function to compute the max and min, either np.max(z) or
> z.max(), than the standard Python one.
Correct me if I'm wrong, but I don't even think you need them. I think
the default cmap behaviour is to normalise to the min and max of the
data.
-- 
Damon McDougall
http://www.damon-is-a-geek.com
B2.39
Mathematics Institute
University of Warwick
Coventry
West Midlands
CV4 7AL
United Kingdom
From: Daπid <dav...@gm...> - 2012年10月19日 21:24:05
On Fri, Oct 19, 2012 at 11:08 PM, elmar werling <el...@ne...> wrote:
> vmin=min(z), vmax=max(z)
A suggestion, when dealing with arrays, it is generally faster to use
the numpy function to compute the max and min, either np.max(z) or
z.max(), than the standard Python one.
From: elmar w. <el...@ne...> - 2012年10月19日 21:19:16
thanks for help,
finally I found the following solution
elmar
import numpy as np
import matplotlib as mpl
import matplotlib.pyplot as plt
N = 200
x = np.linspace(0,1,N)
y = np.random.randn(N)
z = np.random.randn(N)*2+5
cm = mpl.cm.get_cmap('RdYlBu')
sc = plt.scatter(x, y, c=z, vmin=min(z), vmax=max(z), s=35, cmap=cm)
plt.colorbar(sc)
plt.show()
Am 19.10.2012 21:59, schrieb Joe Kington:
> plt.scatter(x, y, c=z, marker='s')
> plt.colorbar()
From: Joe K. <jki...@wi...> - 2012年10月19日 19:59:25
That's what ``scatter`` is intended for.
Basically, you want something like:
 plt.scatter(x, y, c=z, marker='s')
 plt.colorbar()
Note that you can also vary the markers by size based on an additional
parameter, as well.
Have a look at this example:
http://matplotlib.org/examples/pylab_examples/scatter_demo.html
Hope that helps,
-Joe
On Fri, Oct 19, 2012 at 2:19 PM, elmar werling <el...@ne...> wrote:
> Hi,
>
> is there a way to adjust the marker color in a xy-plot in relation to
> the value of a third parameter. Something as the following - not working
> - example 1.
>
> Example 2 is working but rather slow for large arrays.
>
> cheers
> Elmar
>
>
>
>
> # example 1
>
> import matplotlib.pyplot as plt
>
> x = [1,2,3,4]
> y = x
> c = ((1.0, 0.0, 0.0), (0.8, 0.1, 0.1), (0.6, 0.2, 0.6), (0.4, 0.3, 0.3))
>
> plt.plot(x,y, color=c, marker='s')
> plt.show()
>
>
> example 2:
>
> import matplotlib.pyplot as plt
>
> x = [1,2,3,4]
> y = x
> c = ((1.0, 0.0, 0.0), (0.8, 0.1, 0.1), (0.6, 0.2, 0.6), (0.4, 0.3, 0.3))
>
> for i in range(len(x)):
> plt.plot(x[i], y[i], color=c[i], marker='s')
>
> plt.show()
>
>
>
> ------------------------------------------------------------------------------
> Everyone hates slow websites. So do we.
> Make your web apps faster with AppDynamics
> Download AppDynamics Lite for free today:
> http://p.sf.net/sfu/appdyn_sfd2d_oct
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
From: elmar w. <el...@ne...> - 2012年10月19日 19:17:41
Hi,
is there a way to adjust the marker color in a xy-plot in relation to 
the value of a third parameter. Something as the following - not working 
- example 1.
Example 2 is working but rather slow for large arrays.
cheers
Elmar
# example 1
import matplotlib.pyplot as plt
x = [1,2,3,4]
y = x
c = ((1.0, 0.0, 0.0), (0.8, 0.1, 0.1), (0.6, 0.2, 0.6), (0.4, 0.3, 0.3))
plt.plot(x,y, color=c, marker='s')
plt.show()
example 2:
import matplotlib.pyplot as plt
x = [1,2,3,4]
y = x
c = ((1.0, 0.0, 0.0), (0.8, 0.1, 0.1), (0.6, 0.2, 0.6), (0.4, 0.3, 0.3))
for i in range(len(x)):
 plt.plot(x[i], y[i], color=c[i], marker='s')
plt.show()
From: Phil E. <pel...@gm...> - 2012年10月19日 15:35:01
Good idea. If the png version works then the jpg version should also be
made to work,
Would you be willing to open up an issue for the feature request? :
https://github.com/matplotlib/matplotlib/issues/new
If your ready and willing to implement such a thing, that would be even
better (just open a pull request and we can start reviewing)!
All the best,
Phil
On 19 October 2012 15:59, Rich Signell <rsi...@us...> wrote:
> MPL folks,
>
> Would it be possible to enhance Matplotlib to allow "im=imread(url)"
> to work if url returns a JPG?
>
> Currently (it seems):
>
> 1. If the URL returns a PNG this works:
>
> im = imread(urllib2.urlopen(url))
>
> 2. If the URL returns a JPG, this DOESN'T work:
>
> im = imread(urllib2.urlopen(url))
>
> .. and neither does this:
> im = imread(urllib2.urlopen(url),format='jpg')
>
> ... but this DOES work:
>
> im = Image.open(cStringIO.StringIO(urllib.urlopen(url).read()))
>
> See an example in Ipython Notebook here:
> http://nbviewer.ipython.org/3918576/
>
> So could just be hidden from the user so that "im = imread(url)" would
> just work for JPG (assuming PIL was installed)?
>
> Thanks,
> Rich
> --
> Dr. Richard P. Signell
> USGS, 384 Woods Hole Rd.
> Woods Hole, MA 02543-1598
>
>
> ------------------------------------------------------------------------------
> Everyone hates slow websites. So do we.
> Make your web apps faster with AppDynamics
> Download AppDynamics Lite for free today:
> http://p.sf.net/sfu/appdyn_sfd2d_oct
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
From: Pierre H. <pie...@cr...> - 2012年10月19日 15:11:29
Hi,
Le 19/10/2012 06:48, Jae-Joon Lee a écrit :
> Figuring out the dpi of the screen, I have no clue at this moment.
> Maybe this is something a gui expert can answer.
I'm certainly not a gui expert, but as a PyQt user, I know screen
resolution is indeed Python-accessible with PyQt. (I guess other
toolkits provide their own methods)
I've made a quick script that prints the screen X and Y resolution
(requires PyQt). Reference links to PyQt API docs are included.
In my case, it's 96 dpi, and that what I use in my matplotlibrc file for
the "figure.dpi" property. But I use a higher value (say 150) for
"savefig.dpi" so that I get better resolution when saving PNG images.
I agree with Nikolaus that the dpi value for displaying figures would be
better get by the software, if possible. Maybe a property like
figure.dpi='auto' should activate such a behavior. But this would
require many code duplicates, one for each gui toolkit.
Best,
Pierre
From: Rich S. <rsi...@us...> - 2012年10月19日 14:59:18
MPL folks,
Would it be possible to enhance Matplotlib to allow "im=imread(url)"
to work if url returns a JPG?
Currently (it seems):
1. If the URL returns a PNG this works:
im = imread(urllib2.urlopen(url))
2. If the URL returns a JPG, this DOESN'T work:
im = imread(urllib2.urlopen(url))
.. and neither does this:
im = imread(urllib2.urlopen(url),format='jpg')
... but this DOES work:
im = Image.open(cStringIO.StringIO(urllib.urlopen(url).read()))
See an example in Ipython Notebook here:
http://nbviewer.ipython.org/3918576/
So could just be hidden from the user so that "im = imread(url)" would
just work for JPG (assuming PIL was installed)?
Thanks,
Rich
-- 
Dr. Richard P. Signell
USGS, 384 Woods Hole Rd.
Woods Hole, MA 02543-1598
From: Jae-Joon L. <lee...@gm...> - 2012年10月19日 04:49:04
> Yeah, that's what I feared. But in the mean time, are there any best
> practices to minimize undesired effects like the one above? For example,
> are there any other functions that need special parameters to not raster
> their output when writing to a vector format? And is there a way to get
> a figure on the screen with the right size when I don't know what dpi
> the monitor is running with?
As I said, if you use interpolation="none" with your inshow, the
original image will be sent to the backends.
Figuring out the dpi of the screen, I have no clue at this moment.
Maybe this is something a gui expert can answer.
Regards,
-JJ
From: Jae-Joon L. <lee...@gm...> - 2012年10月19日 04:36:56
On Tue, Oct 16, 2012 at 4:04 PM, T J <tj...@gm...> wrote:
> I'm interested in clipping the result of plt.contour (and
> plt.contourf) to a patch. However, QuadContourSet does not have a
> set_clip_path() method. Is there a way to do this?
QuadContourSet does not (I think it should), but LineCollection
instances in QuadContourSet.collections does. Below is a quick
example.
import matplotlib.pyplot as plt
import numpy as np
x = np.arange(100)-50
arr = (x**2 + x[:,np.newaxis]**2)**.5
cont = plt.contour(arr)
col1 = cont.collections[3] # contour line to clip with.
clip_path = col1.get_paths()[0] # Note that col1 may have multiple paths.
for col in cont.collections:
 col.set_clip_path(clip_path, col1.get_transform()) # set clip_path
for individual LineCollection instances.
plt.show()
From: Paul T. <pau...@gm...> - 2012年10月18日 23:24:21
On 10/18/12 5:45 AM, Damon McDougall wrote:
> On Thu, Oct 18, 2012 at 10:10 AM, Alexander Eberspaecher
> <ale...@ov...> wrote:
>> Hello,
>>
>> On 2012年10月17日 11:38:27 +0100
>> Damon McDougall <dam...@gm...> wrote:
>>
>>> How do people feel about perhaps adding a matplotlib version, mocking
>>> the same calling signature as graph?
>>>
>>> I think the most important question is: would it be useful?
>> Yes, this would certainly be useful! I think there are people
>> unfamiliar with Python, but rather excited about MPL's plotting
>> capabilities.
>>
>> I personally would want it to read data from white-space separated text
>> files (np.loadtxt()), probably CSV files, and HDF5 files (e.g. using
>> h5py, if available).
>>
>> To be useful for different purposes, I'd want the tool to be able to use
>> different backends (producing e.g. PNG output in case you need a figure
>> to send via e-mail or PGF output in case you are preparing a LaTeX
>> document). Matplotlibrc should be hidden from the user.
>>
>> As Gnuplot was specifically mentioned in another e-mail in this thread,
>> let me use that opportunity to mention that MPL falls behind Gnuplot in
>> terms of line styles. Using MPL, I found ls="-" and maybe ls="--" to be
>> useful, whereas Gnuplot offers 9 linestyles that are easy to
>> distinguish visually. Compare e.g. the figure linked in
>> http://www.der-schnorz.de/2010/09/gnuplot-colors-presentations-papers-and-contrast/
>> In case this is of general interest, we might discuss that in a new
>> thread.
>>
>> As a side note, personally, for text file visualisation, I often use
>> this dirty MPL plotting plugin for the text editor of my choice (Geany):
>> https://github.com/aeberspaecher/GeanyPlot
>> A command line tool would of course be preferred.
>>
>> Cheers
>>
>> Alex
> Ok wow, awesome feedback! I started on this yesterday morning to see
> how it would go, and I've already got something working that mimics
> the command-line syntax of GNU's `graph` (except it currently only
> supports one data file as input).
>
> I'm currently just developing on a local feature branch in the
> matplotlib repository, but I'm happy to pull it out to a different
> repo and announce it here once I make some more ground on it. I
> haven't pushed anything yet. If I do I'll make an announcement here.
>
> One thing I have noticed is that GNU's `graph` is rather fast.
> Compared to matplotlib, GNU's `graph` blows matplotlib out of the
> water when it comes to speed. Though, in my opinion, matplotlib wins
> when it comes to output quality. As far as I'm concerned, quality wins
> over speed but I realise that there needs to be some speed
> improvements in matplotlib's backends. I have noticed that text takes
> quite a while to process in the backend (currently using Agg for PDF
> and PNG output).
>
> Regarding input data file-type, I agree, supporting those formats
> would expand our userbase considerably. There are already some helper
> functions in matplotlib.cbook for reading csv-type files. One downside
> of supporting lots of different file-types is that there will be more
> (optional) dependencies.
>
>
Along these lines, it would be nice to have some built in data sets to 
show off matplotlib's features--maybe just another library with a bunch 
of CSV strings, or lists. I am thinking of the built-in data sets for R 
that allow a new user to experiment without having to make up data each 
time. Although, I see that already I am suggesting more unneeded 
complexities into something that should be simple. Just a thought.
Paul
From: Damon M. <dam...@gm...> - 2012年10月18日 20:25:22
On Thu, Oct 18, 2012 at 8:13 PM, Mark Lawrence <bre...@ya...> wrote:
> On 18/10/2012 12:54, Alexander Eberspaecher wrote:
>> On 2012年10月18日 10:45:24 +0100
>> Damon McDougall <dam...@gm...> wrote:
>>
>>
>> Using e.g. optparse, multiple data files shouldn't be too complicated.
>>
>
> For the record optparse is deprecated so use argparse. This might also
> be helpful http://www.youtube.com/watch?v=pXhcPJK5cMc, my apologies if
> it's already been mentioned.
>
> --
> Cheers.
>
> Mark Lawrence.
Oh. My. God. That is unworldly.
\begin{opinons}
optparse is awful, and deprecated
argparse is better, but has *serious* limitations
getopt is also pretty bad
\end{opinions}
Thank you *so* much for posting that.
-- 
Damon McDougall
http://www.damon-is-a-geek.com
B2.39
Mathematics Institute
University of Warwick
Coventry
West Midlands
CV4 7AL
United Kingdom
From: Eric F. <ef...@ha...> - 2012年10月18日 19:20:07
On 2012年10月18日 8:54 AM, Michael Aye wrote:
> On 2012年10月18日 05:58:46 +0000, Eric Firing said:
>
>> On 2012年10月17日 6:13 PM, Michael Aye wrote:
>>> I am using matplotlib 1.1.0 that came with the current EPD, which in
>>> turn comes without pygtk.
>>>
>>> However, the linux system I am using this on (CentOS6) has pygtk installed:
>>>
>>> /usr/lib64/pygtk/2.0
>>>
>>> Is there any change I can marry those two? Currently, when I try to
>>> matplotlib.use('gtk')
>>> I get an error
>>> ImportError("Gtk* backend requires pygtk to be installed.")
>>>
>>> Or do I need to recompile it into this matplotlib?
>>
>> Yes, you need to recompile. It will need to compile _backend_gdk.c,
>> which needs to be able to find pygtk.h.
>>
>> The plain (non-agg) gtk backend is basically unmaintained and its use is
>> discouraged.
>
> And the GTKAgg backend would have the same constraints as my current
> WxAgg, correct?
Correct. I take it you have tried with WxAgg, and run into the limitation?
>
>> Are you sure there isn't a reasonably easy way to do what
>> you need with qt4agg, for example? How do you want to visualize your
>> million points?
>
> Obviously there isn't place for displaying 1 million points, so I would
> expect the backend to do averaging/rebinninig/down-sampling of my data,
> depending on the current zoom level, meaning when I zoom in, it should
> repeat the averaging/rebinning/downsampling, optimized for the
> currently displayed data range. I'm aware and very willing to accept
> the delays this implies for display, but this would still be so much
> more comfortable then to write my own downsampling routines.
> I would believe that many believe would agree to the simplest averaging
> routines, if only it would be possible to display large data sets at
> all.
Mpl does some of this, for some plot types, at two levels. One is path 
simplification, in which points on a line that don't change the way the 
line would be displayed are deleted before being fed to agg. The second 
is slicing in the x domain when plotting a small range of a long time 
series. Both of these things are quite general and impose little or no 
penalty.
We are certainly open to suggestions for additional ways of handling 
large data sets, but finding methods that are general, fast, and 
guaranteed not to change the plot in a visually detectable way is not 
trivial.
I suspect a solution might be to provide a hook for a data subsetting 
callable, which could be supplied via a kwarg. This would allow the 
user to set the resolution versus speed tradeoff, to choose averaging 
versus subsampling, etc. mpl might then provide a few such callables, 
probably as classes with a __call__ method, and the user would be free 
to provide a custom callable optimized for a particular type of data and 
plot.
Eric
>
> Michael
>
>
>>
>> Eric
>>
>>>
>>> Thanks for your help!
>>>
>>> Michael
>>>
>>> PS.: The reason why I want to try GTK is actually that there are
>>> reports of it being able to cope with 1 million data points, something
>>> all other Agg-related backends can not do, apparently. (My linux is
>>> server is definitely not the limit ;)
From: Mark L. <bre...@ya...> - 2012年10月18日 19:13:45
On 18/10/2012 12:54, Alexander Eberspaecher wrote:
> On 2012年10月18日 10:45:24 +0100
> Damon McDougall <dam...@gm...> wrote:
>
>
> Using e.g. optparse, multiple data files shouldn't be too complicated.
>
For the record optparse is deprecated so use argparse. This might also 
be helpful http://www.youtube.com/watch?v=pXhcPJK5cMc, my apologies if 
it's already been mentioned.
-- 
Cheers.
Mark Lawrence.
From: Michael A. <kmi...@gm...> - 2012年10月18日 18:55:00
On 2012年10月18日 05:58:46 +0000, Eric Firing said:
> On 2012年10月17日 6:13 PM, Michael Aye wrote:
>> I am using matplotlib 1.1.0 that came with the current EPD, which in
>> turn comes without pygtk.
>> 
>> However, the linux system I am using this on (CentOS6) has pygtk installed:
>> 
>> /usr/lib64/pygtk/2.0
>> 
>> Is there any change I can marry those two? Currently, when I try to
>> matplotlib.use('gtk')
>> I get an error
>> ImportError("Gtk* backend requires pygtk to be installed.")
>> 
>> Or do I need to recompile it into this matplotlib?
> 
> Yes, you need to recompile. It will need to compile _backend_gdk.c,
> which needs to be able to find pygtk.h.
> 
> The plain (non-agg) gtk backend is basically unmaintained and its use is
> discouraged.
And the GTKAgg backend would have the same constraints as my current 
WxAgg, correct?
> Are you sure there isn't a reasonably easy way to do what
> you need with qt4agg, for example? How do you want to visualize your
> million points?
Obviously there isn't place for displaying 1 million points, so I would 
expect the backend to do averaging/rebinninig/down-sampling of my data, 
depending on the current zoom level, meaning when I zoom in, it should 
repeat the averaging/rebinning/downsampling, optimized for the 
currently displayed data range. I'm aware and very willing to accept 
the delays this implies for display, but this would still be so much 
more comfortable then to write my own downsampling routines.
I would believe that many believe would agree to the simplest averaging 
routines, if only it would be possible to display large data sets at 
all.
Michael
> 
> Eric
> 
>> 
>> Thanks for your help!
>> 
>> Michael
>> 
>> PS.: The reason why I want to try GTK is actually that there are
>> reports of it being able to cope with 1 million data points, something
>> all other Agg-related backends can not do, apparently. (My linux is
>> server is definitely not the limit ;)
>> 
>> 
>> 
>> 
>> ------------------------------------------------------------------------------
>> Everyone hates slow websites. So do we.
>> Make your web apps faster with AppDynamics
>> Download AppDynamics Lite for free today:
>> http://p.sf.net/sfu/appdyn_sfd2d_oct
>> _______________________________________________
>> Matplotlib-users mailing list
>> Mat...@li...
>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>> 
> 
> 
> ------------------------------------------------------------------------------
> Everyone hates slow websites. So do we.
> Make your web apps faster with AppDynamics
> Download AppDynamics Lite for free today:
> http://p.sf.net/sfu/appdyn_sfd2d_oct
From: Gökhan S. <gok...@gm...> - 2012年10月18日 16:19:02
On Thu, Oct 18, 2012 at 2:09 AM, Jouni K. Seppänen <jk...@ik...> wrote:
> Gökhan Sever <gok...@gm...>
> writes:
>
> > Another point I noticed is setting linewidth to 0 (in fill_between
> > function) isn't working as expected when figure is saved as a PDF
> > file.
>
> A workaround is to add edgecolor='None' to the fill_between call.
This workaround resolves the issue here. Thanks Jouni.

Showing results of 355

<< < 1 2 3 4 .. 15 > >> (Page 2 of 15)
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.
Thanks for helping keep SourceForge clean.
X





Briefly describe the problem (required):
Upload screenshot of ad (required):
Select a file, or drag & drop file here.
Screenshot instructions:

Click URL instructions:
Right-click on the ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)

More information about our ad policies

Ad destination/click URL:

AltStyle によって変換されたページ (->オリジナル) /