Re: [Matplotlib-users] 2 x-axes

2011-09-12 Thread Neal Becker
Neal Becker wrote:

> Actually, though, I didn't want to plot 2 different sets of data as in that
> example, I want 1 set of data plotted with 2 different x-axis (different
> units). Any suggestion on modifying this example to accomplish this?
> 
> import numpy as np
> import matplotlib.pyplot as plt
> from mpl_toolkits.axes_grid.parasite_axes import SubplotHost
> 
> fig = plt.figure(figsize=(10,8))
> host = SubplotHost(fig, 111)
> fig.add_subplot(host)
> parx = host.twiny()
> 
> parx.axis["top"].set_visible(False)
> offset = 0, -50
> new_axisline = parx.get_grid_helper().new_fixed_axis
> parx.axis["bottom"] = new_axisline(loc="bottom", axes=parx, offset=offset)
> parx.axis["bottom"].label.set_visible(True)
> 
> hplt, = host.plot(np.random.rand(100))
> p2, = parx.plot(np.linspace(0,20,100), np.random.rand(100)*5.0,
> color='green')
> 
> plt.show()
> 
OK, answer my own question.  Just remove the line 'parx.plot(...').  I didn't 
realize that I'd get the second axis drawn without that plot call, but it works 
fine.


--
Doing More with Less: The Next Generation Virtual Desktop 
What are the key obstacles that have prevented many mid-market businesses
from deploying virtual desktops?   How do next-generation virtual desktops
provide companies an easier-to-deploy, easier-to-manage and more affordable
virtual desktop model.http://www.accelacomm.com/jaw/sfnl/114/51426474/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] 2 x-axes

2011-09-12 Thread Neal Becker
Actually, though, I didn't want to plot 2 different sets of data as in that 
example, I want 1 set of data plotted with 2 different x-axis (different units).
Any suggestion on modifying this example to accomplish this?

import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.axes_grid.parasite_axes import SubplotHost

fig = plt.figure(figsize=(10,8))
host = SubplotHost(fig, 111)
fig.add_subplot(host)
parx = host.twiny()

parx.axis["top"].set_visible(False)
offset = 0, -50
new_axisline = parx.get_grid_helper().new_fixed_axis
parx.axis["bottom"] = new_axisline(loc="bottom", axes=parx, offset=offset)
parx.axis["bottom"].label.set_visible(True)

hplt, = host.plot(np.random.rand(100))
p2, = parx.plot(np.linspace(0,20,100), np.random.rand(100)*5.0,
color='green')

plt.show()



--
Doing More with Less: The Next Generation Virtual Desktop 
What are the key obstacles that have prevented many mid-market businesses
from deploying virtual desktops?   How do next-generation virtual desktops
provide companies an easier-to-deploy, easier-to-manage and more affordable
virtual desktop model.http://www.accelacomm.com/jaw/sfnl/114/51426474/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] 2 x-axes

2011-09-11 Thread Gökhan Sever
The master is here. JJ had showed me those multi axes tricks and he is back
again with the plenty of changes to the axes_grid toolkit.

The best thing to do is to make a new clone from the master repo and
experiment.

On Sun, Sep 11, 2011 at 1:37 PM, Neal Becker  wrote:

