windrose

Dear users,
Below is a sample script I got from windrose pack. I would like to place 2 windroses side by side so that a comparison can be made. For example I have created additional variables ws1 wd1, and I would like that to be placed in the same row as a 1 row 2 column way. Any help in this regard will be great. (I tried subplot(221) subplot(222) but it do not work as the windrose uses new axis each time.)

from windrose import WindroseAxes
from matplotlib import pyplot as plt
import matplotlib.cm as cm
from numpy.random import random
from numpy import arange

#Create wind speed and direction variables
ws = random(500)*6
wd = random(500)*360
ws1 = random(500)*6
wd1 = random(500)*360
def new_axes():
fig = plt.figure(figsize=(8, 8), dpi=80, facecolor='w', edgecolor='w')
rect = [0.1, 0.1, 0.8, 0.8]
ax = WindroseAxes(fig, rect, axisbg='w')
fig.add_axes(ax)
return ax

def set_legend(ax):
l = ax.legend(axespad=-0.10)
plt.setp(l.get_texts(), fontsize=8)

#windrose like a stacked histogram with normed (displayed in percent) results
ax = new_axes()
ax.bar(wd, ws, normed=True, opening=0.8, edgecolor='white')
set_legend(ax)

#Another stacked histogram representation, not normed, with bins limits
##print ax._info
plt.show()

···

***************************************************************
Sudheer Joseph
Indian National Centre for Ocean Information Services
Ministry of Earth Sciences, Govt. of India
POST BOX NO: 21, IDA Jeedeemetla P.O.
Via Pragathi Nagar,Kukatpally, Hyderabad; Pin:5000 55
Tel:+91-40-23886047(O),Fax:+91-40-23895011(O),
Tel:+91-40-23044600(R),Tel:+91-40-9440832534(Mobile)
E-mail:sjo.India@...287...;sudheer.joseph@...9...
Web- http://oppamthadathil.tripod.com
***************************************************************

          Below is a sample script I got from windrose pack. I would like to place 2 windroses side by side

...

from windrose import WindroseAxes
from matplotlib import pyplot as plt

...

def new_axes():
    fig = plt.figure(figsize=(8, 8), dpi=80, facecolor='w', edgecolor='w')
    rect = [0.1, 0.1, 0.8, 0.8]
    ax = WindroseAxes(fig, rect, axisbg='w')
    fig.add_axes(ax)
    return ax

