SourceForge logo
SourceForge logo
Menu

matplotlib-users

From: David G. <da...@gu...> - 2009年06月28日 18:42:21
Attachments: draw_eth_test.py
Hi matplotlib_users !
I'm David from Berlin, and believe I'm experiencing some problem with the
SubplotHost module:
I'm generating graphs from hudge databases of cpu and ethernet statistics,
and I wanted to mix several graphs concerning ethernet statistics in the
same figure,
with time as x axis, and bytes-in, bytes-out, packets-in, packets-out and
number of
collisions as three different y axes, with three different scale.
I took the inspiration from
for the x axes and from
http://matplotlib.sourceforge.net/examples/axes_grid/demo_parasite_axes2.html
for the y axes
The following code is a synthetic reproduction of the problem I'm
experiencing (it is also attached):
from matplotlib.dates import date2num
from matplotlib import pyplot
from matplotlib import pylab
from mpl_toolkits.axes_grid.parasite_axes import SubplotHost
from datetime import datetime
dates = [ 733581.20833333337, 733581.20837962965, 733581.20842592593,
733581.20847222221, 733581.20851851848,
 733581.20855324075, 733581.20858796302, 733581.2086342593,
733581.20866898145, 733581.20871527772]
rxB = [054L, 130L, 144L, 54L, 36L, 9L, 35L, 43L, 85L, 43L]
txB = [4L, 9L, 9L, 5L, 4L, 4L, 4L, 5L, 6L, 5L]
rxP = [77, 228, 251, 112, 77, 42, 75, 97, 147, 91]
txP = [61, 177, 188, 90, 61, 40, 64, 76, 113, 77]
col = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0]
ethPlot = pyplot
fig = ethPlot.figure()
host = SubplotHost(fig, 111)
host.set_ylabel("kB/s")
host.set_xlabel("Time")
par1 = host.twinx()
par2 = host.twinx()
par1.set_ylabel("Packets/s")
par2.axis["right"].set_visible(False)
offset = 60, 0
new_axisline = par2.get_grid_helper().new_fixed_axis
par2.axis["right2"] = new_axisline(loc="right",
 axes=par2,
 offset=offset)
par2.axis["right2"].label.set_visible(True)
par2.axis["right2"].set_label("Collisions")
par1.set_ylim(0, 6000)
par2.set_ylim(0, 7000)
host.axis([ dates[0], ( dates[0] + 0.041 ), -7000, 7000])
par1.axis([ dates[0], ( dates[0] + 0.041 ), -10000, 10000])
par2.axis([ dates[0], ( dates[0] + 0.041 ), -700, 700])
fig.add_axes(host)
ethPlot.subplots_adjust(right=0.75)
drawRxByt, = host.plot_date(dates, rxB, 'g', tz=None, xdate=True,
ydate=False, label="kB/s in")
drawTxByt, = host.plot_date(dates, txB, 'b', tz=None, xdate=True,
ydate=False, label="kB/s out")
drawRxPaq, = par1.plot_date(dates, rxP, 'm', tz=None, xdate=True,
ydate=False, label="packets/s in")
drawTxPaq, = par1.plot_date(dates, txP, 'y', tz=None, xdate=True,
ydate=False, label="packets/s out")
drawColls, = par2.plot_date(dates, col, 'r', tz=None, xdate=True,
ydate=False, label="collisions")
fig.autofmt_xdate()
host.set_xlabel("Time")
host.set_ylabel("kB/s")
par1.set_ylabel("Packets/s")
host.legend()
host.axis["left"].label.set_color(drawRxByt.get_color())
host.axis["left"].label.set_color(drawTxByt.get_color())
par1.axis["right"].label.set_color(drawRxPaq.get_color())
par1.axis["right"].label.set_color(drawtxPaq.get_color())
par2.axis["right2"].label.set_color(drawColls.get_color())
ethPlot.draw()
pylab.savefig( './test.png', dpi=(640/8))
Maybe I do something wrong somewhere here, but other scripts that do the
same for a single graphwork like a charm. So it's not a question of dataType
or something. To compare with a working code, here is the first version of
the fuction that does the job on single graphs without any problem :
def drawEthGraph(filename, hdates, rxP, txP, rxB, txB, col):
 ethPlot = pyplot
 fig = ethPlot.figure()
 ax = fig.add_subplot(111)
 ax.plot_date(hdates, rxP, 'g', None, True, False)
 ax.plot_date(hdates, txP, 'b', None, True, False)
 ax.plot_date(hdates, rxB, 'g', None, True, False)
 ax.plot_date(hdates, txB, 'b', None, True, False)
 ax.plot_date(hdates, col, 'r', None, True, False)
 ax.axis([ hdates[0], ( hdates[0] + 0.042 ), -7000, 7000])
 ax.grid(True)
 fig.autofmt_xdate()
 pylab.savefig( filename, dpi=(640/8))
