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
|
|
From: Andreas H. <li...@hi...> - 2012-10-27 08:09:27
|
Hi, maybe matplotlib is capable of doing this: I have two gridded datasets, A and B, for say Europe. Now I want to plot a 3d surface with the z-values given by dataset A. The surface should be colored using a given color palette and the values from dataset B. Any ideas on how to do this are greatly appreciated =) Cheers, Andreas. |
|
From: Jody K. <jk...@uv...> - 2012-10-27 04:01:09
|
Hi all,
So I figured out the magic of "rasterized=True", which is *really* helpful!
However, the colorbar doesn't seem to accept rasterized=True, so there are little lines every facet (zoom on the attached pdf). Is there another way to get the colorbar colors rasterized?
Thanks Jody
x = linspace(0,1,1000)
X = outer(x,x)
pcolormesh(X,cmap=get_cmap('RdBu_r',lut=32),rasterized=True)
colorbar()
savefig('Test.pdf',dpi=50)
|
|
From: Chloe L. <ch...@be...> - 2012-10-26 17:49:18
|
Chloe Lewis PhD candidate, Harte Lab Division of Ecosystem Sciences, ESPM University of California, Berkeley 137 Mulford Hall Berkeley, CA 94720 ch...@be... Begin forwarded message: > From: Chloe Lewis <ch...@be...> > Subject: Re: [Matplotlib-users] how to express statistical data in colors > Date: October 26, 2012 10:47:54 AM PDT > To: ra...@0x... > > you'll be doing something like the second color bar, but making the boundary and color definitions a lot more flexible. Where the discrete color bar uses > > cmap = mpl.colors.ListedColormap(['r', 'g', 'b', 'c']) > bounds = [1, 2, 4, 7, 8] > you'll be making a whole LinearSegmentedColormap, see > http://matplotlib.org/api/colors_api.html#matplotlib.colors.LinearSegmentedColormap > and check out specifically the ascii-art explanation of interpolation between row[i] and row[i+1]. Red, green, blue will break based on your data density and how you want to express 'intensity'. And depending on whether you'll make it red-green-colorblindness neutral! > Interesting problem. Has it been implemented in some other software? > > Chloe Lewis > PhD candidate, Harte Lab > Division of Ecosystem Sciences, ESPM > University of California, Berkeley > 137 Mulford Hall > Berkeley, CA 94720 > ch...@be... > |
|
From: <ra...@0x...> - 2012-10-23 08:14:09
|
hi, I'd like to present data in a colorbar-style graphic. The data to plot is in this form: [1,2,4,4,4.1,4.3,6,7]. The colorbar with this data should show at the begin the color with low intensity. In more or less the middle of the colorbar the intensity should be much more because there are a lot values around 4-4.3 and at the end the intensity should be low again. I imagine low to middle intensity to show with the color blue and high intensity with nearly by or with the color black. With colobar-style I mean this: http://matplotlib.org/examples/api/colorbar_only.html (the first bar). I assume matplotlib already provides such a method I cant find.. so any input is welcome:) thank you |
|
From: troyrock <tro...@ro...> - 2012-10-22 23:22:25
|
I figured out the problem. I need to call self.canvas.draw() in order to update the image. Sorry for the email. -- View this message in context: http://matplotlib.1069221.n5.nabble.com/Would-like-to-update-visible-plot-using-pyside-and-matplotlib-tp39576p39577.html Sent from the matplotlib - users mailing list archive at Nabble.com. |
|
From: troyrock <tro...@ro...> - 2012-10-22 23:04:27
|
I have a tool to show information extracted from various experiments and then
stored in a database. I would like to update a plot shown in the lower half
of the window when information such as the ranges of variables are modified
in the upper half. I can initially put data into the plot, however when I
want to change the contents (such as add another line to the plot), the
changes don't get displayed. Here is some code to illustrate the problem:
import matplotlib
matplotlib.rcParams['backend.qt4'] = 'PySide'
import matplotlib.pyplot as plt
from matplotlib.figure import Figure
matplotlib.use('Qt4Agg')
from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as
FigureCanvas
from PySide import QtCore, QtGui
import sys
class TabDialog(QtGui.QDialog):
def __init__(self):
super(TabDialog, self).__init__()
tabWidget = QtGui.QTabWidget()
tabWidget.addTab(AnalyzeTab(), self.tr("Analyze"))
buttonLayout = QtGui.QHBoxLayout()
saveButton = QtGui.QPushButton(self.tr("Update"))
saveButton.clicked[bool].connect(self.update)
buttonLayout.addWidget(saveButton)
mainLayout = QtGui.QVBoxLayout()
mainLayout.addWidget(tabWidget)
mainLayout.addLayout(buttonLayout)
self.setLayout(mainLayout)
def update(self):
data.update()
class DataHolder():
def __init__(self):
self.gFig = Figure()
self.ax = self.gFig.add_subplot(111)
self.ax.plot([1,2,4,0.1])
self.canvas = FigureCanvas(self.gFig)
def update(self):
self.ax.plot([8,6,4,2])
class AnalyzeTab(QtGui.QWidget):
def __init__(self, parent=None):
QtGui.QWidget.__init__(self, parent)
analyzeLayout = QtGui.QGridLayout()
analyzeLayout.addWidget(data.canvas, 2, 0, 6, 8)
self.setLayout(analyzeLayout)
if __name__ == "__main__":
app = QtGui.QApplication(sys.argv)
data = DataHolder()
tabdialog = TabDialog()
tabdialog.show()
sys.exit(app.exec_())
Any suggestions are very much appreciated.
--
View this message in context: http://matplotlib.1069221.n5.nabble.com/Would-like-to-update-visible-plot-using-pyside-and-matplotlib-tp39576.html
Sent from the matplotlib - users mailing list archive at Nabble.com.
|
|
From: fiolj <fi...@ya...> - 2012-10-22 17:00:55
|
Hi, some time ago I needed the same thing and hacked the function
histogram (from numpy or matplo. Here goes my function
## 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.
|
|
From: Larry C. <lar...@gm...> - 2012-10-22 15:55:36
|
Hi I have been doing some work that generates a lot of plots and since the plots were taking a long time I looked into to whether I could speed up the process. I found some information on how I might improve things from the following link: http://stackoverflow.com/questions/11688318/how-to-speed-up-matplotlib-when-plotting-and-saving-lots-of-figureswhich showa that you can speed things up by using the same axes and simply updating the line data. When I adapted this idea to my plots I noticed that, though the plot loop was quicker my script was running slower. I wrote a code snippet to repeat the problem - shown below: #!/usr/bin/env python import os, matplotlib, time matplotlib.use('TkAgg') import matplotlib.pyplot as plt import numpy as np from cmpactionresultsbetweenviews_1 import getPlotHtml allActionPlotLists = [[0, 1, 2 , 3, 4, 5, 6, 7, 8, 9], [ 10, 11, 12, 13, 14, 15, 16, 17, 18, 19], [9,8,7,6,5,4,3,2,1,0], [19,18,17,16,15,14,13,12,11,10]] allActionLegendsLists = [str(i) for i in range(len(allActionPlotLists[0]))] legendProps={'labelspacing':0.5, 'prop':{'size':8}} colours=['b+-', 'r+-', 'g+-', 'k+-', 'c+-', 'm+-', 'bD:', 'rD:', 'gD:', 'kD:'] fig = plt.figure() ax = None plotlines = [None for i in range(len(allActionPlotLists))] savedir = "tmpRes" if not os.path.exists(savedir): os.makedirs(savedir) figSrcFnRoot = "plotFil" fil = open(os.path.join(savedir, "savepng.html"), 'w') xlabel = "x label" ylabel = "values" colours=['b+-', 'r+-', 'g+-', 'k+-', 'c+-', 'm+-', 'bD:', 'rD:', 'gD:', 'kD:'] for i in range(20): start_plot_time = time.time() plottitle = "Plot %d" % (i) fig.suptitle("") fig.suptitle(plottitle) for subPltIdx in range(len(allActionPlotLists)): li = allActionPlotLists[subPltIdx] if ax == None: ax = fig.add_subplot(1,1,1) ax.set_xlabel(xlabel) ax.set_ylabel(ylabel) if plotlines[subPltIdx] == None: ax.set_xlabel(xlabel) ax.set_ylabel(ylabel) plotlines[subPltIdx] = ax.plot(range(len(li)), li, colours[subPltIdx])[0] else: plotlines[subPltIdx].set_ydata(li) plotlines[subPltIdx].set_xdata(range(len(li))) fig.legend(plotlines, allActionLegendsLists, labelspacing=0.5, prop=legendProps['prop']) # **** change the above line for the one below and the increasing save time problem goes away #ax.legend(plotlines, allActionLegendsLists, labelspacing=0.5, prop=legendProps['prop']) print "plot Execution time:", time.time()-start_plot_time figfn = "%s_%d" % (figSrcFnRoot, i) figfnlink = figfn.replace('%', '%25').replace(';','%3b').replace(':','%3A') fn = os.path.join(savedir, "%s.png" % figfn) start_time = time.time() fig.savefig(fn, format='png',dpi=75) print "savefig Execution time:", time.time()-start_time htmlStr = '' htmlStr += '<center><img src="%s" alt="could not find %s image"/></center>' % (os.path.join(".","%s.png" % figfnlink), figfn) fil.write(htmlStr + "<br>") plt.close() fil.close() A little further investigation showed that savefig was taking longer each run of the loop. I eventually noticed that replacing the call to fig.legend() with ax.legend() solved the problem. Anyone know why the time taken to save the plot increases when using fig.legend() in the code above ? While doing this I also noticed a couple of other things: 1. I cannot seem to clear the figure title, so when I re-set it I get the new title overlaying the old one in the plot output. Does anyone know how to completely clear and reset the title of an existing figure ? 2. The call to figure.legend() puts the legends nicely outside the plot boundaries (in the top right hand corner). The equivalent call to ax.legend() places the legends inside the plot boundary. Does anyone know a) why the behavior here is slightly different and b) how I can get the legends outside the plot boundary using ax.legend() ? |
|
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.
|
|
From: hari j. <ha...@gm...> - 2012-10-21 11:25:31
|
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 |