I'm not familiar with the windrose package, but it looks like the rect
parameter to WindroseAxes specifies the size of the generated axes in
figure co-ordinates (see
http://matplotlib.org/api/figure_api.html?highlight=add_axes#matplotlib.figure.Figure.add_axes).
You should be able to pass in a different list of co-ordinates for
each WindroseAxes to get side-by-side axes on the same figure...

Cheers,
Scott

···

On 4 April 2013 06:45, Sudheer Joseph <sudheer.joseph@...9...> wrote:

Thank you Scott,

Some how I am not getting the trick of the
rect = [0.1, 0.1, 0.8, 0.8]

I tried
rect1= [0.1,0.1,.4,.4]
and rect2=[.4,.4,.8,.8]
but did not work
Sudheer

···

***************************************************************
Sudheer Joseph
Indian National Centre for Ocean Information Services
Ministry of Earth Sciences, Govt. of India
POST BOX NO: 21, IDA Jeedeemetla P.O.
Via Pragathi Nagar,Kukatpally, Hyderabad; Pin:5000 55
Tel:+91-40-23886047(O),Fax:+91-40-23895011(O),
Tel:+91-40-23044600(R),Tel:+91-40-9440832534(Mobile)
E-mail:sjo.India@...287...;sudheer.joseph@...9...
Web- http://oppamthadathil.tripod.com
***************************************************************

----- Original Message -----

From: Scott Sinclair <scott.sinclair.za@...287...>
To: "matplotlib-users@lists.sourceforge.net" <matplotlib-users@...1544...ceforge.net>
Cc:
Sent: Thursday, 4 April 2013 12:37 PM
Subject: Re: [Matplotlib-users] windrose

On 4 April 2013 06:45, Sudheer Joseph <sudheer.joseph@...9...> wrote:

       Below is a sample script I got from windrose pack\. I would like 

to place 2 windroses side by side
...

from windrose import WindroseAxes
from matplotlib import pyplot as plt

...

def new_axes():
fig = plt.figure(figsize=(8, 8), dpi=80, facecolor='w',

edgecolor='w')

 rect = \[0\.1, 0\.1, 0\.8, 0\.8\]
 ax = WindroseAxes\(fig, rect, axisbg=&#39;w&#39;\)
 fig\.add\_axes\(ax\)
 return ax

I'm not familiar with the windrose package, but it looks like the rect
parameter to WindroseAxes specifies the size of the generated axes in
figure co-ordinates (see
http://matplotlib.org/api/figure_api.html?highlight=add_axes#matplotlib.figure.Figure.add_axes).
You should be able to pass in a different list of co-ordinates for
each WindroseAxes to get side-by-side axes on the same figure...

Cheers,
Scott

------------------------------------------------------------------------------
Minimize network downtime and maximize team effectiveness.
Reduce network management and security costs.Learn how to hire
the most talented Cisco Certified professionals. Visit the
Employer Resources Portal
http://www.cisco.com/web/learning/employer_resources/index.html
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options

You don't say exactly what you did, and how it didn't work...

If you read http://matplotlib.org/api/figure_api.html?highlight=add_axes#matplotlib.figure.Figure.add_axes
it says "Add an axes at position rect [left, bottom, width,
height]...". So you need to specify sensible values in rect1 and
rect2.

The following works fine for me:

import matplotlib.pyplot as plt
fig = plt.figure()
rect1 = [0.1, 0.1, 0.4, 0.4]
rect2 = [0.55, 0.1, 0.4, 0.4]
ax1 = fig.add_axes(rect1)
ax2 = fig.add_axes(rect2)
ax1.plot(range(3))
ax2.plot(range(4, 8))
plt.show()

So I would expect that you can adapt your original code to something
like the following (untested):

from windrose import WindroseAxes
from matplotlib import pyplot as plt
from numpy.random import random

def new_axes(fig, rect):
    ax = WindroseAxes(fig, rect, axisbg='w')
    fig.add_axes(ax)
    return ax

def set_legend(ax):
    l = ax.legend(axespad=-0.10)
    plt.setp(l.get_texts(), fontsize=8)

#Create wind speed and direction variables
ws = random(500)*6
wd = random(500)*360
ws1 = random(500)*6
wd1 = random(500)*360

rect1 = [0.1, 0.1, 0.4, 0.4]
rect2 = [0.55, 0.1, 0.4, 0.4]

fig = plt.figure(figsize=(8, 8), dpi=80, facecolor='w', edgecolor='w')

ax1 = new_axes(fig, rect1)
ax2 = new_axes(fig, rect2)

#windrose like a stacked histogram with normed (displayed in percent) results
ax1.bar(wd, ws, normed=True, opening=0.8, edgecolor='white')
set_legend(ax1)

#windrose like a stacked histogram with normed (displayed in percent) results
ax2.bar(wd1, ws1, normed=True, opening=0.8, edgecolor='white')
set_legend(ax2)

plt.show()

Cheers,
Scott

···

On 5 April 2013 03:54, Sudheer Joseph <sudheer.joseph@...9...> wrote:

Some how I am not getting the trick of the
rect = [0.1, 0.1, 0.8, 0.8]

I tried
rect1= [0.1,0.1,.4,.4]
and rect2=[.4,.4,.8,.8]
but did not work

Thank You Scott,
I mistook the values I assumed .1 to .8 as the total x size and expected half of it should provide me 2 half boxes.
thanks a lot for clarification.
with best regards,
Sudheer

···

***************************************************************
Sudheer Joseph
Indian National Centre for Ocean Information Services
Ministry of Earth Sciences, Govt. of India
POST BOX NO: 21, IDA Jeedeemetla P.O.
Via Pragathi Nagar,Kukatpally, Hyderabad; Pin:5000 55
Tel:+91-40-23886047(O),Fax:+91-40-23895011(O),
Tel:+91-40-23044600(R),Tel:+91-40-9440832534(Mobile)
E-mail:sjo.India@...287...;sudheer.joseph@...9...
Web- http://oppamthadathil.tripod.com
***************************************************************

----- Original Message -----

From: Scott Sinclair <scott.sinclair.za@...287...>
To: "matplotlib-users@lists.sourceforge.net" <matplotlib-users@...1544...ceforge.net>
Cc:
Sent: Friday, 5 April 2013 6:36 PM
Subject: Re: [Matplotlib-users] windrose

On 5 April 2013 03:54, Sudheer Joseph <sudheer.joseph@...9...> wrote:

Some how I am not getting the trick of the
rect = [0.1, 0.1, 0.8, 0.8]

I tried
rect1= [0.1,0.1,.4,.4]
and rect2=[.4,.4,.8,.8]
but did not work

You don't say exactly what you did, and how it didn't work...

If you read
http://matplotlib.org/api/figure_api.html?highlight=add_axes#matplotlib.figure.Figure.add_axes
it says "Add an axes at position rect [left, bottom, width,
height]...". So you need to specify sensible values in rect1 and
rect2.

The following works fine for me:

import matplotlib.pyplot as plt
fig = plt.figure()
rect1 = [0.1, 0.1, 0.4, 0.4]
rect2 = [0.55, 0.1, 0.4, 0.4]
ax1 = fig.add_axes(rect1)
ax2 = fig.add_axes(rect2)
ax1.plot(range(3))
ax2.plot(range(4, 8))
plt.show()

So I would expect that you can adapt your original code to something
like the following (untested):

from windrose import WindroseAxes
from matplotlib import pyplot as plt
from numpy.random import random

def new_axes(fig, rect):
ax = WindroseAxes(fig, rect, axisbg='w')
fig.add_axes(ax)
return ax

def set_legend(ax):
l = ax.legend(axespad=-0.10)
plt.setp(l.get_texts(), fontsize=8)

#Create wind speed and direction variables
ws = random(500)*6
wd = random(500)*360
ws1 = random(500)*6
wd1 = random(500)*360

rect1 = [0.1, 0.1, 0.4, 0.4]
rect2 = [0.55, 0.1, 0.4, 0.4]

fig = plt.figure(figsize=(8, 8), dpi=80, facecolor='w',
edgecolor='w')

ax1 = new_axes(fig, rect1)
ax2 = new_axes(fig, rect2)

#windrose like a stacked histogram with normed (displayed in percent) results
ax1.bar(wd, ws, normed=True, opening=0.8, edgecolor='white')
set_legend(ax1)

#windrose like a stacked histogram with normed (displayed in percent) results
ax2.bar(wd1, ws1, normed=True, opening=0.8, edgecolor='white')
set_legend(ax2)

plt.show()

Cheers,
Scott

------------------------------------------------------------------------------
Minimize network downtime and maximize team effectiveness.
Reduce network management and security costs.Learn how to hire
the most talented Cisco Certified professionals. Visit the
Employer Resources Portal
http://www.cisco.com/web/learning/employer_resources/index.html
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options