I don't think I understand the whole process of generation, but I thought at
least at the beginnig I was having a good feeling with this API.
Now I wonder how to go around this. Maybe you'll have an idea :-o
Best regards
DvD
From: Jae-Joon L. <lee...@gm...> - 2009年07月02日 15:05:36
I can reproduce the error with the svn version.
It seems that the problem is not SubplotHost specific, i.e., you have
same problem if you use mpl's original axes with twinx.
I think it has something to do with the axes sharing in general.
Preventing autoscale of xaxis suppress the error.
host.set_autoscalex_on(False)
par1.set_autoscalex_on(False)
par2.set_autoscalex_on(False)
But you have to manually adjust the x-limits later
par1.set_xlim(dates[0], dates[-1])
However, autofmt_xdata does not work. And I guess this is a bug in the
SubplotHost. I may take a more look later today.
Regards,
-JJ
On Sun, Jun 28, 2009 at 1:34 PM, David GUERINEAU<da...@gu...> wrote:
> Hi matplotlib_users !
>
> I'm David from Berlin, and believe I'm experiencing some problem with the
> SubplotHost module:
>
> I'm generating graphs from hudge databases of cpu and ethernet statistics,
> and I wanted to mix several graphs concerning ethernet statistics in the
> same figure,
> with time as x axis, and bytes-in, bytes-out, packets-in, packets-out and
> number of
> collisions as three different y axes, with three different scale.
>
> I took the inspiration from
>
> for the x axes and from
>
> http://matplotlib.sourceforge.net/examples/axes_grid/demo_parasite_axes2.html
> for the y axes
>
> The following code is a synthetic reproduction of the problem I'm
> experiencing (it is also attached):
>
> from matplotlib.dates import date2num
> from matplotlib import pyplot
> from matplotlib import pylab
> from mpl_toolkits.axes_grid.parasite_axes import SubplotHost
> from datetime import datetime
>
> dates = [ 733581.20833333337, 733581.20837962965, 733581.20842592593,
> 733581.20847222221, 733581.20851851848,
>    733581.20855324075, 733581.20858796302, 733581.2086342593,
> 733581.20866898145, 733581.20871527772]
> rxB = [054L, 130L, 144L, 54L, 36L, 9L, 35L, 43L, 85L, 43L]
> txB = [4L, 9L, 9L, 5L, 4L, 4L, 4L, 5L, 6L, 5L]
> rxP = [77, 228, 251, 112, 77, 42, 75, 97, 147, 91]
> txP = [61, 177, 188, 90, 61, 40, 64, 76, 113, 77]
> col = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0]
>
> ethPlot = pyplot
> fig = ethPlot.figure()
> host = SubplotHost(fig, 111)
>
> host.set_ylabel("kB/s")
> host.set_xlabel("Time")
>
> par1 = host.twinx()
> par2 = host.twinx()
>
> par1.set_ylabel("Packets/s")
>
> par2.axis["right"].set_visible(False)
>
> offset = 60, 0
> new_axisline = par2.get_grid_helper().new_fixed_axis
> par2.axis["right2"] = new_axisline(loc="right",
>           axes=par2,
>           offset=offset)
>
> par2.axis["right2"].label.set_visible(True)
> par2.axis["right2"].set_label("Collisions")
>
> par1.set_ylim(0, 6000)
> par2.set_ylim(0, 7000)
>
> host.axis([ dates[0], ( dates[0] + 0.041 ), -7000, 7000])
> par1.axis([ dates[0], ( dates[0] + 0.041 ), -10000, 10000])
> par2.axis([ dates[0], ( dates[0] + 0.041 ), -700, 700])
>
> fig.add_axes(host)
> ethPlot.subplots_adjust(right=0.75)
>
> drawRxByt, = host.plot_date(dates, rxB, 'g', tz=None, xdate=True,
> ydate=False, label="kB/s in")
> drawTxByt, = host.plot_date(dates, txB, 'b', tz=None, xdate=True,
> ydate=False, label="kB/s out")
> drawRxPaq, = par1.plot_date(dates, rxP, 'm', tz=None, xdate=True,
> ydate=False, label="packets/s in")
> drawTxPaq, = par1.plot_date(dates, txP, 'y', tz=None, xdate=True,
> ydate=False, label="packets/s out")
> drawColls, = par2.plot_date(dates, col, 'r', tz=None, xdate=True,
> ydate=False, label="collisions")
>
> fig.autofmt_xdate()
>
> host.set_xlabel("Time")
> host.set_ylabel("kB/s")
> par1.set_ylabel("Packets/s")
>
> host.legend()
>
> host.axis["left"].label.set_color(drawRxByt.get_color())
> host.axis["left"].label.set_color(drawTxByt.get_color())
> par1.axis["right"].label.set_color(drawRxPaq.get_color())
> par1.axis["right"].label.set_color(drawtxPaq.get_color())
> par2.axis["right2"].label.set_color(drawColls.get_color())
>
> ethPlot.draw()
> pylab.savefig( './test.png', dpi=(640/8))
>
>
>
>
> Maybe I do something wrong somewhere here, but other scripts that do the
> same for a single graphwork like a charm. So it's not a question of dataType
> or something. To compare with a working code, here is the first version of
> the fuction that does the job on single graphs without any problem :
>
> def drawEthGraph(filename, hdates, rxP, txP, rxB, txB, col):
>  ethPlot = pyplot
>  fig = ethPlot.figure()
>  ax = fig.add_subplot(111)
>  ax.plot_date(hdates, rxP, 'g', None, True, False)
>  ax.plot_date(hdates, txP, 'b', None, True, False)
>  ax.plot_date(hdates, rxB, 'g', None, True, False)
>  ax.plot_date(hdates, txB, 'b', None, True, False)
>  ax.plot_date(hdates, col, 'r', None, True, False)
>  ax.axis([ hdates[0], ( hdates[0] + 0.042 ), -7000, 7000])
>  ax.grid(True)
>  fig.autofmt_xdate()
>  pylab.savefig( filename, dpi=(640/8))
>
>
> I don't think I understand the whole process of generation, but I thought at
> least at the beginnig I was having a good feeling with this API.
> Now I wonder how to go around this. Maybe you'll have an idea :-o
>
> Best regards
>
> DvD
>
> ------------------------------------------------------------------------------
>
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
>
From: Rodribat <rod...@gm...> - 2010年01月13日 13:16:51
Hi matplotlib users!
Did someone solve the problem of use fig.autofmt_xdate() function with
SubplotHost object?
I googled for it and I found this question only here, without solution. Is
there a bug? Anyone knows
someway to solve this?
Thank you,
[]'s
Rodrigo Batista
David GUERINEAU wrote:
> 
> Hi matplotlib_users !
> 
> I'm David from Berlin, and believe I'm experiencing some problem with the
> SubplotHost module:
> 
> I'm generating graphs from hudge databases of cpu and ethernet statistics,
> and I wanted to mix several graphs concerning ethernet statistics in the
> same figure,
> with time as x axis, and bytes-in, bytes-out, packets-in, packets-out and
> number of
> collisions as three different y axes, with three different scale.
> 
> I took the inspiration from
> 
> for the x axes and from
> 
> http://matplotlib.sourceforge.net/examples/axes_grid/demo_parasite_axes2.html
> for the y axes
> 
> The following code is a synthetic reproduction of the problem I'm
> experiencing (it is also attached):
> 
> from matplotlib.dates import date2num
> from matplotlib import pyplot
> from matplotlib import pylab
> from mpl_toolkits.axes_grid.parasite_axes import SubplotHost
> from datetime import datetime
> 
> dates = [ 733581.20833333337, 733581.20837962965, 733581.20842592593,
> 733581.20847222221, 733581.20851851848,
> 733581.20855324075, 733581.20858796302, 733581.2086342593,
> 733581.20866898145, 733581.20871527772]
> rxB = [054L, 130L, 144L, 54L, 36L, 9L, 35L, 43L, 85L, 43L]
> txB = [4L, 9L, 9L, 5L, 4L, 4L, 4L, 5L, 6L, 5L]
> rxP = [77, 228, 251, 112, 77, 42, 75, 97, 147, 91]
> txP = [61, 177, 188, 90, 61, 40, 64, 76, 113, 77]
> col = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0]
> 
> ethPlot = pyplot
> fig = ethPlot.figure()
> host = SubplotHost(fig, 111)
> 
> host.set_ylabel("kB/s")
> host.set_xlabel("Time")
> 
> par1 = host.twinx()
> par2 = host.twinx()
> 
> par1.set_ylabel("Packets/s")
> 
> par2.axis["right"].set_visible(False)
> 
> offset = 60, 0
> new_axisline = par2.get_grid_helper().new_fixed_axis
> par2.axis["right2"] = new_axisline(loc="right",
> axes=par2,
> offset=offset)
> 
> par2.axis["right2"].label.set_visible(True)
> par2.axis["right2"].set_label("Collisions")
> 
> par1.set_ylim(0, 6000)
> par2.set_ylim(0, 7000)
> 
> host.axis([ dates[0], ( dates[0] + 0.041 ), -7000, 7000])
> par1.axis([ dates[0], ( dates[0] + 0.041 ), -10000, 10000])
> par2.axis([ dates[0], ( dates[0] + 0.041 ), -700, 700])
> 
> fig.add_axes(host)
> ethPlot.subplots_adjust(right=0.75)
> 
> drawRxByt, = host.plot_date(dates, rxB, 'g', tz=None, xdate=True,
> ydate=False, label="kB/s in")
> drawTxByt, = host.plot_date(dates, txB, 'b', tz=None, xdate=True,
> ydate=False, label="kB/s out")
> drawRxPaq, = par1.plot_date(dates, rxP, 'm', tz=None, xdate=True,
> ydate=False, label="packets/s in")
> drawTxPaq, = par1.plot_date(dates, txP, 'y', tz=None, xdate=True,
> ydate=False, label="packets/s out")
> drawColls, = par2.plot_date(dates, col, 'r', tz=None, xdate=True,
> ydate=False, label="collisions")
> 
> fig.autofmt_xdate()
> 
> host.set_xlabel("Time")
> host.set_ylabel("kB/s")
> par1.set_ylabel("Packets/s")
> 
> host.legend()
> 
> host.axis["left"].label.set_color(drawRxByt.get_color())
> host.axis["left"].label.set_color(drawTxByt.get_color())
> par1.axis["right"].label.set_color(drawRxPaq.get_color())
> par1.axis["right"].label.set_color(drawtxPaq.get_color())
> par2.axis["right2"].label.set_color(drawColls.get_color())
> 
> ethPlot.draw()
> pylab.savefig( './test.png', dpi=(640/8))
> 
> 
> 
> 
> Maybe I do something wrong somewhere here, but other scripts that do the
> same for a single graphwork like a charm. So it's not a question of
> dataType
> or something. To compare with a working code, here is the first version of
> the fuction that does the job on single graphs without any problem :
> 
> def drawEthGraph(filename, hdates, rxP, txP, rxB, txB, col):
> ethPlot = pyplot
> fig = ethPlot.figure()
> ax = fig.add_subplot(111)
> ax.plot_date(hdates, rxP, 'g', None, True, False)
> ax.plot_date(hdates, txP, 'b', None, True, False)
> ax.plot_date(hdates, rxB, 'g', None, True, False)
> ax.plot_date(hdates, txB, 'b', None, True, False)
> ax.plot_date(hdates, col, 'r', None, True, False)
> ax.axis([ hdates[0], ( hdates[0] + 0.042 ), -7000, 7000])
> ax.grid(True)
> fig.autofmt_xdate()
> pylab.savefig( filename, dpi=(640/8))
> 
> 
> I don't think I understand the whole process of generation, but I thought
> at
> least at the beginnig I was having a good feeling with this API.
> Now I wonder how to go around this. Maybe you'll have an idea :-o
> 
> Best regards
> 
> DvD
> 
> from matplotlib.dates import date2num
> from matplotlib import pyplot 
> from matplotlib import pylab 
> from mpl_toolkits.axes_grid.parasite_axes import SubplotHost
> from datetime import datetime
> 
> dates = [ 733581.20833333337, 733581.20837962965, 733581.20842592593,
> 733581.20847222221, 733581.20851851848, 
> 	 733581.20855324075, 733581.20858796302, 733581.2086342593,
> 733581.20866898145, 733581.20871527772]
> rxB = [054L, 130L, 144L, 54L, 36L, 9L, 35L, 43L, 85L, 43L]
> txB = [4L, 9L, 9L, 5L, 4L, 4L, 4L, 5L, 6L, 5L]
> rxP = [77, 228, 251, 112, 77, 42, 75, 97, 147, 91]
> txP = [61, 177, 188, 90, 61, 40, 64, 76, 113, 77]
> col = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0]
> 
> ethPlot = pyplot
> fig = ethPlot.figure()
> host = SubplotHost(fig, 111)
> 
> host.set_ylabel("kB/s")
> host.set_xlabel("Time")
> 
> par1 = host.twinx()
> par2 = host.twinx()
> 
> par1.set_ylabel("Packets/s")
> 
> par2.axis["right"].set_visible(False)
> 
> offset = 60, 0
> new_axisline = par2.get_grid_helper().new_fixed_axis
> par2.axis["right2"] = new_axisline(loc="right",
> 				 axes=par2,
> 				 offset=offset)
> 
> par2.axis["right2"].label.set_visible(True)
> par2.axis["right2"].set_label("Collisions")
> 
> par1.set_ylim(0, 6000)
> par2.set_ylim(0, 7000)
> 
> host.axis([ dates[0], ( dates[0] + 0.041 ), -7000, 7000])
> par1.axis([ dates[0], ( dates[0] + 0.041 ), -10000, 10000])
> par2.axis([ dates[0], ( dates[0] + 0.041 ), -700, 700])
> 
> fig.add_axes(host)
> ethPlot.subplots_adjust(right=0.75)
> 
> drawRxByt, = host.plot_date(dates, rxB, 'g', tz=None, xdate=True,
> ydate=False, label="kB/s in")
> drawTxByt, = host.plot_date(dates, txB, 'b', tz=None, xdate=True,
> ydate=False, label="kB/s out")
> drawRxPaq, = par1.plot_date(dates, rxP, 'm', tz=None, xdate=True,
> ydate=False, label="packets/s in")
> drawTxPaq, = par1.plot_date(dates, txP, 'y', tz=None, xdate=True,
> ydate=False, label="packets/s out")
> drawColls, = par2.plot_date(dates, col, 'r', tz=None, xdate=True,
> ydate=False, label="collisions")
> 
> fig.autofmt_xdate()
> 
> host.set_xlabel("Time")
> host.set_ylabel("kB/s")
> par1.set_ylabel("Packets/s")
> 
> host.legend()
> 
> host.axis["left"].label.set_color(drawRxByt.get_color())
> host.axis["left"].label.set_color(drawTxByt.get_color())
> par1.axis["right"].label.set_color(drawRxPaq.get_color())
> par1.axis["right"].label.set_color(drawtxPaq.get_color())
> par2.axis["right2"].label.set_color(drawColls.get_color())
> 
> ethPlot.draw()
> pylab.savefig( './test.png', dpi=(640/8))
> 
> 
> 
> ------------------------------------------------------------------------------
> 
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
> 
> 
-- 
View this message in context: http://old.nabble.com/%22Ordinal-must-be-%3E%3D-1%22-with-SuplotHost-and-dates-tp24305444p27144728.html
Sent from the matplotlib - users mailing list archive at Nabble.com.
From: Jae-Joon L. <lee...@gm...> - 2010年01月13日 16:32:30
The workarounds suggested in this thread does not work?
To me, the ordinal thing is not actually a bug, but you need some
extra caution to avoid this error happening.
The issue with the label roration is a different matter though.
Regards,
-JJ
On Wed, Jan 13, 2010 at 8:16 AM, Rodribat <rod...@gm...> wrote:
>
>
> Hi matplotlib users!
>
> Did someone solve the problem of use fig.autofmt_xdate() function with
> SubplotHost object?
> I googled for it and I found this question only here, without solution. Is
> there a bug? Anyone knows
> someway to solve this?
>
> Thank you,
>
> []'s
>
> Rodrigo Batista
>
>
> David GUERINEAU wrote:
>>
>> Hi matplotlib_users !
>>
>> I'm David from Berlin, and believe I'm experiencing some problem with the
>> SubplotHost module:
>>
>> I'm generating graphs from hudge databases of cpu and ethernet statistics,
>> and I wanted to mix several graphs concerning ethernet statistics in the
>> same figure,
>> with time as x axis, and bytes-in, bytes-out, packets-in, packets-out and
>> number of
>> collisions as three different y axes, with three different scale.
>>
>> I took the inspiration from
>>
>> for the x axes and from
>>
>> http://matplotlib.sourceforge.net/examples/axes_grid/demo_parasite_axes2.html
>> for the y axes
>>
>> The following code is a synthetic reproduction of the problem I'm
>> experiencing (it is also attached):
>>
>> from matplotlib.dates import date2num
>> from matplotlib import pyplot
>> from matplotlib import pylab
>> from mpl_toolkits.axes_grid.parasite_axes import SubplotHost
>> from datetime import datetime
>>
>> dates = [ 733581.20833333337, 733581.20837962965, 733581.20842592593,
>> 733581.20847222221, 733581.20851851848,
>>    733581.20855324075, 733581.20858796302, 733581.2086342593,
>> 733581.20866898145, 733581.20871527772]
>> rxB = [054L, 130L, 144L, 54L, 36L, 9L, 35L, 43L, 85L, 43L]
>> txB = [4L, 9L, 9L, 5L, 4L, 4L, 4L, 5L, 6L, 5L]
>> rxP = [77, 228, 251, 112, 77, 42, 75, 97, 147, 91]
>> txP = [61, 177, 188, 90, 61, 40, 64, 76, 113, 77]
>> col = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0]
>>
>> ethPlot = pyplot
>> fig = ethPlot.figure()
>> host = SubplotHost(fig, 111)
>>
>> host.set_ylabel("kB/s")
>> host.set_xlabel("Time")
>>
>> par1 = host.twinx()
>> par2 = host.twinx()
>>
>> par1.set_ylabel("Packets/s")
>>
>> par2.axis["right"].set_visible(False)
>>
>> offset = 60, 0
>> new_axisline = par2.get_grid_helper().new_fixed_axis
>> par2.axis["right2"] = new_axisline(loc="right",
>>           axes=par2,
>>           offset=offset)
>>
>> par2.axis["right2"].label.set_visible(True)
>> par2.axis["right2"].set_label("Collisions")
>>
>> par1.set_ylim(0, 6000)
>> par2.set_ylim(0, 7000)
>>
>> host.axis([ dates[0], ( dates[0] + 0.041 ), -7000, 7000])
>> par1.axis([ dates[0], ( dates[0] + 0.041 ), -10000, 10000])
>> par2.axis([ dates[0], ( dates[0] + 0.041 ), -700, 700])
>>
>> fig.add_axes(host)
>> ethPlot.subplots_adjust(right=0.75)
>>
>> drawRxByt, = host.plot_date(dates, rxB, 'g', tz=None, xdate=True,
>> ydate=False, label="kB/s in")
>> drawTxByt, = host.plot_date(dates, txB, 'b', tz=None, xdate=True,
>> ydate=False, label="kB/s out")
>> drawRxPaq, = par1.plot_date(dates, rxP, 'm', tz=None, xdate=True,
>> ydate=False, label="packets/s in")
>> drawTxPaq, = par1.plot_date(dates, txP, 'y', tz=None, xdate=True,
>> ydate=False, label="packets/s out")
>> drawColls, = par2.plot_date(dates, col, 'r', tz=None, xdate=True,
>> ydate=False, label="collisions")
>>
>> fig.autofmt_xdate()
>>
>> host.set_xlabel("Time")
>> host.set_ylabel("kB/s")
>> par1.set_ylabel("Packets/s")
>>
>> host.legend()
>>
>> host.axis["left"].label.set_color(drawRxByt.get_color())
>> host.axis["left"].label.set_color(drawTxByt.get_color())
>> par1.axis["right"].label.set_color(drawRxPaq.get_color())
>> par1.axis["right"].label.set_color(drawtxPaq.get_color())
>> par2.axis["right2"].label.set_color(drawColls.get_color())
>>
>> ethPlot.draw()
>> pylab.savefig( './test.png', dpi=(640/8))
>>
>>
>>
>>
>> Maybe I do something wrong somewhere here, but other scripts that do the
>> same for a single graphwork like a charm. So it's not a question of
>> dataType
>> or something. To compare with a working code, here is the first version of
>> the fuction that does the job on single graphs without any problem :
>>
>> def drawEthGraph(filename, hdates, rxP, txP, rxB, txB, col):
>>  ethPlot = pyplot
>>  fig = ethPlot.figure()
>>  ax = fig.add_subplot(111)
>>  ax.plot_date(hdates, rxP, 'g', None, True, False)
>>  ax.plot_date(hdates, txP, 'b', None, True, False)
>>  ax.plot_date(hdates, rxB, 'g', None, True, False)
>>  ax.plot_date(hdates, txB, 'b', None, True, False)
>>  ax.plot_date(hdates, col, 'r', None, True, False)
>>  ax.axis([ hdates[0], ( hdates[0] + 0.042 ), -7000, 7000])
>>  ax.grid(True)
>>  fig.autofmt_xdate()
>>  pylab.savefig( filename, dpi=(640/8))
>>
>>
>> I don't think I understand the whole process of generation, but I thought
>> at
>> least at the beginnig I was having a good feeling with this API.
>> Now I wonder how to go around this. Maybe you'll have an idea :-o
>>
>> Best regards
>>
>> DvD
>>
>> from matplotlib.dates import date2num
>> from matplotlib import pyplot
>> from matplotlib import pylab
>> from mpl_toolkits.axes_grid.parasite_axes import SubplotHost
>> from datetime import datetime
>>
>> dates = [ 733581.20833333337, 733581.20837962965, 733581.20842592593,
>> 733581.20847222221, 733581.20851851848,
>>     733581.20855324075, 733581.20858796302, 733581.2086342593,
>> 733581.20866898145, 733581.20871527772]
>> rxB = [054L, 130L, 144L, 54L, 36L, 9L, 35L, 43L, 85L, 43L]
>> txB = [4L, 9L, 9L, 5L, 4L, 4L, 4L, 5L, 6L, 5L]
>> rxP = [77, 228, 251, 112, 77, 42, 75, 97, 147, 91]
>> txP = [61, 177, 188, 90, 61, 40, 64, 76, 113, 77]
>> col = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0]
>>
>> ethPlot = pyplot
>> fig = ethPlot.figure()
>> host = SubplotHost(fig, 111)
>>
>> host.set_ylabel("kB/s")
>> host.set_xlabel("Time")
>>
>> par1 = host.twinx()
>> par2 = host.twinx()
>>
>> par1.set_ylabel("Packets/s")
>>
>> par2.axis["right"].set_visible(False)
>>
>> offset = 60, 0
>> new_axisline = par2.get_grid_helper().new_fixed_axis
>> par2.axis["right2"] = new_axisline(loc="right",
>>                  axes=par2,
>>                  offset=offset)
>>
>> par2.axis["right2"].label.set_visible(True)
>> par2.axis["right2"].set_label("Collisions")
>>
>> par1.set_ylim(0, 6000)
>> par2.set_ylim(0, 7000)
>>
>> host.axis([ dates[0], ( dates[0] + 0.041 ), -7000, 7000])
>> par1.axis([ dates[0], ( dates[0] + 0.041 ), -10000, 10000])
>> par2.axis([ dates[0], ( dates[0] + 0.041 ), -700, 700])
>>
>> fig.add_axes(host)
>> ethPlot.subplots_adjust(right=0.75)
>>
>> drawRxByt, = host.plot_date(dates, rxB, 'g', tz=None, xdate=True,
>> ydate=False, label="kB/s in")
>> drawTxByt, = host.plot_date(dates, txB, 'b', tz=None, xdate=True,
>> ydate=False, label="kB/s out")
>> drawRxPaq, = par1.plot_date(dates, rxP, 'm', tz=None, xdate=True,
>> ydate=False, label="packets/s in")
>> drawTxPaq, = par1.plot_date(dates, txP, 'y', tz=None, xdate=True,
>> ydate=False, label="packets/s out")
>> drawColls, = par2.plot_date(dates, col, 'r', tz=None, xdate=True,
>> ydate=False, label="collisions")
>>
>> fig.autofmt_xdate()
>>
>> host.set_xlabel("Time")
>> host.set_ylabel("kB/s")
>> par1.set_ylabel("Packets/s")
>>
>> host.legend()
>>
>> host.axis["left"].label.set_color(drawRxByt.get_color())
>> host.axis["left"].label.set_color(drawTxByt.get_color())
>> par1.axis["right"].label.set_color(drawRxPaq.get_color())
>> par1.axis["right"].label.set_color(drawtxPaq.get_color())
>> par2.axis["right2"].label.set_color(drawColls.get_color())
>>
>> ethPlot.draw()
>> pylab.savefig( './test.png', dpi=(640/8))
>>
>>
>>
>> ------------------------------------------------------------------------------
>>
>> _______________________________________________
>> Matplotlib-users mailing list
>> Mat...@li...
>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>>
>>
>
> --
> View this message in context: http://old.nabble.com/%22Ordinal-must-be-%3E%3D-1%22-with-SuplotHost-and-dates-tp24305444p27144728.html
> Sent from the matplotlib - users mailing list archive at Nabble.com.
>
>
> ------------------------------------------------------------------------------
> This SF.Net email is sponsored by the Verizon Developer Community
> Take advantage of Verizon's best-in-class app development support
> A streamlined, 14 day to market process makes app distribution fast and easy
> Join now and get one step closer to millions of Verizon customers
> http://p.sf.net/sfu/verizon-dev2dev
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
From: Solomon M N. <sol...@tw...> - 2010年05月19日 21:47:59
Hello, 
I came across problem of label rotation with autofmt_xdate() in subplothost
too. Is there a new version with the bug fixed or a workaround to doing the
label rotation in subplothost? 
Thanks,
Solomon
Jae-Joon Lee wrote:
> 
> The workarounds suggested in this thread does not work?
> To me, the ordinal thing is not actually a bug, but you need some
> extra caution to avoid this error happening.
> 
> The issue with the label roration is a different matter though.
> 
> Regards,
> 
> -JJ
> 
> 
> On Wed, Jan 13, 2010 at 8:16 AM, Rodribat <rod...@gm...> wrote:
>>
>>
>> Hi matplotlib users!
>>
>> Did someone solve the problem of use fig.autofmt_xdate() function with
>> SubplotHost object?
>> I googled for it and I found this question only here, without solution.
>> Is
>> there a bug? Anyone knows
>> someway to solve this?
>>
>> Thank you,
>>
>> []'s
>>
>> Rodrigo Batista
>>
>>
>> David GUERINEAU wrote:
>>>
>>> Hi matplotlib_users !
>>>
>>> I'm David from Berlin, and believe I'm experiencing some problem with
>>> the
>>> SubplotHost module:
>>>
>>> I'm generating graphs from hudge databases of cpu and ethernet
>>> statistics,
>>> and I wanted to mix several graphs concerning ethernet statistics in the
>>> same figure,
>>> with time as x axis, and bytes-in, bytes-out, packets-in, packets-out
>>> and
>>> number of
>>> collisions as three different y axes, with three different scale.
>>>
>>> I took the inspiration from
>>>
>>> for the x axes and from
>>>
>>> http://matplotlib.sourceforge.net/examples/axes_grid/demo_parasite_axes2.html
>>> for the y axes
>>>
>>> The following code is a synthetic reproduction of the problem I'm
>>> experiencing (it is also attached):
>>>
>>> from matplotlib.dates import date2num
>>> from matplotlib import pyplot
>>> from matplotlib import pylab
>>> from mpl_toolkits.axes_grid.parasite_axes import SubplotHost
>>> from datetime import datetime
>>>
>>> dates = [ 733581.20833333337, 733581.20837962965, 733581.20842592593,
>>> 733581.20847222221, 733581.20851851848,
>>>    733581.20855324075, 733581.20858796302, 733581.2086342593,
>>> 733581.20866898145, 733581.20871527772]
>>> rxB = [054L, 130L, 144L, 54L, 36L, 9L, 35L, 43L, 85L, 43L]
>>> txB = [4L, 9L, 9L, 5L, 4L, 4L, 4L, 5L, 6L, 5L]
>>> rxP = [77, 228, 251, 112, 77, 42, 75, 97, 147, 91]
>>> txP = [61, 177, 188, 90, 61, 40, 64, 76, 113, 77]
>>> col = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0]
>>>
>>> ethPlot = pyplot
>>> fig = ethPlot.figure()
>>> host = SubplotHost(fig, 111)
>>>
>>> host.set_ylabel("kB/s")
>>> host.set_xlabel("Time")
>>>
>>> par1 = host.twinx()
>>> par2 = host.twinx()
>>>
>>> par1.set_ylabel("Packets/s")
>>>
>>> par2.axis["right"].set_visible(False)
>>>
>>> offset = 60, 0
>>> new_axisline = par2.get_grid_helper().new_fixed_axis
>>> par2.axis["right2"] = new_axisline(loc="right",
>>>           axes=par2,
>>>           offset=offset)
>>>
>>> par2.axis["right2"].label.set_visible(True)
>>> par2.axis["right2"].set_label("Collisions")
>>>
>>> par1.set_ylim(0, 6000)
>>> par2.set_ylim(0, 7000)
>>>
>>> host.axis([ dates[0], ( dates[0] + 0.041 ), -7000, 7000])
>>> par1.axis([ dates[0], ( dates[0] + 0.041 ), -10000, 10000])
>>> par2.axis([ dates[0], ( dates[0] + 0.041 ), -700, 700])
>>>
>>> fig.add_axes(host)
>>> ethPlot.subplots_adjust(right=0.75)
>>>
>>> drawRxByt, = host.plot_date(dates, rxB, 'g', tz=None, xdate=True,
>>> ydate=False, label="kB/s in")
>>> drawTxByt, = host.plot_date(dates, txB, 'b', tz=None, xdate=True,
>>> ydate=False, label="kB/s out")
>>> drawRxPaq, = par1.plot_date(dates, rxP, 'm', tz=None, xdate=True,
>>> ydate=False, label="packets/s in")
>>> drawTxPaq, = par1.plot_date(dates, txP, 'y', tz=None, xdate=True,
>>> ydate=False, label="packets/s out")
>>> drawColls, = par2.plot_date(dates, col, 'r', tz=None, xdate=True,
>>> ydate=False, label="collisions")
>>>
>>> fig.autofmt_xdate()
>>>
>>> host.set_xlabel("Time")
>>> host.set_ylabel("kB/s")
>>> par1.set_ylabel("Packets/s")
>>>
>>> host.legend()
>>>
>>> host.axis["left"].label.set_color(drawRxByt.get_color())
>>> host.axis["left"].label.set_color(drawTxByt.get_color())
>>> par1.axis["right"].label.set_color(drawRxPaq.get_color())
>>> par1.axis["right"].label.set_color(drawtxPaq.get_color())
>>> par2.axis["right2"].label.set_color(drawColls.get_color())
>>>
>>> ethPlot.draw()
>>> pylab.savefig( './test.png', dpi=(640/8))
>>>
>>>
>>>
>>>
>>> Maybe I do something wrong somewhere here, but other scripts that do the
>>> same for a single graphwork like a charm. So it's not a question of
>>> dataType
>>> or something. To compare with a working code, here is the first version
>>> of
>>> the fuction that does the job on single graphs without any problem :
>>>
>>> def drawEthGraph(filename, hdates, rxP, txP, rxB, txB, col):
>>>  ethPlot = pyplot
>>>  fig = ethPlot.figure()
>>>  ax = fig.add_subplot(111)
>>>  ax.plot_date(hdates, rxP, 'g', None, True, False)
>>>  ax.plot_date(hdates, txP, 'b', None, True, False)
>>>  ax.plot_date(hdates, rxB, 'g', None, True, False)
>>>  ax.plot_date(hdates, txB, 'b', None, True, False)
>>>  ax.plot_date(hdates, col, 'r', None, True, False)
>>>  ax.axis([ hdates[0], ( hdates[0] + 0.042 ), -7000, 7000])
>>>  ax.grid(True)
>>>  fig.autofmt_xdate()
>>>  pylab.savefig( filename, dpi=(640/8))
>>>
>>>
>>> I don't think I understand the whole process of generation, but I
>>> thought
>>> at
>>> least at the beginnig I was having a good feeling with this API.
>>> Now I wonder how to go around this. Maybe you'll have an idea :-o
>>>
>>> Best regards
>>>
>>> DvD
>>>
>>> from matplotlib.dates import date2num
>>> from matplotlib import pyplot
>>> from matplotlib import pylab
>>> from mpl_toolkits.axes_grid.parasite_axes import SubplotHost
>>> from datetime import datetime
>>>
>>> dates = [ 733581.20833333337, 733581.20837962965, 733581.20842592593,
>>> 733581.20847222221, 733581.20851851848,
>>>     733581.20855324075, 733581.20858796302, 733581.2086342593,
>>> 733581.20866898145, 733581.20871527772]
>>> rxB = [054L, 130L, 144L, 54L, 36L, 9L, 35L, 43L, 85L, 43L]
>>> txB = [4L, 9L, 9L, 5L, 4L, 4L, 4L, 5L, 6L, 5L]
>>> rxP = [77, 228, 251, 112, 77, 42, 75, 97, 147, 91]
>>> txP = [61, 177, 188, 90, 61, 40, 64, 76, 113, 77]
>>> col = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0]
>>>
>>> ethPlot = pyplot
>>> fig = ethPlot.figure()
>>> host = SubplotHost(fig, 111)
>>>
>>> host.set_ylabel("kB/s")
>>> host.set_xlabel("Time")
>>>
>>> par1 = host.twinx()
>>> par2 = host.twinx()
>>>
>>> par1.set_ylabel("Packets/s")
>>>
>>> par2.axis["right"].set_visible(False)
>>>
>>> offset = 60, 0
>>> new_axisline = par2.get_grid_helper().new_fixed_axis
>>> par2.axis["right2"] = new_axisline(loc="right",
>>>                  axes=par2,
>>>                  offset=offset)
>>>
>>> par2.axis["right2"].label.set_visible(True)
>>> par2.axis["right2"].set_label("Collisions")
>>>
>>> par1.set_ylim(0, 6000)
>>> par2.set_ylim(0, 7000)
>>>
>>> host.axis([ dates[0], ( dates[0] + 0.041 ), -7000, 7000])
>>> par1.axis([ dates[0], ( dates[0] + 0.041 ), -10000, 10000])
>>> par2.axis([ dates[0], ( dates[0] + 0.041 ), -700, 700])
>>>
>>> fig.add_axes(host)
>>> ethPlot.subplots_adjust(right=0.75)
>>>
>>> drawRxByt, = host.plot_date(dates, rxB, 'g', tz=None, xdate=True,
>>> ydate=False, label="kB/s in")
>>> drawTxByt, = host.plot_date(dates, txB, 'b', tz=None, xdate=True,
>>> ydate=False, label="kB/s out")
>>> drawRxPaq, = par1.plot_date(dates, rxP, 'm', tz=None, xdate=True,
>>> ydate=False, label="packets/s in")
>>> drawTxPaq, = par1.plot_date(dates, txP, 'y', tz=None, xdate=True,
>>> ydate=False, label="packets/s out")
>>> drawColls, = par2.plot_date(dates, col, 'r', tz=None, xdate=True,
>>> ydate=False, label="collisions")
>>>
>>> fig.autofmt_xdate()
>>>
>>> host.set_xlabel("Time")
>>> host.set_ylabel("kB/s")
>>> par1.set_ylabel("Packets/s")
>>>
>>> host.legend()
>>>
>>> host.axis["left"].label.set_color(drawRxByt.get_color())
>>> host.axis["left"].label.set_color(drawTxByt.get_color())
>>> par1.axis["right"].label.set_color(drawRxPaq.get_color())
>>> par1.axis["right"].label.set_color(drawtxPaq.get_color())
>>> par2.axis["right2"].label.set_color(drawColls.get_color())
>>>
>>> ethPlot.draw()
>>> pylab.savefig( './test.png', dpi=(640/8))
>>>
>>>
>>>
>>> ------------------------------------------------------------------------------
>>>
>>> _______________________________________________
>>> Matplotlib-users mailing list
>>> Mat...@li...
>>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>>>
>>>
>>
>> --
>> View this message in context:
>> http://old.nabble.com/%22Ordinal-must-be-%3E%3D-1%22-with-SuplotHost-and-dates-tp24305444p27144728.html
>> Sent from the matplotlib - users mailing list archive at Nabble.com.
>>
>>
>> ------------------------------------------------------------------------------
>> This SF.Net email is sponsored by the Verizon Developer Community
>> Take advantage of Verizon's best-in-class app development support
>> A streamlined, 14 day to market process makes app distribution fast and
>> easy
>> Join now and get one step closer to millions of Verizon customers
>> http://p.sf.net/sfu/verizon-dev2dev
>> _______________________________________________
>> Matplotlib-users mailing list
>> Mat...@li...
>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>>
> 
> ------------------------------------------------------------------------------
> This SF.Net email is sponsored by the Verizon Developer Community
> Take advantage of Verizon's best-in-class app development support
> A streamlined, 14 day to market process makes app distribution fast and
> easy
> Join now and get one step closer to millions of Verizon customers
> http://p.sf.net/sfu/verizon-dev2dev 
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
> 
> 
-- 
View this message in context: http://old.nabble.com/%22Ordinal-must-be-%3E%3D-1%22-with-SuplotHost-and-dates-tp24305444p28614682.html
Sent from the matplotlib - users mailing list archive at Nabble.com.
From: Jae-Joon L. <lee...@gm...> - 2010年05月21日 15:01:55
On Wed, May 19, 2010 at 5:47 PM, Solomon M Negusse
<sol...@tw...> wrote:
> Hello,
> I came across problem of label rotation with autofmt_xdate() in subplothost
> too. Is there a new version with the bug fixed or a workaround to doing the
> label rotation in subplothost?
>
While this is fixed in the svn, there is no release yet.
One workaround is to turn off axisline mode.
host = SubplotHost(fig, 111)
host.toggle_axisline(False)
Note that, with this change, things like
host.axis["left"].label.set_color(drawRxByt.get_color())
won't work and you have to use the methods of original matplotlib Axes.
Regards,
-JJ
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.
Thanks for helping keep SourceForge clean.
X





Briefly describe the problem (required):
Upload screenshot of ad (required):
Select a file, or drag & drop file here.
Screenshot instructions:

Click URL instructions:
Right-click on the ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)

More information about our ad policies

Ad destination/click URL:

AltStyle によって変換されたページ (->オリジナル) /