Re: [Matplotlib-users] Backend Agg - show plot

2008-02-17 Thread sa6113

Thanks for your help
I use the code below , but the plot wont be diplayed on my screen .

matplotlib.use('TkAgg') 
import matplotlib.pylab as plt
fig = plt.figure() 
ax = fig.add_subplot(111) 
ax.plot(x, y, marker='o', linestyle='', markerfacecolor='green') 
ax.set_title('Some random dots') 
ax.set_xlabel('x') 
ax.set_ylabel('y') 
ax.grid(True) 
fig.savefig('myplot.png', dpi=100) 
plt.show() 

Would you please help me ?


Eric Firing wrote:
> 
> sa6113 wrote:
>> How should I darw and show a plot using Backend Agg , I don't want to
>> save
>> figure , just show ?
> 
> If you don't want to save a figure, then you will need an interactive 
> backend--not Agg, but TkAgg or GtkAgg etc.  Then you end your script 
> with "show()" (imported from pylab or matplotlib.pyplot), and the plot 
> will be diplayed on your screen.  (The plain Agg backend is useful only 
> with "savefig(...)" to generate png files.)
> 
> Check out the "examples" directory in the distribution.
> 
> Eric
> 
> -
> This SF.net email is sponsored by: Microsoft
> Defy all challenges. Microsoft(R) Visual Studio 2008.
> http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
> ___
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Backend-Agg---show-plot-tp15527044p15527408.html
Sent from the matplotlib - users mailing list archive at Nabble.com.


-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Backend Agg - show plot

2008-02-17 Thread Darren Dale
On Sunday 17 February 2008 4:32:39 am sa6113 wrote:
> Thanks for your help
> I use the code below , but the plot wont be diplayed on my screen .
>
> matplotlib.use('TkAgg')
> import matplotlib.pylab as plt
> fig = plt.figure()
> ax = fig.add_subplot(111)
> ax.plot(x, y, marker='o', linestyle='', markerfacecolor='green')
> ax.set_title('Some random dots')
> ax.set_xlabel('x')
> ax.set_ylabel('y')
> ax.grid(True)
> fig.savefig('myplot.png', dpi=100)
> plt.show()
>
> Would you please help me ?

We need more information in order to help. What OS are you using, are you 
running the script from a command prompt or are you running it from the IDLE 
editor, are there any error messages that would help diagnose the problem, we 
need something to go on.

> Eric Firing wrote:
> > sa6113 wrote:
> >> How should I darw and show a plot using Backend Agg , I don't want to
> >> save
> >> figure , just show ?
> >
> > If you don't want to save a figure, then you will need an interactive
> > backend--not Agg, but TkAgg or GtkAgg etc.  Then you end your script
> > with "show()" (imported from pylab or matplotlib.pyplot), and the plot
> > will be diplayed on your screen.  (The plain Agg backend is useful only
> > with "savefig(...)" to generate png files.)
> >
> > Check out the "examples" directory in the distribution.
> >
> > Eric
> >
> > -
> > This SF.net email is sponsored by: Microsoft
> > Defy all challenges. Microsoft(R) Visual Studio 2008.
> > http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
> > ___
> > Matplotlib-users mailing list
> > Matplotlib-users@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/matplotlib-users



-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Subplots from existing figures

2008-02-17 Thread Robin
On Feb 15, 2008 12:04 PM, Robin <[EMAIL PROTECTED]> wrote:
> Hello,
>
> I have some functions that produce various figures. This is usually
> done by calling figure(), then the plot function (eg bar). I save the
> figure object and pass it out.
>
> I would like to be able to collect several figure objects from such
> functions and collect them as subplots in a single figure for easy
> printing, comparison. I don't want to change the functions that create
> them though, because I will also want to view them individually in the
> future.
>
> So given a load of figure objects, how can I make a new figure with
> each subplot one of the existing figures? (I hope this is clear). Does
> it matter if the original figure object has been closed? I'm having a
> look through the help to see if I could find it but it's taking a bit
> of time and I thought it's probably quite easy if your more familiar
> with the object structure of matplotlib.

I'm afraid I haven't been able to make very much progress with this on
my own. I tried calling get_children on the figure objects I have, and
then tried calling set_axes with the subplot of a new figure on each
of the children in the hope that this would bind them over, but after
playing a bit nothing I've tried seems to work.

Is it possible to do this, or even if it is is it perhaps too
complicated/involved to be worth while? (I had hoped it would be
relatively straightforward once I found the right combination of
get/set functions to move the plot objects over to the new subplot).

