Re: [Matplotlib-users] Matplotlib gray area around plot

2013-05-16 Thread blueone
Thank you very much! This is exactly what i was looking for! 



--
View this message in context: 
http://matplotlib.1069221.n5.nabble.com/Matplotlib-gray-area-around-plot-tp41073p41076.html
Sent from the matplotlib - users mailing list archive at Nabble.com.

--
AlienVault Unified Security Management (USM) platform delivers complete
security visibility with the essential security capabilities. Easily and
efficiently configure, manage, and operate all of your security controls
from a single console and one unified framework. Download a free trial.
http://p.sf.net/sfu/alienvault_d2d
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Squashed axes with AxesGrid

2013-05-16 Thread Matthias Flor
Hi all,

it seems that I am experiencing the same problem here with imshow (rather
than scatter) and AxesGrid. But calling imshow with aspect=False does not do
the trick for me.
I am trying to have two imshow subplots next to each other and a single
colorbar at the right. The data underlying the imshow's have different x-
and y-ranges but I want the x- and y-axis to have an aspect ratio of 1 (i.e.
each imshow should produce a square). I've tried aspect=False,
aspect='equal', and explicitely setting aspect=2 which should be the correct
value. See the three images below the code example.

I've also tried Grid instead of AxesGrid as suggested but I didn't manage to
achieve good results with the colorbar in that case.

I'd appreciate any help,

Matthias



Here's a more or less minimal code example:
#
import numpy as np
import numpy.random as npr
from scipy.interpolate import griddata
import matplotlib.pyplot as plt
from mpl_toolkits.axes_grid1 import AxesGrid

fig = figure(1, figsize=[12,10])

grid = AxesGrid(fig, 111,
nrows_ncols = (1, 2),
axes_pad = 0.2,
share_all = False,
label_mode = 'L',
cbar_location = 'right',
cbar_mode = 'single',
cbar_pad = 0.2
)

for i in range(2):  
xmin, xmax = 0., 1.
ymin, ymax = 0., 0.5
zmin, zmax = -1., 1.

# generate random data:
N = 100
X = xmin + (xmax-xmin)*npr.random((N,))  # x_i in [0, 1]
Y = ymin + (ymax-ymin)*npr.random((N,))  # y_i in [0, 0.5]
Z = zmin + (zmax-zmin)*npr.random((N,))  # z_i in [-1, 1]

# generate griddata for imshow plot:
numspaces = np.sqrt(N)
xi = linspace(xmin, xmax, numspaces)
yi = linspace(ymin, ymax, numspaces)
zi = griddata((X, Y), Z, (xi[None,:], yi[:,None]), method='nearest')
norm = matplotlib.colors.normalize(vmin=zmin, vmax=zmax)

ax = grid[i]
im = ax.imshow(zi,
extent = [xmin,xmax,ymin,ymax],  
norm = norm, 
vmin = zmin,
vmax = zmax, 
origin = 'lower', 
aspect = 'equal', # or False, or 'auto', or 2, or ...
interpolation = 'nearest')

ax.grid(False)
ax.set_xlabel('x')
ax.set_ylabel('y')

# add a colorbar:
cbar = plt.colorbar(im, cax=grid.cbar_axes[0])
cbar.ax.set_ylabel('color level')


And here are the three resulting images:

aspect='equal':
 

aspect=False:
 

aspect=2.:
 



--
View this message in context: 
http://matplotlib.1069221.n5.nabble.com/Squashed-axes-with-AxesGrid-tp40699p41075.html
Sent from the matplotlib - users mailing list archive at Nabble.com.

--
AlienVault Unified Security Management (USM) platform delivers complete
security visibility with the essential security capabilities. Easily and
efficiently configure, manage, and operate all of your security controls
from a single console and one unified framework. Download a free trial.
http://p.sf.net/sfu/alienvault_d2d
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Matplotlib gray area around plot

2013-05-16 Thread Benjamin Root
On Thu, May 16, 2013 at 2:41 PM, blueone  wrote:

> Hi,
>
> I am working on my first project involving Matplotlib. I haven't used it
> much, but i'm already impressed by it!
> The project i am working on uses Matplotlib embedded in wxPython. I have
> already embedded it successfully, but there is one thing that i would still
> like to change and that is the gray area around the plot. The background of
> the plot is white and around it there's this thick gray rectangle. Is there
> a way of making it smaller?
>
> Thanks in advance!
>
>
>
You can adjust the margins using subplots_adjust():
http://matplotlib.org/api/pyplot_api.html#matplotlib.pyplot.subplots_adjust

Cheers!
Ben Root
--
AlienVault Unified Security Management (USM) platform delivers complete
security visibility with the essential security capabilities. Easily and
efficiently configure, manage, and operate all of your security controls
from a single console and one unified framework. Download a free trial.
http://p.sf.net/sfu/alienvault_d2d___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Matplotlib gray area around plot

2013-05-16 Thread blueone
Hi,

I am working on my first project involving Matplotlib. I haven't used it
much, but i'm already impressed by it!
The project i am working on uses Matplotlib embedded in wxPython. I have
already embedded it successfully, but there is one thing that i would still
like to change and that is the gray area around the plot. The background of
the plot is white and around it there's this thick gray rectangle. Is there
a way of making it smaller?

Thanks in advance!



--
View this message in context: 
http://matplotlib.1069221.n5.nabble.com/Matplotlib-gray-area-around-plot-tp41073.html
Sent from the matplotlib - users mailing list archive at Nabble.com.