> Jae-Joon Lee wrote:
>
> > On Sun, Sep 11, 2011 at 10:16 PM, Neal Becker 
> wrote:
> >> Yes, that's very helpful.  Just one thing.  How would I get a bit more
> bottom
> >> margin on the main figure to leave more room for the extra axis?
> >>
> >> I'm using this as an example.  I experimented with plt.subplots_adjust,
> which
> >> seems like it might do the right thing.  Is this the 'best' approach?
> >> (I really don't know what all these methods do, just guessing)
> >
> > Yes, you need to fiddle with subplots_adjust command. The current
> > development branch of matplotlib (not yet released) has a new function
> > "tight_layout", which does this automatically for you.
> > Regards,
> >
> > -JJ
> Looking forward to that.  Any idea of an ETA for a release?
>
>
>
> --
> Using storage to extend the benefits of virtualization and iSCSI
> Virtualization increases hardware utilization and delivers a new level of
> agility. Learn what those decisions are and how to modernize your storage
> and backup environments for virtualization.
> http://www.accelacomm.com/jaw/sfnl/114/51434361/
> ___
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>



-- 
Gökhan
--
Doing More with Less: The Next Generation Virtual Desktop 
What are the key obstacles that have prevented many mid-market businesses
from deploying virtual desktops?   How do next-generation virtual desktops
provide companies an easier-to-deploy, easier-to-manage and more affordable
virtual desktop model.http://www.accelacomm.com/jaw/sfnl/114/51426474/___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] 2 x-axes

2011-09-11 Thread Neal Becker
Jae-Joon Lee wrote:

> On Sun, Sep 11, 2011 at 10:16 PM, Neal Becker  wrote:
>> Yes, that's very helpful.  Just one thing.  How would I get a bit more bottom
>> margin on the main figure to leave more room for the extra axis?
>>
>> I'm using this as an example.  I experimented with plt.subplots_adjust, which
>> seems like it might do the right thing.  Is this the 'best' approach?
>> (I really don't know what all these methods do, just guessing)
> 
> Yes, you need to fiddle with subplots_adjust command. The current
> development branch of matplotlib (not yet released) has a new function
> "tight_layout", which does this automatically for you.
> Regards,
> 
> -JJ
Looking forward to that.  Any idea of an ETA for a release?


--
Using storage to extend the benefits of virtualization and iSCSI
Virtualization increases hardware utilization and delivers a new level of
agility. Learn what those decisions are and how to modernize your storage 
and backup environments for virtualization.
http://www.accelacomm.com/jaw/sfnl/114/51434361/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] 2 x-axes

2011-09-11 Thread Jae-Joon Lee
On Sun, Sep 11, 2011 at 10:16 PM, Neal Becker  wrote:
> Yes, that's very helpful.  Just one thing.  How would I get a bit more bottom
> margin on the main figure to leave more room for the extra axis?
>
> I'm using this as an example.  I experimented with plt.subplots_adjust, which
> seems like it might do the right thing.  Is this the 'best' approach?
> (I really don't know what all these methods do, just guessing)

Yes, you need to fiddle with subplots_adjust command. The current
development branch of matplotlib (not yet released) has a new function
"tight_layout", which does this automatically for you.
Regards,

-JJ

--
Using storage to extend the benefits of virtualization and iSCSI
Virtualization increases hardware utilization and delivers a new level of
agility. Learn what those decisions are and how to modernize your storage 
and backup environments for virtualization.
http://www.accelacomm.com/jaw/sfnl/114/51434361/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] 2 x-axes

2011-09-11 Thread Jae-Joon Lee
Just in case, here is a version with "axes_grid1" toolkit. Note that
axes_grid is kind of deprecated.
Regards,

-JJ


import numpy as np
import matplotlib.pyplot as plt
import mpl_toolkits.axes_grid1 as axes_grid1

host = axes_grid1.host_subplot(111)
hplt, = host.plot(np.random.rand(100))


from matplotlib.transforms import Affine2D
transfrom_from_parx_to_host = Affine2D().scale(1000, 1)
parx = host.twin(transfrom_from_parx_to_host)

if 1: # adjust axis postion etc.
parx.axis["right"].toggle(ticklabels=False)
parx.axis["top"].toggle(ticklabels=False)
parx.axis["bottom"].toggle(ticklabels=True)

parx.axis["bottom"].line.set_visible(True)
parx.spines["bottom"].set_position(('outward',20))

plt.show()


On Sat, Sep 10, 2011 at 6:14 AM, Gökhan Sever  wrote:
> Hi,
> The code below should create a properly placed 2nd x-axis. You might need to
> adjust the placement of the figure canvas to match into the window.
> import numpy as np
> import matplotlib.pyplot as plt
> from mpl_toolkits.axes_grid.parasite_axes import SubplotHost
> fig = plt.figure(figsize=(10,8))
> host = SubplotHost(fig, 111)
> fig.add_subplot(host)
> parx = host.twiny()
> parx.axis["top"].set_visible(False)
> offset = 0, -50
> new_axisline = parx.get_grid_helper().new_fixed_axis
> parx.axis["bottom"] = new_axisline(loc="bottom", axes=parx, offset=offset)
> parx.axis["bottom"].label.set_visible(True)
> hplt, = host.plot(np.random.rand(100))
> p2, = parx.plot(np.linspace(0,20,100), np.random.rand(100)*5.0,
> color='green')
> plt.show()
>
> There is also another example at:
> http://matplotlib.sourceforge.net/mpl_toolkits/axes_grid/users/overview.html#axisartist-with-parasiteaxes
> Hope this helps.
> On Fri, Sep 9, 2011 at 12:50 PM, Neal Becker  wrote:
>>
>> Neal Becker wrote:
>>
>> > I have a semilog plot.  I'd like to add a second x axis (maybe below the
>> > existing one, or else maybe on top of graph).  This second x axis is
>> > simply
>> > describing the same existing data, in different units.
>> >
>> > For example imagine a plot of
>> >
>> > x - time in seconds
>> > y - velocity
>> >
>> > x2 - time in minutes
>> >
>> >
>>
>> This almost works:
>>    fig = plt.figure()
>>    ax = fig.add_subplot(111)
>> ...
>>    ax2 = ax.twiny()
>>    min_x, max_x = ax.get_xlim()
>>    ax2.set_xlim (min_x-1, max_x-1)
>>
>> except the 2nd x axis is on the top, and prints right on top of the title
>>
>>
>>
>> --
>> Why Cloud-Based Security and Archiving Make Sense
>> Osterman Research conducted this study that outlines how and why cloud
>> computing security and archiving is rapidly being adopted across the IT
>> space for its ease of implementation, lower cost, and increased
>> reliability. Learn more. http://www.accelacomm.com/jaw/sfnl/114/51425301/
>> ___
>> Matplotlib-users mailing list
>> Matplotlib-users@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
>
>
> --
> Gökhan
>
> --
> Why Cloud-Based Security and Archiving Make Sense
> Osterman Research conducted this study that outlines how and why cloud
> computing security and archiving is rapidly being adopted across the IT
> space for its ease of implementation, lower cost, and increased
> reliability. Learn more. http://www.accelacomm.com/jaw/sfnl/114/51425301/
> ___
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
>

--
Using storage to extend the benefits of virtualization and iSCSI
Virtualization increases hardware utilization and delivers a new level of
agility. Learn what those decisions are and how to modernize your storage 
and backup environments for virtualization.
http://www.accelacomm.com/jaw/sfnl/114/51434361/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] 2 x-axes

2011-09-11 Thread Neal Becker
Gökhan Sever wrote:

> Hi,
> 
> The code below should create a properly placed 2nd x-axis. You might need to
> adjust the placement of the figure canvas to match into the window.
> 
> import numpy as np
> import matplotlib.pyplot as plt
> from mpl_toolkits.axes_grid.parasite_axes import SubplotHost
> 
> fig = plt.figure(figsize=(10,8))
> host = SubplotHost(fig, 111)
> fig.add_subplot(host)
> parx = host.twiny()
> 
> parx.axis["top"].set_visible(False)
> offset = 0, -50
> new_axisline = parx.get_grid_helper().new_fixed_axis
> parx.axis["bottom"] = new_axisline(loc="bottom", axes=parx, offset=offset)
> parx.axis["bottom"].label.set_visible(True)
> 
> hplt, = host.plot(np.random.rand(100))
> p2, = parx.plot(np.linspace(0,20,100), np.random.rand(100)*5.0,
> color='green')
> 
> plt.show()
> 
> 
> There is also another example at:
> 
http://matplotlib.sourceforge.net/mpl_toolkits/axes_grid/users/overview.html#axisartist-
with-parasiteaxes
> 
> Hope this helps.
Yes, that's very helpful.  Just one thing.  How would I get a bit more bottom 
margin on the main figure to leave more room for the extra axis?

I'm using this as an example.  I experimented with plt.subplots_adjust, which 
seems like it might do the right thing.  Is this the 'best' approach?
(I really don't know what all these methods do, just guessing)

import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.axes_grid.parasite_axes import SubplotHost

from matplotlib.backends.backend_pdf import PdfPages

pdf = PdfPages('results.pdf')

fig = plt.figure(figsize=(10,8))
host = SubplotHost(fig, 111)
ax = fig.add_subplot(host)
plt.subplots_adjust (bottom=0.1)
parx = host.twiny()

parx.axis["top"].set_visible(False)
offset = 0, -30
new_axisline = parx.get_grid_helper().new_fixed_axis
parx.axis["bottom"] = new_axisline(loc="bottom", axes=parx, offset=offset)
parx.axis["bottom"].label.set_visible(True)

hplt, = host.plot(np.linspace(0,20,100), np.random.rand(100))
plt.xlabel ('Es/No')
p2, = parx.plot(np.linspace(0,20,100)-5, np.random.rand(100)*5.0, color='green')
parx.set_xlabel ('$Eb_{i}/No$')
#plt.show()

pdf.savefig (fig)
plt.close()
pdf.close()




--
Using storage to extend the benefits of virtualization and iSCSI
Virtualization increases hardware utilization and delivers a new level of
agility. Learn what those decisions are and how to modernize your storage 
and backup environments for virtualization.
http://www.accelacomm.com/jaw/sfnl/114/51434361/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] 2 x-axes

2011-09-09 Thread Gökhan Sever
Hi,

The code below should create a properly placed 2nd x-axis. You might need to
adjust the placement of the figure canvas to match into the window.

import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.axes_grid.parasite_axes import SubplotHost

fig = plt.figure(figsize=(10,8))
host = SubplotHost(fig, 111)
fig.add_subplot(host)
parx = host.twiny()

parx.axis["top"].set_visible(False)
offset = 0, -50
new_axisline = parx.get_grid_helper().new_fixed_axis
parx.axis["bottom"] = new_axisline(loc="bottom", axes=parx, offset=offset)
parx.axis["bottom"].label.set_visible(True)

hplt, = host.plot(np.random.rand(100))
p2, = parx.plot(np.linspace(0,20,100), np.random.rand(100)*5.0,
color='green')

plt.show()


There is also another example at:
http://matplotlib.sourceforge.net/mpl_toolkits/axes_grid/users/overview.html#axisartist-with-parasiteaxes

Hope this helps.

On Fri, Sep 9, 2011 at 12:50 PM, Neal Becker  wrote:

> Neal Becker wrote:
>
> > I have a semilog plot.  I'd like to add a second x axis (maybe below the
> > existing one, or else maybe on top of graph).  This second x axis is
> simply
> > describing the same existing data, in different units.
> >
> > For example imagine a plot of
> >
> > x - time in seconds
> > y - velocity
> >
> > x2 - time in minutes
> >
> >
>
> This almost works:
>fig = plt.figure()
>ax = fig.add_subplot(111)
> ...
>ax2 = ax.twiny()
>min_x, max_x = ax.get_xlim()
>ax2.set_xlim (min_x-1, max_x-1)
>
> except the 2nd x axis is on the top, and prints right on top of the title
>
>
>
> --
> Why Cloud-Based Security and Archiving Make Sense
> Osterman Research conducted this study that outlines how and why cloud
> computing security and archiving is rapidly being adopted across the IT
> space for its ease of implementation, lower cost, and increased
> reliability. Learn more. http://www.accelacomm.com/jaw/sfnl/114/51425301/
> ___
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>



-- 
Gökhan
--
Why Cloud-Based Security and Archiving Make Sense
Osterman Research conducted this study that outlines how and why cloud
computing security and archiving is rapidly being adopted across the IT 
space for its ease of implementation, lower cost, and increased 
reliability. Learn more. http://www.accelacomm.com/jaw/sfnl/114/51425301/___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] 2 x-axes

2011-09-09 Thread Neal Becker
Neal Becker wrote:

> I have a semilog plot.  I'd like to add a second x axis (maybe below the
> existing one, or else maybe on top of graph).  This second x axis is simply
> describing the same existing data, in different units.
> 
> For example imagine a plot of
> 
> x - time in seconds
> y - velocity
> 
> x2 - time in minutes
> 
> 

This almost works:
fig = plt.figure() 
ax = fig.add_subplot(111) 
...
ax2 = ax.twiny()
min_x, max_x = ax.get_xlim()
ax2.set_xlim (min_x-1, max_x-1)

except the 2nd x axis is on the top, and prints right on top of the title


--
Why Cloud-Based Security and Archiving Make Sense
Osterman Research conducted this study that outlines how and why cloud
computing security and archiving is rapidly being adopted across the IT 
space for its ease of implementation, lower cost, and increased 
reliability. Learn more. http://www.accelacomm.com/jaw/sfnl/114/51425301/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] 2 x-axes

2011-09-09 Thread Neal Becker
I have a semilog plot.  I'd like to add a second x axis (maybe below the 
existing one, or else maybe on top of graph).  This second x axis is simply 
describing the same existing data, in different units.

For example imagine a plot of

x - time in seconds
y - velocity

x2 - time in minutes




--
Why Cloud-Based Security and Archiving Make Sense
Osterman Research conducted this study that outlines how and why cloud
computing security and archiving is rapidly being adopted across the IT 
space for its ease of implementation, lower cost, and increased 
reliability. Learn more. http://www.accelacomm.com/jaw/sfnl/114/51425301/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users