Thanks,

Robin

-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Subplots from existing figures

2008-02-17 Thread Eric Firing
Robin,

I'm not sure I understand what you want to do; is it to recycle axes 
objects that were originally in one or more figures and put them in 
another figure?  It looks like that might be doable if you create the 
new figure, then for each axes call ax.set_figure(newfig), and then for 
each axes call newfig.add_axes(ax).  I would be not the least surprised 
if all this failed, though.

Eric

Robin wrote:
> On Feb 15, 2008 12:04 PM, Robin <[EMAIL PROTECTED]> wrote:
>> Hello,
>>
>> I have some functions that produce various figures. This is usually
>> done by calling figure(), then the plot function (eg bar). I save the
>> figure object and pass it out.
>>
>> I would like to be able to collect several figure objects from such
>> functions and collect them as subplots in a single figure for easy
>> printing, comparison. I don't want to change the functions that create
>> them though, because I will also want to view them individually in the
>> future.
>>
>> So given a load of figure objects, how can I make a new figure with
>> each subplot one of the existing figures? (I hope this is clear). Does
>> it matter if the original figure object has been closed? I'm having a
>> look through the help to see if I could find it but it's taking a bit
>> of time and I thought it's probably quite easy if your more familiar
>> with the object structure of matplotlib.
> 
> I'm afraid I haven't been able to make very much progress with this on
> my own. I tried calling get_children on the figure objects I have, and
> then tried calling set_axes with the subplot of a new figure on each
> of the children in the hope that this would bind them over, but after
> playing a bit nothing I've tried seems to work.
> 
> Is it possible to do this, or even if it is is it perhaps too
> complicated/involved to be worth while? (I had hoped it would be
> relatively straightforward once I found the right combination of
> get/set functions to move the plot objects over to the new subplot).
> 
> Thanks,
> 
> Robin
> 
> -
> This SF.net email is sponsored by: Microsoft
> Defy all challenges. Microsoft(R) Visual Studio 2008.
> http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
> ___
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users


-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Backend Agg - show plot

2008-02-17 Thread sa6113

My OS is win XP and I run my program from command prompt and IDLE both , and
there isn't any error.
I can save the plot with (savefig) but the show() command dose not work and
I can't see the plot on my screen and also I want to use Backend Agg insted
of pylab.


Darren Dale-2 wrote:
> 
> On Sunday 17 February 2008 4:32:39 am sa6113 wrote:
>> Thanks for your help
>> I use the code below , but the plot wont be diplayed on my screen .
>>
>> matplotlib.use('TkAgg')
>> import matplotlib.pylab as plt
>> fig = plt.figure()
>> ax = fig.add_subplot(111)
>> ax.plot(x, y, marker='o', linestyle='', markerfacecolor='green')
>> ax.set_title('Some random dots')
>> ax.set_xlabel('x')
>> ax.set_ylabel('y')
>> ax.grid(True)
>> fig.savefig('myplot.png', dpi=100)
>> plt.show()
>>
>> Would you please help me ?
> 
> We need more information in order to help. What OS are you using, are you 
> running the script from a command prompt or are you running it from the
> IDLE 
> editor, are there any error messages that would help diagnose the problem,
> we 
> need something to go on.
> 
>> Eric Firing wrote:
>> > sa6113 wrote:
>> >> How should I darw and show a plot using Backend Agg , I don't want to
>> >> save
>> >> figure , just show ?
>> >
>> > If you don't want to save a figure, then you will need an interactive
>> > backend--not Agg, but TkAgg or GtkAgg etc.  Then you end your script
>> > with "show()" (imported from pylab or matplotlib.pyplot), and the plot
>> > will be diplayed on your screen.  (The plain Agg backend is useful only
>> > with "savefig(...)" to generate png files.)
>> >
>> > Check out the "examples" directory in the distribution.
>> >
>> > Eric
>> >
>> >
>> -
>> > This SF.net email is sponsored by: Microsoft
>> > Defy all challenges. Microsoft(R) Visual Studio 2008.
>> > http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
>> > ___
>> > Matplotlib-users mailing list
>> > Matplotlib-users@lists.sourceforge.net
>> > https://lists.sourceforge.net/lists/listinfo/matplotlib-users
> 
> 
> 
> -
> This SF.net email is sponsored by: Microsoft
> Defy all challenges. Microsoft(R) Visual Studio 2008.
> http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
> ___
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Backend-Agg---show-plot-tp15527044p15539567.html
Sent from the matplotlib - users mailing list archive at Nabble.com.


-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Backend Agg - show plot

