[Matplotlib-users] Relpos only works once when using FancyArrow for annotation

2011-11-28 Thread Markus Baden
Hi list,

I'm trying to annotate points on a graph by drawing a simple line from the
point on the axis to the top left corner of the text. I can't figure out,
how to use pyplot.annotate so that it turns of the arrow head and I can use
horizontalalignment (ha) and verticalalignment (va). When I use
arrowstyle='-' in the arrowprops dictionary ha and va don't work. Instead I
use relpos=(0, 1) in the arrowprops dictionary, which works, but only when
I call the annotate function the first time. Below is a minimal example.

I'm using mpl version 1.0. as part of EPD 7.1 on Mac OS X 10.5.

Any hints on how to achieve my goal would be greatly appreciated!

Best regards,

Markus

---

The following code reproduces my problem

import numpy as np
import matplotlib.pyplot as plt

data = np.linspace(1,10)
plt.plot(data, data)
anno_args = {
'annotation_clip': False,
'arrowprops': dict(arrowstyle='-', relpos=(0, 1)),
}
plt.annotate('Good relpos', (3, 3), xytext = (3, 2), **anno_args)
plt.annotate('Bad relpos', (6, 6), xytext = (6, 5), **anno_args)
plt.annotate('No ha/va', (5, 5), xytext = (5, 4),
arrowprops=dict(arrowstyle='-'),
 ha='left', va='top')
plt.show()
--
All the data continuously generated in your IT infrastructure 
contains a definitive record of customers, application performance, 
security threats, fraudulent activity, and more. Splunk takes this 
data and makes sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-novd2d___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Relpos only works once when using FancyArrow for annotation

2011-11-28 Thread Jae-Joon Lee
On Mon, Nov 28, 2011 at 9:39 PM, Markus Baden markus.ba...@gmail.com wrote:
 anno_args = {
     'annotation_clip': False,
     'arrowprops': dict(arrowstyle='-', relpos=(0, 1)),
     }
 plt.annotate('Good relpos', (3, 3), xytext = (3, 2), **anno_args)
 plt.annotate('Bad relpos', (6, 6), xytext = (6, 5), **anno_args)

This is a bug. In the current implementation, annotate has a
side-effect that modifies the arrowprops dictionary.
As a workaround, you may do,

arrowprops = dict(arrowstyle='-', relpos=(0, 1))
plt.annotate('Good relpos', (3, 3), xytext = (3, 2),
 annotation_clip=False, arrowprops=arrowprops.copy())


 plt.annotate('No ha/va', (5, 5), xytext = (5, 4),
 arrowprops=dict(arrowstyle='-'),
  ha='left', va='top')


ha and va controls the location of the text relative to the xytext,
and I believe it does work as expected. It has nothing to do with the
starting point of the arrow, which should be controlled by the relpos
parameter.

Regards,

-JJ

--
All the data continuously generated in your IT infrastructure 
contains a definitive record of customers, application performance, 
security threats, fraudulent activity, and more. Splunk takes this 
data and makes sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-novd2d
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Basemap drawparallels failed issue

2011-11-28 Thread Jeff Whitaker
On 11/22/11 12:51 PM, Dave Xia wrote:
 Hi,

 I am a new user of matplotlib Basemap. I tried to draw  the latitude 
 with interval 0.1 degree using drawparallels, but failed.  I wonder if 
 the drawparallels can draw latitude lines with small interval instead 
 of integer values. (drawmeridian can work with small interval 0.1).

 Does anyone have any idea to fix this issue?

 Thanks!

 Dave
Confirmed.  This is now fixed in github master.  It's a one-liner, so 
you can manually patch your source if you prefer.

Just change line 2067 in lib/mpl_toolkits/basemap/__init__.py from

if t is not None: linecolls[int(lat)][1].append(t)

to

if t is not None: linecolls[lat][1].append(t)

Regards,

Jeff

--
All the data continuously generated in your IT infrastructure 
contains a definitive record of customers, application performance, 
security threats, fraudulent activity, and more. Splunk takes this 
data and makes sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-novd2d
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Possible bug processing events outisde

2011-11-28 Thread abccoeur . t . tos
Hello,

On matplotlib's home, there is a demo ( a program called legend_picking.py
) were one can click on the lines in the legend of a plot to hide / unhide
the corresponding plot lines.

However there is a problem when the click takes place outside the main
canvas (the white space).

