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
(8) |
2
(7) |
3
(8) |
4
(12) |
5
(1) |
|
6
(1) |
7
(9) |
8
(2) |
9
|
10
(1) |
11
|
12
(6) |
|
13
(6) |
14
(2) |
15
(7) |
16
(10) |
17
|
18
(3) |
19
(4) |
|
20
(4) |
21
(10) |
22
(8) |
23
(17) |
24
(13) |
25
(9) |
26
(1) |
|
27
(1) |
28
(4) |
29
(7) |
30
(2) |
31
(10) |
|
|
|
From: Benjamin R. <ben...@ou...> - 2012-05-16 01:46:14
|
On Tuesday, May 15, 2012, Gökhan Sever wrote: > Hello, > > I have encountered a weird plotting issue recently using a recent mpl > clone. See the linked pdfs for better demonstration of the issue: > > http://atmos.uwyo.edu/~gsever/data/vocals_RF04_NU05_newmpl.pdf > http://atmos.uwyo.edu/~gsever/data/vocals_RF04_NU05_oldmpl.pdf > > > newmpl file is created using the latest master branch (cloned and setup > today) > oldmpl is created using mpl v1.1.0 ( > https://github.com/downloads/matplotlib/matplotlib/matplotlib-1.1.0.tar.gz > ) > > Scroll down to page 4 in each file and you will see the wrong > plotted behavior of alwp_lcl (black line) variable on newmpl file comparing > to the correct version that is shown on oldmpl. > > I was trying to figure out a way to correct this and I raised y-axis max > to 2400 and then the line looks fine. However I have other data that show > similar wrong behaviors, so I decided to try earlier mpl versions since I > know that those plots were looking correct earlier (at least a few months > back). Trying v1.1.x branch gave me the same results. Note that these data > contain "nans". Are nan handling changed in recent mpl code or the way the > data is plotted out of margins? I can't reproduce this with synthetic data. > > Any ideas as to what could be going wrong here? > > Thanks. > > -- > Gökhan > I do recall some changes were made for v1.1.x with regards to autoscaling. Another change was also made with respect to Bbox clipping. I can't recall enough details to know if they are a part of this issue. Ben Root |
|
From: Gökhan S. <gok...@gm...> - 2012-05-15 23:57:45
|
Hello, I have encountered a weird plotting issue recently using a recent mpl clone. See the linked pdfs for better demonstration of the issue: http://atmos.uwyo.edu/~gsever/data/vocals_RF04_NU05_newmpl.pdf http://atmos.uwyo.edu/~gsever/data/vocals_RF04_NU05_oldmpl.pdf newmpl file is created using the latest master branch (cloned and setup today) oldmpl is created using mpl v1.1.0 ( https://github.com/downloads/matplotlib/matplotlib/matplotlib-1.1.0.tar.gz) Scroll down to page 4 in each file and you will see the wrong plotted behavior of alwp_lcl (black line) variable on newmpl file comparing to the correct version that is shown on oldmpl. I was trying to figure out a way to correct this and I raised y-axis max to 2400 and then the line looks fine. However I have other data that show similar wrong behaviors, so I decided to try earlier mpl versions since I know that those plots were looking correct earlier (at least a few months back). Trying v1.1.x branch gave me the same results. Note that these data contain "nans". Are nan handling changed in recent mpl code or the way the data is plotted out of margins? I can't reproduce this with synthetic data. Any ideas as to what could be going wrong here? Thanks. -- Gökhan |
|
From: Paul H. <pmh...@gm...> - 2012-05-15 18:04:06
|
Neal,
I can't run your script as is, but something as simple as this show work:
import matplotlib.pyplot as plt
fig = plt.figure()
ax = fig.add_subplot(111)
ax.set_xscale('log')
ax.xaxis.grid(True, which='major')
ax.xaxis.grid(True, which='minor')
plt.show()
On Tue, May 15, 2012 at 10:18 AM, Neal Becker <ndb...@gm...> wrote:
> In the following code snippet (not a complete example), I get the
> dashed lines for the minor ticks on the y (log) axis, but on the x axis, I only
> got the major ticks lines. How do I get minor lines to show up?
>
> (Previously, I tried without the MultipleLocator and set_minor_locator, but
> still got only major x axis lines plotted)
>
> import matplotlib.pyplot as plt
> fig = plt.figure()
> ax = fig.add_subplot(111)
>
> ax.semilogy (h1.buckets(), h1.cumulative())
> ax.semilogy (h2.buckets(), h2.inv_cumulative())
> from matplotlib.ticker import MultipleLocator
> minorLocator = MultipleLocator(5)
> ax.xaxis.set_minor_locator(minorLocator)
> plt.grid(b=True, which='major', linestyle='solid')
> plt.grid(b=True, which='minor', linestyle='dashed')
> plt.show()
>
>
>
> ------------------------------------------------------------------------------
> Live Security Virtual Conference
> Exclusive live event will cover all the ways today's security and
> threat landscape has changed and how IT managers can respond. Discussions
> will include endpoint security, mobile security and the latest in malware
> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
|
|
From: Neal B. <ndb...@gm...> - 2012-05-15 17:18:46
|
In the following code snippet (not a complete example), I get the dashed lines for the minor ticks on the y (log) axis, but on the x axis, I only got the major ticks lines. How do I get minor lines to show up? (Previously, I tried without the MultipleLocator and set_minor_locator, but still got only major x axis lines plotted) import matplotlib.pyplot as plt fig = plt.figure() ax = fig.add_subplot(111) ax.semilogy (h1.buckets(), h1.cumulative()) ax.semilogy (h2.buckets(), h2.inv_cumulative()) from matplotlib.ticker import MultipleLocator minorLocator = MultipleLocator(5) ax.xaxis.set_minor_locator(minorLocator) plt.grid(b=True, which='major', linestyle='solid') plt.grid(b=True, which='minor', linestyle='dashed') plt.show() |
|
From: Edward C. J. <edc...@co...> - 2012-05-15 16:09:10
|
I use up-to-date Debian testing (wheezy) with the amd64 architecture
and Debian's python3.2. I install matplotlib from the tarball
matplotlib-matplotlib-v1.1.0-684-ge87374e.tar.gz
Before the current install, I had also on my system Debian's
python-matplotlib and python-matplotlib-data packages. They contain
some of the same
files as the tarball (/etc/matplotlibrc). I have completely removed the two
Debian packages. My Debian system includes the packages python3-tk, tck8.5,
tcl8.5-dev, tk8.5, and tk-dev.
I did a new matplotlib install, starting by unpacking the tarball.
In /usr/local/lib/python3.2/dist-packages/matplotlib/tests/test_text.py
in test_afm_kerning, I added before the assert:
xxx = afm.string_width_height('VAVAVAVAVAVA')
print(xxx)
The results are:
> python3.2
Python 3.2.3rc2 (default, Mar 21 2012, 05:47:04)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import matplotlib
>>> matplotlib.test()
..K........./usr/lib/python3/dist-packages/nose/tools.py:82:
ResourceWarning: unclosed file <_io.BufferedRandom name=3>
pass
...../usr/lib/python3.2/subprocess.py:650: ResourceWarning: unclosed file
<_io.FileIO name=6 mode='rb'>
_cleanup()
/usr/lib/python3.2/subprocess.py:650: ResourceWarning: unclosed file
<_io.FileIO name=8 mode='rb'>
_cleanup()
Many "."s and "K"s are printed.
======================================================================
FAIL: matplotlib.tests.test_text.test_afm_kerning
----------------------------------------------------------------------
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/nose/case.py", line 198, in runTest
self.test(*self.arg)
File
"/usr/local/lib/python3.2/dist-packages/matplotlib/tests/test_text.py", line
109, in test_afm_kerning
assert afm.string_width_height('VAVAVAVAVAVA') == (7174.0, 718)
AssertionError: AssertionError:
-------------------- >> begin captured stdout << ---------------------
(8004.0, 718)
--------------------- >> end captured stdout << ----------------------
----------------------------------------------------------------------
Ran 1091 tests in 312.866s
FAILED (KNOWNFAIL=275, failures=1)
/usr/local/lib/python3.2/dist-packages/matplotlib/__init__.py:937:
/UserWarning: This call to matplotlib.use() has no effect
because the the backend has already been chosen;
matplotlib.use() must be called *before* pylab, matplotlib.pyplot,
or matplotlib.backends is imported for the first time.
if warn: warnings.warn(_use_error_msg)
False
>>>
=======
Here is one of matplotlib's simple sample programs. It works.
#! /usr/bin/env python3.2
from pylab import *
t = arange(0.0, 2.0, 0.01)
s = sin(2*pi*t)
plot(t, s, linewidth=1.0)
xlabel('time (s)')
ylabel('voltage (mV)')
title('About as simple as it gets, folks')
grid(True)
show()
|
|
From: Michael D. <md...@st...> - 2012-05-15 15:00:39
|
On 05/15/2012 10:15 AM, Edward C. Jones wrote:
> Michael Droettboom said
>
> > Are you running the tests from the source directory? That often
> results in failures that look like this.
>
> Yes, I did that. Some Googling found the correct way to do it:
>
> python3.2
> >>> import matplotlib
> >>> matplotlib.test()
> ..K........./usr/lib/python3/dist-packages/nose/tools.py:82:
> ResourceWarning: unclosed file<_io.BufferedRandom name=3>
> pass
> ...../usr/lib/python3.2/subprocess.py:650: ResourceWarning: unclosed file
> <_io.FileIO name=6 mode='rb'>
> _cleanup()
> /usr/lib/python3.2/subprocess.py:650: ResourceWarning: unclosed file
> <_io.FileIO name=8 mode='rb'>
> _cleanup()
>
> Many "."s and "K"s are output.
The K's are probably because some requirement of the test framework
(ghostscript or inkscape) is not being found on your machine.
>
> FAIL: matplotlib.tests.test_text.test_afm_kerning
> ----------------------------------------------------------------------
> Traceback (most recent call last):
> File "/usr/lib/python3/dist-packages/nose/case.py", line 198, in runTest
> self.test(*self.arg)
> File
> "/usr/local/lib/python3.2/dist-packages/matplotlib/tests/test_text.py", line
> 107, in test_afm_kerning
> assert afm.string_width_height('VAVAVAVAVAVA') == (7174.0, 718)
> AssertionError
>
> ----------------------------------------------------------------------
> Ran 1091 tests in 310.441s
>
> FAILED (KNOWNFAIL=275, failures=1)
> False
>
This is a new test as of yesterday. Can you add a print to figure out
what afm.string_width_height() returns? I'm curious as to what way this
is failing on your machine.
Mike
|
|
From: Edward C. J. <edc...@co...> - 2012-05-15 14:16:29
|
Michael Droettboom said
> Are you running the tests from the source directory? That often
results in failures that look like this.
Yes, I did that. Some Googling found the correct way to do it:
python3.2
>>> import matplotlib
>>> matplotlib.test()
..K........./usr/lib/python3/dist-packages/nose/tools.py:82:
ResourceWarning: unclosed file <_io.BufferedRandom name=3>
pass
...../usr/lib/python3.2/subprocess.py:650: ResourceWarning: unclosed file
<_io.FileIO name=6 mode='rb'>
_cleanup()
/usr/lib/python3.2/subprocess.py:650: ResourceWarning: unclosed file
<_io.FileIO name=8 mode='rb'>
_cleanup()
Many "."s and "K"s are output.
FAIL: matplotlib.tests.test_text.test_afm_kerning
----------------------------------------------------------------------
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/nose/case.py", line 198, in runTest
self.test(*self.arg)
File
"/usr/local/lib/python3.2/dist-packages/matplotlib/tests/test_text.py", line
107, in test_afm_kerning
assert afm.string_width_height('VAVAVAVAVAVA') == (7174.0, 718)
AssertionError
----------------------------------------------------------------------
Ran 1091 tests in 310.441s
FAILED (KNOWNFAIL=275, failures=1)
False
|
|
From: Michael D. <md...@st...> - 2012-05-15 12:38:53
|
Are you running the tests from the source directory? That often results
in failures that look like this.
Mike
On 05/14/2012 06:11 PM, Edward C. Jones wrote:
> I use up-to-date Debian testing (wheezy) with an amd64 architecture. I
> am trying to use matplotlib with Python 3.2, I downloaded
> matplotlib-matplotlib-v1.1.0-684-ge87374e.tar.gz
> I expanded the tarball and did
> python3.2 setup.py build
> and, as root,
> python3.2 setup.py install
>
> When I tried to run
> python3.2 tests.py
> I had two types of error. First the files in lib/dateutil: parser.py,
> rrule.py, etc. had not been run through 2to3. I removed back-quotes,
> used the function-call form for exceptions, and fixed some import
> statements.
>
> After fixing these errors I get 13 messages like:
>
> ERROR: Failure: AttributeError ('module' object has no attribute
> 'test_backend_svg')
> ----------------------------------------------------------------------
> Traceback (most recent call last):
> File "/usr/lib/python3/dist-packages/nose/failure.py", line 37, in
> runTest
> raise self.exc_class(self.exc_val).with_traceback(self.tb)
> File "/usr/lib/python3/dist-packages/nose/loader.py", line 379, in
> loadTestsFromName
> module = resolve_name(addr.module)
> File "/usr/lib/python3/dist-packages/nose/util.py", line 331, in
> resolve_name
> obj = getattr(obj, part)
> AttributeError: 'module' object has no attribute 'test_backend_svg'
>
> These tests are all in build/lib.linux-x86_64-3.2/matplotlib/tests.
>
> There is a similar problem in
> http://sourceforge.net/mailarchive/message.php?msg_id=28398373
>
> What is the problem and the fix?
>
>
> ------------------------------------------------------------------------------
> Live Security Virtual Conference
> Exclusive live event will cover all the ways today's security and
> threat landscape has changed and how IT managers can respond. Discussions
> will include endpoint security, mobile security and the latest in malware
> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
|
|
From: Edward C. J. <edc...@co...> - 2012-05-14 22:12:19
|
I use up-to-date Debian testing (wheezy) with an amd64 architecture. I
am trying to use matplotlib with Python 3.2, I downloaded
matplotlib-matplotlib-v1.1.0-684-ge87374e.tar.gz
I expanded the tarball and did
python3.2 setup.py build
and, as root,
python3.2 setup.py install
When I tried to run
python3.2 tests.py
I had two types of error. First the files in lib/dateutil: parser.py,
rrule.py, etc. had not been run through 2to3. I removed back-quotes,
used the function-call form for exceptions, and fixed some import
statements.
After fixing these errors I get 13 messages like:
ERROR: Failure: AttributeError ('module' object has no attribute
'test_backend_svg')
----------------------------------------------------------------------
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/nose/failure.py", line 37, in
runTest
raise self.exc_class(self.exc_val).with_traceback(self.tb)
File "/usr/lib/python3/dist-packages/nose/loader.py", line 379, in
loadTestsFromName
module = resolve_name(addr.module)
File "/usr/lib/python3/dist-packages/nose/util.py", line 331, in
resolve_name
obj = getattr(obj, part)
AttributeError: 'module' object has no attribute 'test_backend_svg'
These tests are all in build/lib.linux-x86_64-3.2/matplotlib/tests.
There is a similar problem in
http://sourceforge.net/mailarchive/message.php?msg_id=28398373
What is the problem and the fix?
|
|
From: Michael O. <mic...@ch...> - 2012-05-14 13:53:03
|
Hello,
I am struggling with a potentially easy problem in matplotlib: I have
some 2D data
which I visualize using matplotlibs contour function. However, besides the
contour lines itself I want to visualize the underlying grid as well
which I do by setting ticks for
each data point on x and y axis and setting the tick labels to void:
figure()
ax=gca()
ax.set_aspect('equal')
xax=ax.xaxis
xax.set_ticks(X[0,:])
xax.set_ticklabels('')
yax=ax.yaxis
yax.set_ticks(Y[:,0])
yax.set_ticklabels('')
contour(X,Y,g,0,linewidth=4)
ax.grid(color='r', linestyle='-', linewidth=1)
Here, X, Y are the coordinates of my grid created with
X, Y = np.meshgrid(X, Y)
So far everything is fine and I have my grid. However, I also want to
have some tick labels
on the x and y axis. I tried that using twinx() but that has the result
that
i) the aspect ratio is lost (which I have set with ax.set_aspect('equal'))
ii) the grid-lines are re-set to the major ticks of the newly created
axis.
How can I achieve both: i) having my 2D grid vizualized and ii) having some
ticks and labels along the x and y axis.
Thanks for any help and greetings from Sweden
Michael
|
|
From: Jeff W. <js...@fa...> - 2012-05-13 14:03:08
|
On 5/13/12 3:34 AM, David Craig wrote: > Hi, I'm having a problem usinf fill_between() with basemap. I plot two > great circles and want to shade the region between them. My code is > below, it doesnt give any error just creates the plot without filling > the area. Does anyone know if it's possible to do this or should I try > a different method? > Thanks, > David > David Try replacing m.drawgreatcircle(x1, y1, x2, y2, del_s=10, color='gray', lw=1.) m.drawgreatcircle(x1, y1, x3, y3, del_s=10, color='gray', lw=1.) a=linspace(x3,x1) b=linspace(y2,y1) c=linspace(y3,y1) fill_between(a, b, c, where=None, alpha=0.2) with xx1,yy1 = m.gcpoints(x1,y1,x2,y2,100) xx2,yy2 = m.gcpoints(x1,y1,x3,y3,100) fill_between(xx1, yy1, yy2) -Jeff > from mpl_toolkits.basemap import Basemap > from pylab import * > > ### PARAMETERS FOR MATPLOTLIB : > import matplotlib as mpl > rcParams['font.size'] = 10. > rcParams['font.family'] = 'Comic Sans MS' > rcParams['axes.labelsize'] = 8. > rcParams['xtick.labelsize'] = 6. > rcParams['ytick.labelsize'] = 6. > > def shoot(lon, lat, azimuth, maxdist=None): > """Shooter Function > Original javascript on http://williams.best.vwh.net/gccalc.htm > Translated to python by Thomas Lecocq > """ > glat1 = lat * pi / 180. > glon1 = lon * pi / 180. > s = maxdist / 1.852 > faz = azimuth * pi / 180. > > EPS= 0.00000000005 > if ((abs(cos(glat1))<EPS) and not (abs(sin(faz))<EPS)): > alert("Only N-S courses are meaningful, starting at a pole!") > > a=6378.13/1.852 > f=1/298.257223563 > r = 1 - f > tu = r * tan(glat1) > sf = sin(faz) > cf = cos(faz) > if (cf==0): > b=0. > else: > b=2. * arctan2 (tu, cf) > > cu = 1. / sqrt(1 + tu * tu) > su = tu * cu > sa = cu * sf > c2a = 1 - sa * sa > x = 1. + sqrt(1. + c2a * (1. / (r * r) - 1.)) > x = (x - 2.) / x > c = 1. - x > c = (x * x / 4. + 1.) / c > d = (0.375 * x * x - 1.) * x > tu = s / (r * a * c) > y = tu > c = y + 1 > while (abs (y - c) > EPS): > > sy = sin(y) > cy = cos(y) > cz = cos(b + y) > e = 2. * cz * cz - 1. > c = y > x = e * cy > y = e + e - 1. > y = (((sy * sy * 4. - 3.) * y * cz * d / 6. + x) * > d / 4. - cz) * sy * d + tu > > b = cu * cy * cf - su * sy > c = r * sqrt(sa * sa + b * b) > d = su * cy + cu * sy * cf > glat2 = (arctan2(d, c) + pi) % (2*pi) - pi > c = cu * cy - su * sy * cf > x = arctan2(sy * sf, c) > c = ((-3. * c2a + 4.) * f + 4.) * c2a * f / 16. > d = ((e * cy * c + cz) * sy * c + y) * sa > glon2 = ((glon1 + x - (1. - c) * d * f + pi) % (2*pi)) - pi > > baz = (arctan2(sa, b) + pi) % (2 * pi) > > glon2 *= 180./pi > glat2 *= 180./pi > baz *= 180./pi > > return (glon2, glat2, baz) > > #Create a basemap around N. Atlantic > m = Basemap(llcrnrlon=-45.0,llcrnrlat=30.0,urcrnrlon=15.0,urcrnrlat=75.0, > resolution='i',projection='merc',lon_0=-17.5,lat_0=60.0) > > > m.drawcountries(linewidth=0.5) > m.drawcoastlines(linewidth=0.5) > m.bluemarble() > m.drawparallels(arange(40.,75.,10.),labels=[1,0,0,0],color='black',dashes=[1,0],labelstyle='+/-',linewidth=0.2) > # draw parallels > m.drawmeridians(arange(-45.,15.,10.),labels=[0,0,0,1],color='black',dashes=[1,0],labelstyle='+/-',linewidth=0.2) > # draw meridians > > # Shade region defined by great circles. > x1, y1 = -9.1676613, 51.6029999 > az1 = 270. > az2 = 290. > maxdist = 2000 > x2, y2, baz = shoot(x1, y1, az1, maxdist) > x3, y3, baz = shoot(x1, y1, az2, maxdist) > > m.drawgreatcircle(x1, y1, x2, y2, del_s=10, color='gray', lw=1.) > m.drawgreatcircle(x1, y1, x3, y3, del_s=10, color='gray', lw=1.) > a=linspace(x3,x1) > b=linspace(y2,y1) > c=linspace(y3,y1) > fill_between(a, b, c, where=None, alpha=0.2) > show() > > > ------------------------------------------------------------------------------ > Live Security Virtual Conference > Exclusive live event will cover all the ways today's security and > threat landscape has changed and how IT managers can respond. Discussions > will include endpoint security, mobile security and the latest in malware > threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ > > > _______________________________________________ > Matplotlib-users mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users |
|
From: Jerzy K. <jer...@un...> - 2012-05-13 11:15:36
|
Appendix. (and excuses for my approximate syntax in the first message; I was doing three things simultaneously). Maestro David Craig, your filling will be lousy anyway. If your x and y arrays come from linespace, you will surely get a triangle, and not the curvilinear area between GreatCircles. You must transform the coordinates in a more clever (but equally easy...) way. Jerzy K. |
|
From: Jerzy K. <jer...@un...> - 2012-05-13 10:14:09
|
Le 13/05/2012 11:34, David Craig a écrit : > Hi, I'm having a problem usinf fill_between() with basemap. I plot two > great circles and want to shade the region between them. My code is > below, it doesnt give any error just creates the plot without filling > the area. Does anyone know if it's possible to do this or should I try > a different method? Hello, Boss. Perhaps I am telling rubbish, but fill_between demands the coordinates within your axes, not the basemap angles. Your a,b,c contain some small numers (negative x, say -38) won't do any good, x should be, say 3001129 etc. Use m(...) to convert. Jerzy K |
|
From: David C. <dcd...@gm...> - 2012-05-13 09:34:43
|
Hi, I'm having a problem usinf fill_between() with basemap. I plot two
great circles and want to shade the region between them. My code is below,
it doesnt give any error just creates the plot without filling the area.
Does anyone know if it's possible to do this or should I try a different
method?
Thanks,
David
from mpl_toolkits.basemap import Basemap
from pylab import *
### PARAMETERS FOR MATPLOTLIB :
import matplotlib as mpl
rcParams['font.size'] = 10.
rcParams['font.family'] = 'Comic Sans MS'
rcParams['axes.labelsize'] = 8.
rcParams['xtick.labelsize'] = 6.
rcParams['ytick.labelsize'] = 6.
def shoot(lon, lat, azimuth, maxdist=None):
"""Shooter Function
Original javascript on http://williams.best.vwh.net/gccalc.htm
Translated to python by Thomas Lecocq
"""
glat1 = lat * pi / 180.
glon1 = lon * pi / 180.
s = maxdist / 1.852
faz = azimuth * pi / 180.
EPS= 0.00000000005
if ((abs(cos(glat1))<EPS) and not (abs(sin(faz))<EPS)):
alert("Only N-S courses are meaningful, starting at a pole!")
a=6378.13/1.852
f=1/298.257223563
r = 1 - f
tu = r * tan(glat1)
sf = sin(faz)
cf = cos(faz)
if (cf==0):
b=0.
else:
b=2. * arctan2 (tu, cf)
cu = 1. / sqrt(1 + tu * tu)
su = tu * cu
sa = cu * sf
c2a = 1 - sa * sa
x = 1. + sqrt(1. + c2a * (1. / (r * r) - 1.))
x = (x - 2.) / x
c = 1. - x
c = (x * x / 4. + 1.) / c
d = (0.375 * x * x - 1.) * x
tu = s / (r * a * c)
y = tu
c = y + 1
while (abs (y - c) > EPS):
sy = sin(y)
cy = cos(y)
cz = cos(b + y)
e = 2. * cz * cz - 1.
c = y
x = e * cy
y = e + e - 1.
y = (((sy * sy * 4. - 3.) * y * cz * d / 6. + x) *
d / 4. - cz) * sy * d + tu
b = cu * cy * cf - su * sy
c = r * sqrt(sa * sa + b * b)
d = su * cy + cu * sy * cf
glat2 = (arctan2(d, c) + pi) % (2*pi) - pi
c = cu * cy - su * sy * cf
x = arctan2(sy * sf, c)
c = ((-3. * c2a + 4.) * f + 4.) * c2a * f / 16.
d = ((e * cy * c + cz) * sy * c + y) * sa
glon2 = ((glon1 + x - (1. - c) * d * f + pi) % (2*pi)) - pi
baz = (arctan2(sa, b) + pi) % (2 * pi)
glon2 *= 180./pi
glat2 *= 180./pi
baz *= 180./pi
return (glon2, glat2, baz)
#Create a basemap around N. Atlantic
m = Basemap(llcrnrlon=-45.0,llcrnrlat=30.0,urcrnrlon=15.0,urcrnrlat=75.0,
resolution='i',projection='merc',lon_0=-17.5,lat_0=60.0)
m.drawcountries(linewidth=0.5)
m.drawcoastlines(linewidth=0.5)
m.bluemarble()
m.drawparallels(arange(40.,75.,10.),labels=[1,0,0,0],color='black',dashes=[1,0],labelstyle='+/-',linewidth=0.2)
# draw parallels
m.drawmeridians(arange(-45.,15.,10.),labels=[0,0,0,1],color='black',dashes=[1,0],labelstyle='+/-',linewidth=0.2)
# draw meridians
# Shade region defined by great circles.
x1, y1 = -9.1676613, 51.6029999
az1 = 270.
az2 = 290.
maxdist = 2000
x2, y2, baz = shoot(x1, y1, az1, maxdist)
x3, y3, baz = shoot(x1, y1, az2, maxdist)
m.drawgreatcircle(x1, y1, x2, y2, del_s=10, color='gray', lw=1.)
m.drawgreatcircle(x1, y1, x3, y3, del_s=10, color='gray', lw=1.)
a=linspace(x3,x1)
b=linspace(y2,y1)
c=linspace(y3,y1)
fill_between(a, b, c, where=None, alpha=0.2)
show()
|
|
From: Jerzy K. <jer...@un...> - 2012-05-13 09:29:48
|
(13/05/2012 02:52), Arek Kędzior: > What I am trying is to plot multiple discontinuous lines. > I know that this approach does not work very well. How about > using LineCollection. > Put all curves into line collection > Use Pick event to get line segment (what function to use ?) > Once I have line segment, get xdata, ydata corresponding to line > segment (what function to use ?) Why don't you use: picker=myTest in your ax.plot, where def myTest(artist,mousevnt): ... return (hit,kwdict) performs any test you like? Again, this is called separately for every Artist belonging to the Usual Suspects, but you may control whether this is the first line found, then your program just computes the distance, or the second one, then it computes the distance, and discriminates between the two. The properties kwdict passed to your callback will permit to do the rest. Or, perhaps, the first time the test doesn't do anything, and returns False, and the second time computes both distances, and finds the minimum. You have your "private" access to both lines anyway. The generalization to many lines should be straightforward. Jerzy K. |
|
From: Arek K. <ake...@ya...> - 2012-05-13 00:52:27
|
What I am trying is to plot multiple discontinuous lines. I know that this approach does not work very well. How about using LineCollection. Put all curves into line collection Use Pick event to get line segment (what function to use ?) Once I have line segment, get xdata, ydata corresponding to line segment (what function to use ?) I tied this approach as well Put all data points into numpy.array and each curve was separated by numpy.nan It worked but I was getting run-time warning in distance calculations. Any suggestions how to ? Regards, Arek ________________________________ From: "mat...@li..." <mat...@li...> To: mat...@li... Sent: Saturday, May 12, 2012 1:12 PM Subject: Matplotlib-users Digest, Vol 72, Issue 11 Send Matplotlib-users mailing list submissions to mat...@li... To subscribe or unsubscribe via the World Wide Web, visit https://lists.sourceforge.net/lists/listinfo/matplotlib-users or, via email, send a message with subject or body 'help' to mat...@li... You can reach the person managing the list at mat...@li... When replying, please edit your Subject line so it is more specific than "Re: Contents of Matplotlib-users digest..." Today's Topics: 1. Re: Matplotlib-users Digest, Vol 72, Issue 10 (Arek Kedzior) 2. Re: pick event (Arek Kedzior) ---------------------------------------------------------------------- Message: 1 Date: Sat, 12 May 2012 09:35:59 -0700 (PDT) From: Arek Kedzior <ake...@ya...> Subject: Re: [Matplotlib-users] Matplotlib-users Digest, Vol 72, Issue 10 To: "mat...@li..." <mat...@li...> Message-ID: <133...@we...> Content-Type: text/plain; charset="iso-8859-1" If you pick one of the curves in the close location to tangancy area, the OnPick function?will be?ececuted twice (2 curves) and will display 2 markers. I want to find the shortest distance from the pick location (mouse coord.) to a discrete point on the curve and?draw?marker on the curve at this location (only one).? See the line with "print lineObj" ________________________________ From: "mat...@li..." <mat...@li...> To: mat...@li... Sent: Saturday, May 12, 2012 10:59 AM Subject: Matplotlib-users Digest, Vol 72, Issue 10 Send Matplotlib-users mailing list submissions to ??? mat...@li... To subscribe or unsubscribe via the World Wide Web, visit ??? https://lists.sourceforge.net/lists/listinfo/matplotlib-users or, via email, send a message with subject or body 'help' to ??? mat...@li... You can reach the person managing the list at ??? mat...@li... When replying, please edit your Subject line so it is more specific than "Re: Contents of Matplotlib-users digest..." Today's Topics: ? 1. pick event (Arek Kedzior) ? 2. Re: pick event (Jerzy Karczmarczuk) ? 3. Re: pick event (Benjamin Root) ---------------------------------------------------------------------- Message: 1 Date: Sat, 12 May 2012 06:07:37 -0700 (PDT) From: Arek Kedzior <ake...@ya...> Subject: [Matplotlib-users] pick event To: "mat...@li..." ??? <mat...@li...> Message-ID: ??? <133...@we...> Content-Type: text/plain; charset="iso-8859-1" I am trying to use pick event.? See the simple script below.? I am interested to find the shortest distance between pick point (mouse coord.) and the ?line at the discrete points only (points on the curve from data) What am I doing wrong ? Regards, Arek ? import numpy as np import matplotlib.pyplot as plt from matplotlib.lines import Line2D import math as math ? # create figure and attach axes to it fig = plt.figure(1) ax = fig.add_subplot(111) ? ? def getMinDistance(xmouse, ymouse, xList, yList): ??? """ ??? find shortest distance between mouse coordinates and pick point ??? point pick may be a list of points if data is clouded ??? Input ??? xmouse - x coordinate of mouse (x - pick) ??? ymouse - y coordinate of mouse (y - pick) ??? xList? - xData from curve ??? yList? - yData from curve ??? Returns: ??? dmin? - minimum distance ??? index - index of data point in the xList and yList ??? """ ????dmin? = math.sqrt((xList[0] - xmouse)**2. + (yList[0]-ymouse)**2.)? ????index = 0 ??? for idx in range(1,len(xList)): ??????? d = math.sqrt((xList[idx] - xmouse)**2. + (yList[idx]-ymouse)**2.) ??????? if(d < dmin): ??????????? dmin = d ??????????? index = idx ????return dmin, index ? def showMarker(x, y, color): ??? """ ??? draw marker at loction x, y with color ??? """ ??? # draw marker ??? markerOn, = ax.plot(x, y, 'o', color = color) ???? def OnPick(event): ??? """ ??? pick event ??? """ ??? print '****************************' ??? mouseEvent = event.mouseevent ??? # get pick coord ??? xmouse, ymouse = mouseEvent.xdata, mouseEvent.ydata ??? # get the artist ??? lineObj = event.artist ????print lineObj ????if not isinstance(lineObj, Line2D): ??????? return ????ind = event.ind ????# check if indexes exist of the pick object ??? N = len(ind) ??? if not N: ??????? return ??? # get curve picked data ??? Xdata, Ydata = lineObj.get_data() ??? color = lineObj.get_color() ????xLi = np.take(Xdata, ind) ??? yLi = np.take(Ydata, ind) ??? dmin, index = getMinDistance(xmouse, ymouse, xLi, yLi) ??? ????xP = xLi[index] ??? yP = yLi[index] ??? ????xStr = '%.4g' % xP ??? yStr = '%.4g' % yP ??? txt = 'X = ' + xStr + ' ;? ' + 'Y = ' + yStr ??? print txt ??? # show marker ??? showMarker(xP, yP, color) ??? # redraw to show marker ??? fig.canvas.draw() ??? # connect to pick event??? fig.canvas.mpl_connect('pick_event',OnPick) ? # generate data for display x = np.arange(-4,4,0.1)????? # x- coord y2 = x**2 + 5.0????????????? # y coord of first curve y? = 2*x + 4.0?????????????? # y coord of the second curve # create the list of x and y data xList = [x, x]?????????????? yList = [y, y2] objList = []???? # store draw lines (artists) # display 2 curves for idx in range(len(xList)): ??? obj, = ax.plot(xList[idx], yList[idx], picker = 5) ??? objList.append(obj) ? # display plot plt.show(1) -------------- next part -------------- An HTML attachment was scrubbed... ------------------------------ Message: 2 Date: Sat, 12 May 2012 16:44:16 +0200 From: Jerzy Karczmarczuk <jer...@un...> Subject: Re: [Matplotlib-users] pick event To: mat...@li... Message-ID: <4FA...@un...> Content-Type: text/plain; charset="iso-8859-1" Arek Ke;dzior: > I am trying to use pick event. ... > What am I doing wrong ? Wrong with WHAT? What do you expect? Jerzy Karczmarczuk -------------- next part -------------- An HTML attachment was scrubbed... ------------------------------ Message: 3 Date: Sat, 12 May 2012 10:59:39 -0400 From: Benjamin Root <ben...@ou...> Subject: Re: [Matplotlib-users] pick event To: "jer...@un..." <jer...@un...> Cc: "mat...@li..." ??? <mat...@li...> Message-ID: ??? <CAN...@ma...> Content-Type: text/plain; charset="utf-8" On Saturday, May 12, 2012, Jerzy Karczmarczuk wrote: >? Arek K?dzior: > >? I am trying to use pick event. > > ... > >? What am I doing wrong ? > > Wrong with WHAT? > What do you expect? > > Jerzy Karczmarczuk > Arek. Could you provide a little more detail about your issue? Cheers! Ben Root -------------- next part -------------- An HTML attachment was scrubbed... ------------------------------ ------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ ------------------------------ _______________________________________________ Matplotlib-users mailing list Mat...@li... https://lists.sourceforge.net/lists/listinfo/matplotlib-users End of Matplotlib-users Digest, Vol 72, Issue 10 ************************************************ -------------- next part -------------- An HTML attachment was scrubbed... ------------------------------ Message: 2 Date: Sat, 12 May 2012 10:12:18 -0700 (PDT) From: Arek Kedzior <ake...@ya...> Subject: Re: [Matplotlib-users] pick event To: "mat...@li..." <mat...@li...> Message-ID: <133...@we...> Content-Type: text/plain; charset="iso-8859-1" If you pick one of the curves in the close location to tangancy area, the OnPick function will be ececuted twice (2 curves) and will display 2 markers. I want to find the shortest distance from the pick location (mouse coord.) to a discrete point on the curve and draw marker on the curve at this location (only one). See the line with "print lineObj" ________________________________ From: "mat...@li..." <mat...@li...> To: mat...@li... Sent: Saturday, May 12, 2012 10:59 AM Subject: Matplotlib-users Digest, Vol 72, Issue 10 Send Matplotlib-users mailing list submissions to ??? mat...@li... To subscribe or unsubscribe via the World Wide Web, visit ??? https://lists.sourceforge.net/lists/listinfo/matplotlib-users or, via email, send a message with subject or body 'help' to ??? mat...@li... You can reach the person managing the list at ??? mat...@li... When replying, please edit your Subject line so it is more specific than "Re: Contents of Matplotlib-users digest..." Today's Topics: ? 1. pick event (Arek Kedzior) ? 2. Re: pick event (Jerzy Karczmarczuk) ? 3. Re: pick event (Benjamin Root) ---------------------------------------------------------------------- Message: 1 Date: Sat, 12 May 2012 06:07:37 -0700 (PDT) From: Arek Kedzior <ake...@ya...> Subject: [Matplotlib-users] pick event To: "mat...@li..." ??? <mat...@li...> Message-ID: ??? <133...@we...> Content-Type: text/plain; charset="iso-8859-1" I am trying to use pick event.? See the simple script below.? I am interested to find the shortest distance between pick point (mouse coord.) and the ?line at the discrete points only (points on the curve from data) What am I doing wrong ? Regards, Arek ? import numpy as np import matplotlib.pyplot as plt from matplotlib.lines import Line2D import math as math ? # create figure and attach axes to it fig = plt.figure(1) ax = fig.add_subplot(111) ? ? def getMinDistance(xmouse, ymouse, xList, yList): ??? """ ??? find shortest distance between mouse coordinates and pick point ??? point pick may be a list of points if data is clouded ??? Input ??? xmouse - x coordinate of mouse (x - pick) ??? ymouse - y coordinate of mouse (y - pick) ??? xList? - xData from curve ??? yList? - yData from curve ??? Returns: ??? dmin? - minimum distance ??? index - index of data point in the xList and yList ??? """ ????dmin? = math.sqrt((xList[0] - xmouse)**2. + (yList[0]-ymouse)**2.)? ????index = 0 ??? for idx in range(1,len(xList)): ??????? d = math.sqrt((xList[idx] - xmouse)**2. + (yList[idx]-ymouse)**2.) ??????? if(d < dmin): ??????????? dmin = d ??????????? index = idx ????return dmin, index ? def showMarker(x, y, color): ??? """ ??? draw marker at loction x, y with color ??? """ ??? # draw marker ??? markerOn, = ax.plot(x, y, 'o', color = color) ???? def OnPick(event): ??? """ ??? pick event ??? """ ??? print '****************************' ??? mouseEvent = event.mouseevent ??? # get pick coord ??? xmouse, ymouse = mouseEvent.xdata, mouseEvent.ydata ??? # get the artist ??? lineObj = event.artist ????print lineObj ????if not isinstance(lineObj, Line2D): ??????? return ????ind = event.ind ????# check if indexes exist of the pick object ??? N = len(ind) ??? if not N: ??????? return ??? # get curve picked data ??? Xdata, Ydata = lineObj.get_data() ??? color = lineObj.get_color() ????xLi = np.take(Xdata, ind) ??? yLi = np.take(Ydata, ind) ??? dmin, index = getMinDistance(xmouse, ymouse, xLi, yLi) ??? ????xP = xLi[index] ??? yP = yLi[index] ??? ????xStr = '%.4g' % xP ??? yStr = '%.4g' % yP ??? txt = 'X = ' + xStr + ' ;? ' + 'Y = ' + yStr ??? print txt ??? # show marker ??? showMarker(xP, yP, color) ??? # redraw to show marker ??? fig.canvas.draw() ??? # connect to pick event??? fig.canvas.mpl_connect('pick_event',OnPick) ? # generate data for display x = np.arange(-4,4,0.1)????? # x- coord y2 = x**2 + 5.0????????????? # y coord of first curve y? = 2*x + 4.0?????????????? # y coord of the second curve # create the list of x and y data xList = [x, x]?????????????? yList = [y, y2] objList = []???? # store draw lines (artists) # display 2 curves for idx in range(len(xList)): ??? obj, = ax.plot(xList[idx], yList[idx], picker = 5) ??? objList.append(obj) ? # display plot plt.show(1) -------------- next part -------------- An HTML attachment was scrubbed... ------------------------------ Message: 2 Date: Sat, 12 May 2012 16:44:16 +0200 From: Jerzy Karczmarczuk <jer...@un...> Subject: Re: [Matplotlib-users] pick event To: mat...@li... Message-ID: <4FA...@un...> Content-Type: text/plain; charset="iso-8859-1" Arek Ke;dzior: > I am trying to use pick event. ... > What am I doing wrong ? Wrong with WHAT? What do you expect? Jerzy Karczmarczuk -------------- next part -------------- An HTML attachment was scrubbed... ------------------------------ Message: 3 Date: Sat, 12 May 2012 10:59:39 -0400 From: Benjamin Root <ben...@ou...> Subject: Re: [Matplotlib-users] pick event To: "jer...@un..." <jer...@un...> Cc: "mat...@li..." ??? <mat...@li...> Message-ID: ??? <CAN...@ma...> Content-Type: text/plain; charset="utf-8" On Saturday, May 12, 2012, Jerzy Karczmarczuk wrote: >? Arek K?dzior: > >? I am trying to use pick event. > > ... > >? What am I doing wrong ? > > Wrong with WHAT? > What do you expect? > > Jerzy Karczmarczuk > Arek. Could you provide a little more detail about your issue? Cheers! Ben Root -------------- next part -------------- An HTML attachment was scrubbed... ------------------------------ ------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ ------------------------------ _______________________________________________ Matplotlib-users mailing list Mat...@li... https://lists.sourceforge.net/lists/listinfo/matplotlib-users End of Matplotlib-users Digest, Vol 72, Issue 10 ************************************************ -------------- next part -------------- An HTML attachment was scrubbed... ------------------------------ ------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ ------------------------------ _______________________________________________ Matplotlib-users mailing list Mat...@li... https://lists.sourceforge.net/lists/listinfo/matplotlib-users End of Matplotlib-users Digest, Vol 72, Issue 11 ************************************************ |
|
From: Jerzy K. <jer...@un...> - 2012-05-12 19:55:10
|
Arek Ke;dzior: > If you pick one of the curves in the close location to tangancy area, > the OnPick function will be executed twice (2 curves) and will display > 2 markers. I want to find the shortest distance from the pick location > (mouse coord.) to a discrete point on the curve and draw marker on the > curve at this location (only one). See the line with "print lineObj" Ok, now I -- perhaps -- understand. This is a speculation... Your approach cannot work, since the low level event handling issues TWO pick events, one for each curve. Everything works very well, your program finds the appropriate point ... on both curves, separately. I suggest that you try to react to lower level mouse events. Look into the Pick code within the Artist class. The system tries to pick all the children, and here - I believe - resides your problem. You should perhaps discriminate the picked target at this point. Jerzy Karczmarczuk |
|
From: Arek K. <ake...@ya...> - 2012-05-12 17:12:25
|
If you pick one of the curves in the close location to tangancy area, the OnPick function will be ececuted twice (2 curves) and will display 2 markers. I want to find the shortest distance from the pick location (mouse coord.) to a discrete point on the curve and draw marker on the curve at this location (only one). See the line with "print lineObj" ________________________________ From: "mat...@li..." <mat...@li...> To: mat...@li... Sent: Saturday, May 12, 2012 10:59 AM Subject: Matplotlib-users Digest, Vol 72, Issue 10 Send Matplotlib-users mailing list submissions to mat...@li... To subscribe or unsubscribe via the World Wide Web, visit https://lists.sourceforge.net/lists/listinfo/matplotlib-users or, via email, send a message with subject or body 'help' to mat...@li... You can reach the person managing the list at mat...@li... When replying, please edit your Subject line so it is more specific than "Re: Contents of Matplotlib-users digest..." Today's Topics: 1. pick event (Arek Kedzior) 2. Re: pick event (Jerzy Karczmarczuk) 3. Re: pick event (Benjamin Root) ---------------------------------------------------------------------- Message: 1 Date: Sat, 12 May 2012 06:07:37 -0700 (PDT) From: Arek Kedzior <ake...@ya...> Subject: [Matplotlib-users] pick event To: "mat...@li..." <mat...@li...> Message-ID: <133...@we...> Content-Type: text/plain; charset="iso-8859-1" I am trying to use pick event.? See the simple script below.? I am interested to find the shortest distance between pick point (mouse coord.) and the ?line at the discrete points only (points on the curve from data) What am I doing wrong ? Regards, Arek ? import numpy as np import matplotlib.pyplot as plt from matplotlib.lines import Line2D import math as math ? # create figure and attach axes to it fig = plt.figure(1) ax = fig.add_subplot(111) ? ? def getMinDistance(xmouse, ymouse, xList, yList): ??? """ ??? find shortest distance between mouse coordinates and pick point ??? point pick may be a list of points if data is clouded ??? Input ??? xmouse - x coordinate of mouse (x - pick) ??? ymouse - y coordinate of mouse (y - pick) ??? xList? - xData from curve ??? yList? - yData from curve ??? Returns: ??? dmin? - minimum distance ??? index - index of data point in the xList and yList ??? """ ????dmin? = math.sqrt((xList[0] - xmouse)**2. + (yList[0]-ymouse)**2.)? ????index = 0 ??? for idx in range(1,len(xList)): ??????? d = math.sqrt((xList[idx] - xmouse)**2. + (yList[idx]-ymouse)**2.) ??????? if(d < dmin): ??????????? dmin = d ??????????? index = idx ????return dmin, index ? def showMarker(x, y, color): ??? """ ??? draw marker at loction x, y with color ??? """ ??? # draw marker ??? markerOn, = ax.plot(x, y, 'o', color = color) ???? def OnPick(event): ??? """ ??? pick event ??? """ ??? print '****************************' ??? mouseEvent = event.mouseevent ??? # get pick coord ??? xmouse, ymouse = mouseEvent.xdata, mouseEvent.ydata ??? # get the artist ??? lineObj = event.artist ????print lineObj ????if not isinstance(lineObj, Line2D): ??????? return ????ind = event.ind ????# check if indexes exist of the pick object ??? N = len(ind) ??? if not N: ??????? return ??? # get curve picked data ??? Xdata, Ydata = lineObj.get_data() ??? color = lineObj.get_color() ????xLi = np.take(Xdata, ind) ??? yLi = np.take(Ydata, ind) ??? dmin, index = getMinDistance(xmouse, ymouse, xLi, yLi) ??? ????xP = xLi[index] ??? yP = yLi[index] ??? ????xStr = '%.4g' % xP ??? yStr = '%.4g' % yP ??? txt = 'X = ' + xStr + ' ;? ' + 'Y = ' + yStr ??? print txt ??? # show marker ??? showMarker(xP, yP, color) ??? # redraw to show marker ??? fig.canvas.draw() ??? # connect to pick event??? fig.canvas.mpl_connect('pick_event',OnPick) ? # generate data for display x = np.arange(-4,4,0.1)????? # x- coord y2 = x**2 + 5.0????????????? # y coord of first curve y? = 2*x + 4.0?????????????? # y coord of the second curve # create the list of x and y data xList = [x, x]?????????????? yList = [y, y2] objList = []???? # store draw lines (artists) # display 2 curves for idx in range(len(xList)): ??? obj, = ax.plot(xList[idx], yList[idx], picker = 5) ??? objList.append(obj) ? # display plot plt.show(1) -------------- next part -------------- An HTML attachment was scrubbed... ------------------------------ Message: 2 Date: Sat, 12 May 2012 16:44:16 +0200 From: Jerzy Karczmarczuk <jer...@un...> Subject: Re: [Matplotlib-users] pick event To: mat...@li... Message-ID: <4FA...@un...> Content-Type: text/plain; charset="iso-8859-1" Arek Ke;dzior: > I am trying to use pick event. ... > What am I doing wrong ? Wrong with WHAT? What do you expect? Jerzy Karczmarczuk -------------- next part -------------- An HTML attachment was scrubbed... ------------------------------ Message: 3 Date: Sat, 12 May 2012 10:59:39 -0400 From: Benjamin Root <ben...@ou...> Subject: Re: [Matplotlib-users] pick event To: "jer...@un..." <jer...@un...> Cc: "mat...@li..." <mat...@li...> Message-ID: <CAN...@ma...> Content-Type: text/plain; charset="utf-8" On Saturday, May 12, 2012, Jerzy Karczmarczuk wrote: > Arek K?dzior: > > I am trying to use pick event. > > ... > > What am I doing wrong ? > > Wrong with WHAT? > What do you expect? > > Jerzy Karczmarczuk > Arek. Could you provide a little more detail about your issue? Cheers! Ben Root -------------- next part -------------- An HTML attachment was scrubbed... ------------------------------ ------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ ------------------------------ _______________________________________________ Matplotlib-users mailing list Mat...@li... https://lists.sourceforge.net/lists/listinfo/matplotlib-users End of Matplotlib-users Digest, Vol 72, Issue 10 ************************************************ |
|
From: Arek K. <ake...@ya...> - 2012-05-12 16:36:06
|
If you pick one of the curves in the close location to tangancy area, the OnPick function will be ececuted twice (2 curves) and will display 2 markers. I want to find the shortest distance from the pick location (mouse coord.) to a discrete point on the curve and draw marker on the curve at this location (only one). See the line with "print lineObj" ________________________________ From: "mat...@li..." <mat...@li...> To: mat...@li... Sent: Saturday, May 12, 2012 10:59 AM Subject: Matplotlib-users Digest, Vol 72, Issue 10 Send Matplotlib-users mailing list submissions to mat...@li... To subscribe or unsubscribe via the World Wide Web, visit https://lists.sourceforge.net/lists/listinfo/matplotlib-users or, via email, send a message with subject or body 'help' to mat...@li... You can reach the person managing the list at mat...@li... When replying, please edit your Subject line so it is more specific than "Re: Contents of Matplotlib-users digest..." Today's Topics: 1. pick event (Arek Kedzior) 2. Re: pick event (Jerzy Karczmarczuk) 3. Re: pick event (Benjamin Root) ---------------------------------------------------------------------- Message: 1 Date: Sat, 12 May 2012 06:07:37 -0700 (PDT) From: Arek Kedzior <ake...@ya...> Subject: [Matplotlib-users] pick event To: "mat...@li..." <mat...@li...> Message-ID: <133...@we...> Content-Type: text/plain; charset="iso-8859-1" I am trying to use pick event.? See the simple script below.? I am interested to find the shortest distance between pick point (mouse coord.) and the ?line at the discrete points only (points on the curve from data) What am I doing wrong ? Regards, Arek ? import numpy as np import matplotlib.pyplot as plt from matplotlib.lines import Line2D import math as math ? # create figure and attach axes to it fig = plt.figure(1) ax = fig.add_subplot(111) ? ? def getMinDistance(xmouse, ymouse, xList, yList): ??? """ ??? find shortest distance between mouse coordinates and pick point ??? point pick may be a list of points if data is clouded ??? Input ??? xmouse - x coordinate of mouse (x - pick) ??? ymouse - y coordinate of mouse (y - pick) ??? xList? - xData from curve ??? yList? - yData from curve ??? Returns: ??? dmin? - minimum distance ??? index - index of data point in the xList and yList ??? """ ????dmin? = math.sqrt((xList[0] - xmouse)**2. + (yList[0]-ymouse)**2.)? ????index = 0 ??? for idx in range(1,len(xList)): ??????? d = math.sqrt((xList[idx] - xmouse)**2. + (yList[idx]-ymouse)**2.) ??????? if(d < dmin): ??????????? dmin = d ??????????? index = idx ????return dmin, index ? def showMarker(x, y, color): ??? """ ??? draw marker at loction x, y with color ??? """ ??? # draw marker ??? markerOn, = ax.plot(x, y, 'o', color = color) ???? def OnPick(event): ??? """ ??? pick event ??? """ ??? print '****************************' ??? mouseEvent = event.mouseevent ??? # get pick coord ??? xmouse, ymouse = mouseEvent.xdata, mouseEvent.ydata ??? # get the artist ??? lineObj = event.artist ????print lineObj ????if not isinstance(lineObj, Line2D): ??????? return ????ind = event.ind ????# check if indexes exist of the pick object ??? N = len(ind) ??? if not N: ??????? return ??? # get curve picked data ??? Xdata, Ydata = lineObj.get_data() ??? color = lineObj.get_color() ????xLi = np.take(Xdata, ind) ??? yLi = np.take(Ydata, ind) ??? dmin, index = getMinDistance(xmouse, ymouse, xLi, yLi) ??? ????xP = xLi[index] ??? yP = yLi[index] ??? ????xStr = '%.4g' % xP ??? yStr = '%.4g' % yP ??? txt = 'X = ' + xStr + ' ;? ' + 'Y = ' + yStr ??? print txt ??? # show marker ??? showMarker(xP, yP, color) ??? # redraw to show marker ??? fig.canvas.draw() ??? # connect to pick event??? fig.canvas.mpl_connect('pick_event',OnPick) ? # generate data for display x = np.arange(-4,4,0.1)????? # x- coord y2 = x**2 + 5.0????????????? # y coord of first curve y? = 2*x + 4.0?????????????? # y coord of the second curve # create the list of x and y data xList = [x, x]?????????????? yList = [y, y2] objList = []???? # store draw lines (artists) # display 2 curves for idx in range(len(xList)): ??? obj, = ax.plot(xList[idx], yList[idx], picker = 5) ??? objList.append(obj) ? # display plot plt.show(1) -------------- next part -------------- An HTML attachment was scrubbed... ------------------------------ Message: 2 Date: Sat, 12 May 2012 16:44:16 +0200 From: Jerzy Karczmarczuk <jer...@un...> Subject: Re: [Matplotlib-users] pick event To: mat...@li... Message-ID: <4FA...@un...> Content-Type: text/plain; charset="iso-8859-1" Arek Ke;dzior: > I am trying to use pick event. ... > What am I doing wrong ? Wrong with WHAT? What do you expect? Jerzy Karczmarczuk -------------- next part -------------- An HTML attachment was scrubbed... ------------------------------ Message: 3 Date: Sat, 12 May 2012 10:59:39 -0400 From: Benjamin Root <ben...@ou...> Subject: Re: [Matplotlib-users] pick event To: "jer...@un..." <jer...@un...> Cc: "mat...@li..." <mat...@li...> Message-ID: <CAN...@ma...> Content-Type: text/plain; charset="utf-8" On Saturday, May 12, 2012, Jerzy Karczmarczuk wrote: > Arek K?dzior: > > I am trying to use pick event. > > ... > > What am I doing wrong ? > > Wrong with WHAT? > What do you expect? > > Jerzy Karczmarczuk > Arek. Could you provide a little more detail about your issue? Cheers! Ben Root -------------- next part -------------- An HTML attachment was scrubbed... ------------------------------ ------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ ------------------------------ _______________________________________________ Matplotlib-users mailing list Mat...@li... https://lists.sourceforge.net/lists/listinfo/matplotlib-users End of Matplotlib-users Digest, Vol 72, Issue 10 ************************************************ |
|
From: Benjamin R. <ben...@ou...> - 2012-05-12 14:59:45
|
On Saturday, May 12, 2012, Jerzy Karczmarczuk wrote: > Arek Kędzior: > > I am trying to use pick event. > > ... > > What am I doing wrong ? > > Wrong with WHAT? > What do you expect? > > Jerzy Karczmarczuk > Arek. Could you provide a little more detail about your issue? Cheers! Ben Root |
|
From: Jerzy K. <jer...@un...> - 2012-05-12 14:44:29
|
Arek Ke;dzior: > I am trying to use pick event. ... > What am I doing wrong ? Wrong with WHAT? What do you expect? Jerzy Karczmarczuk |
|
From: Arek K. <ake...@ya...> - 2012-05-12 13:07:44
|
I am trying to use pick event. See the simple script
below. I am interested to find the shortest distance between pick
point (mouse coord.) and the line at the discrete points only (points on
the curve from data)
What am I doing wrong ?
Regards,
Arek
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.lines import Line2D
import math as math
# create figure and attach axes to it
fig = plt.figure(1)
ax = fig.add_subplot(111)
def getMinDistance(xmouse, ymouse, xList, yList):
"""
find shortest distance between mouse
coordinates and pick point
point pick may be a list of points if
data is clouded
Input
xmouse - x coordinate of mouse (x - pick)
ymouse - y coordinate of mouse (y - pick)
xList - xData from curve
yList - yData from curve
Returns:
dmin - minimum distance
index - index of data point in the xList
and yList
"""
dmin = math.sqrt((xList[0] -
xmouse)**2. + (yList[0]-ymouse)**2.)
index = 0
for idx in range(1,len(xList)):
d =
math.sqrt((xList[idx] - xmouse)**2. + (yList[idx]-ymouse)**2.)
if(d < dmin):
dmin = d
index = idx
return dmin, index
def showMarker(x, y, color):
"""
draw marker at loction x, y with color
"""
# draw marker
markerOn, = ax.plot(x, y, 'o', color =
color)
def OnPick(event):
"""
pick event
"""
print '****************************'
mouseEvent = event.mouseevent
# get pick coord
xmouse, ymouse = mouseEvent.xdata,
mouseEvent.ydata
# get the artist
lineObj = event.artist
print lineObj
if not isinstance(lineObj, Line2D):
return
ind = event.ind
# check if indexes exist of the pick
object
N = len(ind)
if not N:
return
# get curve picked data
Xdata, Ydata = lineObj.get_data()
color = lineObj.get_color()
xLi = np.take(Xdata, ind)
yLi = np.take(Ydata, ind)
dmin, index = getMinDistance(xmouse,
ymouse, xLi, yLi)
xP = xLi[index]
yP = yLi[index]
xStr = '%.4g' % xP
yStr = '%.4g' % yP
txt = 'X = ' + xStr + ' ; ' + 'Y =
' + yStr
print txt
# show marker
showMarker(xP, yP, color)
# redraw to show marker
fig.canvas.draw()
# connect to pick event
fig.canvas.mpl_connect('pick_event',OnPick)
# generate data for display
x = np.arange(-4,4,0.1) # x-
coord
y2 = x**2 + 5.0
# y coord of first curve
y = 2*x +
4.0
# y coord of the second curve
# create the list of x and y data
xList = [x,
x]
yList = [y, y2]
objList = [] # store draw lines
(artists)
# display 2 curves
for idx in range(len(xList)):
obj, = ax.plot(xList[idx], yList[idx],
picker = 5)
objList.append(obj)
# display plot
plt.show(1) |
|
From: David C. <dcd...@gm...> - 2012-05-10 15:11:19
|
Hi,
I'm having a problem using matplotlibs barbs function. I'm trying to
plot some wind barbs on a map created with basemap. My code is as follows,
m =
Basemap(llcrnrlon=-35.0,llcrnrlat=40.0,urcrnrlon=10.0,urcrnrlat=68.0,
resolution='i',projection='lcc',lon_0=-12.5,lat_0=54.0)
m.drawcoastlines()
m.bluemarble()
m.drawcoastlines()
# draw parallels
m.drawparallels(np.arange(40,68,5),labels=[1,0,0,0])
# draw meridians
m.drawmeridians(np.arange(-35, 10, 5),labels=[0,0,0,1])
x, y = m(lons, lats)
m.barbs(lons,lats,us,vs, barbcolor = 'r', flagcolor = 'r')
plt.show()
where x, y, us and vs are lists with shape (64,). I get the following error,
ERROR: An unexpected error occurred while tokenizing input
The following traceback may be corrupted or invalid
The error message is: ('EOF in multi-line statement', (382, 0))
---------------------------------------------------------------------------
ValueError Traceback (most recent
call last)
/home/davcra/python_scripts/plot_synops.py in <module>()
63 #m.plot(x,y,'ro', ms=5)
64 plt.suptitle(record['date'])
---> 65 m.barbs(x,y,us,vs, barbcolor = 'r', flagcolor = 'r')
66 #m.xlim(-35.0, 10.0)
67 #m.ylim(40.0, 68.0)
/usr/lib64/python2.6/site-packages/mpl_toolkits/basemap/__init__.pyc
in barbs(self, x, y, u, v, *args, **kwargs)
2924 retnh = ax.barbs(x,y,unh,vnh,*args,**kwargs)
2925 kwargs['flip_barb']=True
-> 2926 retsh = ax.barbs(x,y,ush,vsh,*args,**kwargs)
2927 try:
2928 plt.draw_if_interactive()
/usr/lib64/python2.6/site-packages/matplotlib/axes.pyc in
barbs(self, *args, **kw)
5888 """
5889 if not self._hold: self.cla()
-> 5890 b = mquiver.Barbs(self, *args, **kw)
5891 self.add_collection(b)
5892 self.update_datalim(b.get_offsets())
/usr/lib64/python2.6/site-packages/matplotlib/quiver.pyc in
__init__(self, ax, *args, **kw)
776 self.set_transform(transforms.IdentityTransform())
777
--> 778 self.set_UVC(u, v, c)
779
780 __init__.__doc__ = """
/usr/lib64/python2.6/site-packages/matplotlib/quiver.pyc in
set_UVC(self, U, V, C)
952
953 def set_UVC(self, U, V, C=None):
--> 954 self.u = ma.masked_invalid(U, copy=False).ravel()
955 self.v = ma.masked_invalid(V, copy=False).ravel()
956 if C is not None:
/usr/lib64/python2.6/site-packages/numpy/ma/core.pyc in
masked_invalid(a, copy)
1976 condition = ~(np.isfinite(a))
1977 if hasattr(a, '_mask'):
-> 1978 condition = mask_or(condition, a._mask)
1979 cls = type(a)
1980 else:
/usr/lib64/python2.6/site-packages/numpy/ma/core.pyc in mask_or(m1,
m2, copy, shrink)
1383 _recursive_mask_or(m1, m2, newmask)
1384 return newmask
-> 1385 return make_mask(umath.logical_or(m1, m2), copy=copy,
shrink=shrink)
1386
1387
/usr/lib64/python2.6/site-packages/numpy/ma/core.pyc in make_mask(m,
copy, shrink, flag, dtype)
1265 # We won't return after this point to make sure we
can shrink the mask
1266 # Fill the mask in case there are missing data
-> 1267 m = filled(m, True)
1268 # Make sure the input dtype is valid
1269 dtype = make_mask_descr(dtype)
/usr/lib64/python2.6/site-packages/numpy/ma/core.pyc in filled(a,
fill_value)
406 """
407 if hasattr(a, 'filled'):
--> 408 return a.filled(fill_value)
409 elif isinstance(a, ndarray):
410 # Should we check for contiguity ? and
a.flags['CONTIGUOUS']:
/usr/lib64/python2.6/site-packages/numpy/ma/core.pyc in filled(self,
fill_value)
2929 result = self._data.copy()
2930 try:
-> 2931 np.putmask(result, m, fill_value)
2932 except (TypeError, AttributeError):
2933 fill_value = narray(fill_value, dtype=object)
ValueError: putmask: mask and data must be the same size
WARNING: Failure executing file: <plot_synops.py>
Anyone know whats going on here??
Thanks in advance,
D
|
|
From: stecue <st...@gm...> - 2012-05-08 22:26:53
|
Dear All, I've figured out that I can use LinearLocator and set ylim manually to fix the number of ticks. But I still don't know to set the display precision of the scientific notation. Currently I can only work around this by choosing proper limits and number of ticks manually. Is there anyway to fore the display precision (i.e, "3.33x10^-6" instead of "3.33333333333 x10^-6") ? Thanks very much! Sincerely yours Xing On 05/05/2012 01:13 AM, stecue wrote: > Hi, > > I'm plotting figures for a series of data set and I want to keep the > looking consistent with each other. Currently I'm using MaxNLocator > and ScalarFormatter but still, > > 1. Is there a way to limit the minimum number of ticks for > MaxNLocator? Currently, if I set nbins=5, the number of ticks varies > from 2 to 5. The variation is too large for me. I tried FixedLocator > but then I lost the ability to set "ylim" (or "xlim") automatically. > > 2. About the scientific notation of ScalarFormatter, can I fix the > number of decimal places? Currently, the notation will be "2x10^-5" in > some figures, while "2.50x10^-5" in other figures. I need all tick > labels to have the same number of decimal places. > > I've searched the online documents for hours but cann't find the > answer... any ideas? > > Thanks! > |
|
From: Jonathan S. <js...@cf...> - 2012-05-08 12:41:34
|
The example here: http://matplotlib.sourceforge.net/examples/pylab_examples/dash_control.html?highlight=set_dashes will probably help. Jon > See the API document of plot(): > > http://matplotlib.sourceforge.net/api/axes_api.html#matplotlib.axes.Axes.plot > > You may try different combinations of linestyle and marker to achieve > your desired style. > > ~Pengkui > > > On Fri, May 4, 2012 at 10:39 AM, Chao YUE <cha...@gm...> > wrote: > Dear all, > > Is it possible to have a customized linestyle for line plots? > such as I want '--.--.--.' or '-*-*-*' or others. > > I read the documentation part of set_drawstyle and a post > here: > http://old.nabble.com/Changing-the-Dash-Spacing--td33381003.html#a33381003 > > but still not clear. Could anyone give a very small example? > > thanks et cheers, > > Chao |