--
AlienVault Unified Security Management (USM) platform delivers complete
security visibility with the essential security capabilities. Easily and
efficiently configure, manage, and operate all of your security controls
from a single console and one unified framework. Download a free trial.
http://p.sf.net/sfu/alienvault_d2d
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] legend marker update problem

2013-05-16 Thread Sterling Smith
Gregorio,

I experienced a similar issue with trying to change the marker color.  

See below the previous response from JJ for accessing the legend marker or 
using a proxy artist.

-Sterling

> On Sep 4, 2012, at 5:33PM, Jae-Joon Lee wrote:
> 
> On Wed, Sep 5, 2012 at 6:05 AM, Sterling Smith  wrote:
>> I still do not get black markers.  Furthermore, if you try to make a new 
>> legend with the result of leg.get_lines(), you will get lines without 
>> markers, which leads me to the conclusion I stated in my previous email 
>> (which you did not copy)
 I suspect that this is because the legend marker is drawn separately from 
 the legend line to accommodate the numpoints argument of the legend 
 functions.  Then the question is how to access these markers if they are 
 separate from the line2d objects in the legend.  I didn't even see them in 
 the children of the legend [legend.get_children()].
> 
> This is correct. To support legend handle like --o-- (i.e., no markers
> at the ends), lines and markers are drawn as a separate artist. You
> may use something like,
> 
> line[0]._legmarker.set_markerfacecolor('black')
> line[1]._legmarker.set_markerfacecolor('black')
> 
> I, personally, recommend you to use a proxy artist.
> 
> http://matplotlib.sourceforge.net/users/legend_guide.html#using-proxy-artist
> 
> For example,
> 
> You may do something like
> 
> import pylab
> pylab.plot(pylab.linspace(0,1,100),marker='o',ls='')
> pylab.plot(pylab.linspace(0,1,100),marker='o',ls='-')
> 
> # creates artists for legend purpose only
> l1, = pylab.plot(pylab.linspace(0,1,100), 'ko-')
> l2, = pylab.plot(pylab.linspace(0,1,100), 'ko')
> # remove them from the axes.
> l1.remove()
> l2.remove()
> 
> leg=pylab.legend([l1, l2], ["Test 1", "Test 2"], loc='best')
> 
> Regards,
> 
> -JJ
On May 16, 2013, at 7:25AM, Gregorio Bastardo wrote:

> Hi,
> 
> I've recently come accross an issue when working on an interactive
> marker toggling callback. The problem is illustrated below:
> 
> import matplotlib.pyplot as plt
> fig = plt.figure()
> ax = fig.add_subplot(111)
> line, = ax.plot(range(10), range(10))
> # uncomment next line to reproduce bug
> # line.set_marker('d')
> legend = ax.legend([line], ['foo'])
> legend_line, = legend.get_lines()
> fig.show()
> raw_input('press enter to clear marker')
> line.set_marker('')
> legend_line.set_marker('')
> fig.canvas.draw()
> raw_input('press enter to set marker')
> line.set_marker('d')
> legend_line.set_marker('d')
> fig.canvas.draw()
> raw_input('press enter to exit')
> 
> So when I add a line object to the legend *without marker*, the update
> works fine both on data and legend line, but *with marker* it does not
> refresh the legend line. I consider it as a bug, please tell me if I'm
> doing something wrong.
> 
> python 2.7.4 win32
> matplotlib 1.2.1
> 
> Thanks,
> Gregorio
> 
> --
> AlienVault Unified Security Management (USM) platform delivers complete
> security visibility with the essential security capabilities. Easily and
> efficiently configure, manage, and operate all of your security controls
> from a single console and one unified framework. Download a free trial.
> http://p.sf.net/sfu/alienvault_d2d
> ___
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users


--
AlienVault Unified Security Management (USM) platform delivers complete
security visibility with the essential security capabilities. Easily and
efficiently configure, manage, and operate all of your security controls
from a single console and one unified framework. Download a free trial.
http://p.sf.net/sfu/alienvault_d2d
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] legend marker update problem

2013-05-16 Thread Gregorio Bastardo
Hi,

I've recently come accross an issue when working on an interactive
marker toggling callback. The problem is illustrated below:

import matplotlib.pyplot as plt
fig = plt.figure()
ax = fig.add_subplot(111)
line, = ax.plot(range(10), range(10))
# uncomment next line to reproduce bug
# line.set_marker('d')
legend = ax.legend([line], ['foo'])
legend_line, = legend.get_lines()
fig.show()
raw_input('press enter to clear marker')
line.set_marker('')
legend_line.set_marker('')
fig.canvas.draw()
raw_input('press enter to set marker')
line.set_marker('d')
legend_line.set_marker('d')
fig.canvas.draw()
raw_input('press enter to exit')

So when I add a line object to the legend *without marker*, the update
works fine both on data and legend line, but *with marker* it does not
refresh the legend line. I consider it as a bug, please tell me if I'm
doing something wrong.

python 2.7.4 win32
matplotlib 1.2.1

Thanks,
Gregorio

--
AlienVault Unified Security Management (USM) platform delivers complete
security visibility with the essential security capabilities. Easily and
efficiently configure, manage, and operate all of your security controls
from a single console and one unified framework. Download a free trial.
http://p.sf.net/sfu/alienvault_d2d
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users