I made a small project demonstrating the problem:
1) Normally the legend should hold 2 lines: a red one on the top (it should
be outside the canvas) and, below it a red line (it should be within the
canvas). If this is not the case you may have to tweak the loc=(0,0.95)
parameters to get to this situation.
2) Click on the blue line. Everything is normal: the blue plot goes on and
off on the canvas.
3) Click on the red line. The event handler is called twice, hiding and
unhiding the red plot (visible via the print statement in the function)
This makes it impossible to hide the plot.

Thank you for reading,
Tos

The code follows:
import matplotlib.pyplot as plt

fig=plt.figure()
ax = fig.add_subplot(111)
# Plot
p0,=plt.plot([0,1,2,3], 'r')
p1,=plt.plot([3,0,6,2], 'b')
#leg=plt.legend()
#leg = ax.legend(('Sausage length', 'Sauerkraut Vitamin content', 'Total
message length'), 'upper center', shadow=True)
leg = ax.legend(('Sausage length', 'Sauerkraut Vitamin content', 'Total
message length'), loc=(0,0.95), shadow=True)

# we will set up a dict mapping legend line to orig line, and enable
# picking on the legend line
lines = [p0, p1]
lined = dict()

for legline, origline in zip(leg.get_lines(), lines):
legline.set_picker(5)  # pts tolerance
lined[legline] = origline

def onpick(event):
print 'in onpick'
# on the pick event, find the orig line corresponding to the
# legend proxy line, and toggle the visibilit
legline = event.artist
origline = lined[legline]
print 'origline=', origline
vis = not origline.get_visible()
origline.set_visible(vis)
print 'vis=', vis
# Change the alpha on the line in the legend so we can see what lines
# have been toggled
if vis:
legline.set_alpha(1.0)
else:
legline.set_alpha(0.2)
fig.canvas.draw()

fig.canvas.mpl_connect('pick_event', onpick)
plt.show()
--
All the data continuously generated in your IT infrastructure 
contains a definitive record of customers, application performance, 
security threats, fraudulent activity, and more. Splunk takes this 
data and makes sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-novd2d___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Removing ticks and frame (imshow)

2011-11-28 Thread Tony Yu
On Thu, Nov 24, 2011 at 9:48 AM, Marianne C. mariyann...@gmail.com wrote:

 Hi all,

 My name is Marianne, I am a beginner user of matplotlib.
 I am using imshow in pyplot.  I am desperate to get rid of
 the ticks on both x and y axes (see attached picture).  I
 do not need the black box around the data either.  Should
 I use imshow in axes.Axes instead, to be able to call

 set_ticks_position(none)?

 Thank you for your help,
 Marianne

 Here is the code so far:

 import numpy
 from matplotlib import pyplot

 q=numpy.loadtxt('field.txt')

 myfield = pyplot.imshow(q,aspect=1)
 myfield.set_clim(vmin=0, vmax=0.6)

 pyplot.colorbar()

 pyplot.savefig('field_1.eps')



There are a number of ways to accomplish this, but the one I use is to make
the x and y axes invisible (gets rid of the ticks) and also make the spines
invisible (gets rid of the lines). I just throw these changes into a
utility function (`clear_frame` below) and put that in a module that's on
my python path so that it's easily reusable.

Hope that helps,
-Tony

#~~~
import numpy as np
import matplotlib.pyplot as plt

def clear_frame(ax=None):
if ax is None:
ax = plt.gca()
ax.xaxis.set_visible(False)
ax.yaxis.set_visible(False)
for spine in ax.spines.itervalues():
spine.set_visible(False)

img = np.random.random((100,100))
plt.imshow(img)
clear_frame()

plt.colorbar()

plt.show()
#~~~
--
All the data continuously generated in your IT infrastructure 
contains a definitive record of customers, application performance, 
security threats, fraudulent activity, and more. Splunk takes this 
data and makes sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-novd2d___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Removing ticks and frame (imshow)

2011-11-28 Thread Sterling Smith
 
 From: Marianne C. mariyann...@gmail.com
 Date: November 24, 2011 6:48:34 AM PST
 To: matplotlib-users@lists.sourceforge.net
 Subject: [Matplotlib-users] Removing ticks and frame (imshow)
 
 
 Hi all,
 
 My name is Marianne, I am a beginner user of matplotlib.
 I am using imshow in pyplot.  I am desperate to get rid of
 the ticks on both x and y axes (see attached picture).  I
 do not need the black box around the data either.  Should
 I use imshow in axes.Axes instead, to be able to call
 set_ticks_position(none)?
 Thank you for your help,
 Marianne
 
 Here is the code so far:
 
 import numpy
 from matplotlib import pyplot
 
 q=numpy.loadtxt('field.txt')
 
 myfield = pyplot.imshow(q,aspect=1)
 myfield.set_clim(vmin=0, vmax=0.6)
 
 pyplot.colorbar()
 
 pyplot.savefig('field_1.eps')
 
 field_1.pdf

Marianne,

Try

myfield.get_axes().axis('off')

-Sterling


--
All the data continuously generated in your IT infrastructure 
contains a definitive record of customers, application performance, 
security threats, fraudulent activity, and more. Splunk takes this 
data and makes sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-novd2d
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Specify plot xticks

2011-11-28 Thread Shankararaman Ramakrishnan
Hello,

 

I am fairly new to Matplotlib and appreciate your help with my question:


 

I am looking to generate a time series trend plots and include as my
xtick labels a selective list of strings. For ex: Month/Year label for
data corresponding to the 1st day of each month. I may be plotting 365
days of data but want to show only 12 xtick labels. 

 

Would it be possible to specify grid lines for every 7 days of data for
instance? This makes the grid line locations different from the xtick
label locations. 

 

I am sure there is support for such a feature in Matplotlib. I did look
through the docs/forums but could not find much help.

Any suggestions will be much appreciated. 

 

Thanks,
Shankar

--
All the data continuously generated in your IT infrastructure 
contains a definitive record of customers, application performance, 
security threats, fraudulent activity, and more. Splunk takes this 
data and makes sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-novd2d___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] help with custom formatter rules

2011-11-28 Thread C M
As related to another question(s) I've posted, can someone help with this
custom formatter?  This is for use in a FunctionFormatter to be used on the
y axis to format the ticks (in particular, to remove them when not
wanted).  Example:

def CustomFormatter(self,y,i):
if y  0:
return ''

This says if the value of y  0, put nothing on the axis tick.

QUESTION:  How can I implement the following two sorts of rules in
Matplotlib's (OO) API?

def CustomFormatter(self,y,i):
if y falls in the bottom 50 pixels' worth of height of this plot:
return ''

or

def CustomFormatter(self,y,i):
if y falls in the bottom 10% of the height of this plot:
return ''

Thanks,
Che
--
All the data continuously generated in your IT infrastructure 
contains a definitive record of customers, application performance, 
security threats, fraudulent activity, and more. Splunk takes this 
data and makes sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-novd2d___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Using Widgets, Extending imshow

2011-11-28 Thread Austin Godber
Hello,

Are there examples of extending imshow or further customizing any of
the UI components of matpotlib?  Or anything you can point me at to
get started?  I have been able to connect events to imshow.  An
example of the type of thing I might want to do is to print the R,G,B
value in a status bar when I hover over an x y coordinate of an image.

-- 
Austin Godber

--
All the data continuously generated in your IT infrastructure 
contains a definitive record of customers, application performance, 
security threats, fraudulent activity, and more. Splunk takes this 
data and makes sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-novd2d
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Relpos only works once when using FancyArrow for annotation

2011-11-28 Thread Markus Baden
 This is a bug. In the current implementation, annotate has a
 side-effect that modifies the arrowprops dictionary.
 As a workaround, you may do,

 arrowprops = dict(arrowstyle='-', relpos=(0, 1))
 plt.annotate('Good relpos', (3, 3), xytext = (3, 2),

 annotation_clip=False, arrowprops=arrowprops.copy())


Works for me. Thanks a lot!



  plt.annotate('No ha/va', (5, 5), xytext = (5, 4),
  arrowprops=dict(arrowstyle='-'),
   ha='left', va='top')
 

 ha and va controls the location of the text relative to the xytext,
 and I believe it does work as expected. It has nothing to do with the
 starting point of the arrow, which should be controlled by the relpos
 parameter.


Thanks for clarifying.

Regards,

Markus
--
All the data continuously generated in your IT infrastructure 
contains a definitive record of customers, application performance, 
security threats, fraudulent activity, and more. Splunk takes this 
data and makes sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-novd2d___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users