2008-02-17 Thread Eric Firing
sa6113 wrote:
> My OS is win XP and I run my program from command prompt and IDLE both , and
> there isn't any error.
> I can save the plot with (savefig) but the show() command dose not work and
> I can't see the plot on my screen and also I want to use Backend Agg insted
> of pylab.

1) Using the Agg backend, you *cannot* plot directly to the screen. 
that is what I was telling you in my first reply.  Also note that pylab 
is simply a command-oriented API; it works with any backend, provided 
you import matplotlib and then specify the backend *before* you import 
pylab.

2) Please try running some of the example scripts that come with the 
distribution, and tell us whether they display to your screen.  If they 
don't, your matplotlib installation is broken.

3) If the examples work, then provide a simplest-possible example of a 
*complete* script that does *not* work.  Also, to be sure, say what 
version of matplotlib you are using.

Eric


> 
> 
> Darren Dale-2 wrote:
>> On Sunday 17 February 2008 4:32:39 am sa6113 wrote:
>>> Thanks for your help
>>> I use the code below , but the plot wont be diplayed on my screen .
>>>
>>> matplotlib.use('TkAgg')
>>> import matplotlib.pylab as plt
>>> fig = plt.figure()
>>> ax = fig.add_subplot(111)
>>> ax.plot(x, y, marker='o', linestyle='', markerfacecolor='green')
>>> ax.set_title('Some random dots')
>>> ax.set_xlabel('x')
>>> ax.set_ylabel('y')
>>> ax.grid(True)
>>> fig.savefig('myplot.png', dpi=100)
>>> plt.show()
>>>
>>> Would you please help me ?
>> We need more information in order to help. What OS are you using, are you 
>> running the script from a command prompt or are you running it from the
>> IDLE 
>> editor, are there any error messages that would help diagnose the problem,
>> we 
>> need something to go on.
>>
>>> Eric Firing wrote:
 sa6113 wrote:
> How should I darw and show a plot using Backend Agg , I don't want to
> save
> figure , just show ?
 If you don't want to save a figure, then you will need an interactive
 backend--not Agg, but TkAgg or GtkAgg etc.  Then you end your script
 with "show()" (imported from pylab or matplotlib.pyplot), and the plot
 will be diplayed on your screen.  (The plain Agg backend is useful only
 with "savefig(...)" to generate png files.)

 Check out the "examples" directory in the distribution.

 Eric

-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Subplots from existing figures

2008-02-17 Thread Robin
On Feb 18, 2008 4:44 AM, Eric Firing <[EMAIL PROTECTED]> wrote:
> I'm not sure I understand what you want to do; is it to recycle axes
> objects that were originally in one or more figures and put them in
> another figure?

Hi,

I have a number of figures created from functions like this:
fig1 = plot_fig1(data1)
fig2 = plot_fig2(data2)
etc.

Now instead of having two separate figure windows displaying the
plots, I would like them to appear as subplots in a new figure (single
window) and close the previous figures. Other than moving to the
subplot in a new figure, I would like everything about the plot to
remain the same (titles, labels, scale,ticks etc.)

I had imagined something like this would be possible:
newfig = figure()
sp1 = subplot(211)
for x in fig1.get_children():
   x.set_axes(sp1)

or similar, but it doesn't seem to work. Also, when trying something
like this, does it matter if the original figure windows are already
closed? (ie does the act of closing the window change the objects to
make them not show-able any more).

I'm not sure if I can do this reallocation by figure or axes, that is
what I was asking really.

> It looks like that might be doable if you create the
> new figure, then for each axes call ax.set_figure(newfig), and then for
> each axes call newfig.add_axes(ax).  I would be not the least surprised
> if all this failed, though.

If I move the axes over as you describe, will this also bring the
plotted data, titles etc.? I will try and play around with this later
today. Would I first have to delete the existing axes created when I
create the subplot? Wouldn't that make a problem, since isn't it these
created axis that have the important subplot position properties (if I
just move over the existing axes how will the subplot placing work).
I imagine I might have to, copy over the axes from old figure, set
position and size of old axes to those of new subplot axes, copy over
all children (rectangles, text etc.)?

Alternatively if theres another way of achieving the same thing. I
thought I could modify the functions to take an optional axes
argument, so if not present they make a new figure, and if present
they use that:
fig = figure()
sp1 = subplot(211)
plot_data1(data1, axes=sp1)

but then I'm not sure how inside the function, I use plot commands
(bar, plot, imshow) on this provided subplot axis.

Thanks,

Robin

-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users