SourceForge logo
SourceForge logo
Menu

matplotlib-users — Discussion related to using matplotlib

You can subscribe to this list here.

2003 Jan
Feb
Mar
Apr
May
(3)
Jun
Jul
Aug
(12)
Sep
(12)
Oct
(56)
Nov
(65)
Dec
(37)
2004 Jan
(59)
Feb
(78)
Mar
(153)
Apr
(205)
May
(184)
Jun
(123)
Jul
(171)
Aug
(156)
Sep
(190)
Oct
(120)
Nov
(154)
Dec
(223)
2005 Jan
(184)
Feb
(267)
Mar
(214)
Apr
(286)
May
(320)
Jun
(299)
Jul
(348)
Aug
(283)
Sep
(355)
Oct
(293)
Nov
(232)
Dec
(203)
2006 Jan
(352)
Feb
(358)
Mar
(403)
Apr
(313)
May
(165)
Jun
(281)
Jul
(316)
Aug
(228)
Sep
(279)
Oct
(243)
Nov
(315)
Dec
(345)
2007 Jan
(260)
Feb
(323)
Mar
(340)
Apr
(319)
May
(290)
Jun
(296)
Jul
(221)
Aug
(292)
Sep
(242)
Oct
(248)
Nov
(242)
Dec
(332)
2008 Jan
(312)
Feb
(359)
Mar
(454)
Apr
(287)
May
(340)
Jun
(450)
Jul
(403)
Aug
(324)
Sep
(349)
Oct
(385)
Nov
(363)
Dec
(437)
2009 Jan
(500)
Feb
(301)
Mar
(409)
Apr
(486)
May
(545)
Jun
(391)
Jul
(518)
Aug
(497)
Sep
(492)
Oct
(429)
Nov
(357)
Dec
(310)
2010 Jan
(371)
Feb
(657)
Mar
(519)
Apr
(432)
May
(312)
Jun
(416)
Jul
(477)
Aug
(386)
Sep
(419)
Oct
(435)
Nov
(320)
Dec
(202)
2011 Jan
(321)
Feb
(413)
Mar
(299)
Apr
(215)
May
(284)
Jun
(203)
Jul
(207)
Aug
(314)
Sep
(321)
Oct
(259)
Nov
(347)
Dec
(209)
2012 Jan
(322)
Feb
(414)
Mar
(377)
Apr
(179)
May
(173)
Jun
(234)
Jul
(295)
Aug
(239)
Sep
(276)
Oct
(355)
Nov
(144)
Dec
(108)
2013 Jan
(170)
Feb
(89)
Mar
(204)
Apr
(133)
May
(142)
Jun
(89)
Jul
(160)
Aug
(180)
Sep
(69)
Oct
(136)
Nov
(83)
Dec
(32)
2014 Jan
(71)
Feb
(90)
Mar
(161)
Apr
(117)
May
(78)
Jun
(94)
Jul
(60)
Aug
(83)
Sep
(102)
Oct
(132)
Nov
(154)
Dec
(96)
2015 Jan
(45)
Feb
(138)
Mar
(176)
Apr
(132)
May
(119)
Jun
(124)
Jul
(77)
Aug
(31)
Sep
(34)
Oct
(22)
Nov
(23)
Dec
(9)
2016 Jan
(26)
Feb
(17)
Mar
(10)
Apr
(8)
May
(4)
Jun
(8)
Jul
(6)
Aug
(5)
Sep
(9)
Oct
(4)
Nov
Dec
2017 Jan
(5)
Feb
(7)
Mar
(1)
Apr
(5)
May
Jun
(3)
Jul
(6)
Aug
(1)
Sep
Oct
(2)
Nov
(1)
Dec
2018 Jan
Feb
Mar
Apr
(1)
May
Jun
Jul
Aug
Sep
Oct
Nov
Dec
2020 Jan
Feb
Mar
Apr
May
(1)
Jun
Jul
Aug
Sep
Oct
Nov
Dec
2025 Jan
(1)
Feb
Mar
Apr
May
Jun
Jul
Aug
Sep
Oct
Nov
Dec
S M T W T F S


1
(9)
2
(8)
3
4
(6)
5
6
7
(41)
8
(18)
9
(25)
10
(18)
11
(10)
12
(13)
13
(7)
14
(4)
15
(12)
16
(6)
17
(9)
18
(7)
19
(2)
20
(5)
21
(7)
22
(2)
23
(11)
24
(11)
25
(14)
26
(3)
27
(3)
28
(17)
29
(7)
30
(16)
31
(8)


Showing 10 results of 10

From: Goyo <goy...@gm...> - 2011年03月11日 22:18:45
2011年3月11日 Luciano Fleischfresser <l_...@ya...>:
> [...]
> I have to confess that object-oriented programming seems very
> counter-intuitive to me.
> Hopefully it will come more naturally soon.
This has nothing to do with OOP, you just need to know what
command/function/method does what you want. It happens that in
matplotlib plots are autoscaled by default but not tightly. You can
change this behavoir using autoscale. There is a functional version
pyplot.autoscale but for scripting is usually better the
axes.autoscale version because it make explicit in your code which
axes is affected. For interactive plotting, the functional version may
be more convenient.
>
> Along the same lines of my original query, this one I think is more obscure,
> so here it goes:
>
> Same script, just another .csv file with the same format. This time around,
> the plot comes up
> with UTC times for the labels on the x-axis. The first one came with the
> dates.
>
> Does anybody know how to tell matplotlib to always put dates?
Matplotlib automatically choose a formatter for labels, based on the
interval to plot and the like. If you don't like it, use your own.
Maybe this:
import matplotlib.dates as mdates
formatter = mdates.DateFormatter('%d-%b-%y-%H:%M:%S')
axes.xaxis.set_major_formatter(formatter)
Goyo
From: Benjamin R. <ben...@ou...> - 2011年03月11日 22:05:16
2011年3月10日 Søren Nielsen <sor...@gm...>
> Hi,
>
> When I do an errorbar plot (a.errorbar(), a = axis) with negative values
> and then try to change the yscale to log (a.set_yscale('log')) matplotlib
> crashes with:
>
> Traceback (most recent call last):
> File
> "/usr/lib64/python2.6/site-packages/wx-2.8-gtk2-unicode/wx/_core.py", line
> 14636, in <lambda>
> lambda event: event.callable(*event.args, **event.kw) )
> File "/home/specuser/new_workspace/TestDriven/src/RAWPlot.py", line 371,
> in plotSASM
> line, ec, el = a.errorbar(sasm.q[q_min:q_max], sasm.i[q_min:q_max],
> sasm.err[q_min:q_max], picker = 3, label = legend_label, **kwargs)
> File "/usr/lib64/python2.6/site-packages/matplotlib/axes.py", line 4872,
> in errorbar
> barcols.append( self.vlines(x, lower, upper, **lines_kw) )
> File "/usr/lib64/python2.6/site-packages/matplotlib/axes.py", line 3302,
> in vlines
> self.autoscale_view()
> File "/usr/lib64/python2.6/site-packages/matplotlib/axes.py", line 1627,
> in autoscale_view
> YL = self.yaxis.get_major_locator().view_limits(y0, y1)
> File "/usr/lib64/python2.6/site-packages/matplotlib/ticker.py", line
> 1119, in view_limits
> if not is_decade(vmin,self._base): vmin = decade_down(vmin,self._base)
> File "/usr/lib64/python2.6/site-packages/matplotlib/ticker.py", line
> 1030, in is_decade
> return lx==int(lx)
> OverflowError: cannot convert float infinity to integer
> Traceback (most recent call last):
> File
> "/usr/lib64/python2.6/site-packages/wx-2.8-gtk2-unicode/wx/_core.py", line
> 14636, in <lambda>
> lambda event: event.callable(*event.args, **event.kw) )
> File "/home/specuser/new_workspace/TestDriven/src/RAW.py", line 1953, in
> addItem
> newItem = ManipItemPanel(self.underpanel, sasm, font_colour =
> item_colour)
> File "/home/specuser/new_workspace/TestDriven/src/RAW.py", line 2353, in
> __init__
> color = conv.to_rgb(self.sasm.line.get_mfc())
> AttributeError: 'NoneType' object has no attribute 'get_mfc'
>
> I don't think this should be the expected outcome.. rather it should not
> plot values that are illegal/negative (i.e. ignore them).
>
> Is there a way I can get around this without having to search through my
> data and remove points that are negative or NaN or INF when the yscale needs
> to be log? That would also show an incorrect curve since a line would be
> drawn across the points that were removed.. It should rather be gaps in the
> line.
>
> Thanks,
> Soren
>
>
>
>
Soren,
This is a bug I encountered recently in my investigations with log scales.
While most projections are handling this properly, there are some cases
where this problem sneaks in. I have not been able to figure out how to
permanently address this issue.
For reference, the similiar issue is when zooming in on polar plots with the
radial axis in log scale.
Ben Root
From: Goyo <goy...@gm...> - 2011年03月11日 21:18:26
2011年3月10日 Søren Nielsen <sor...@gm...>:
> Is there a way I can get around this without having to search through my
> data and remove points that are negative or NaN or INF when the yscale needs
> to be log? That would also show an incorrect curve since a line would be
> drawn across the points that were removed.. It should rather be gaps in the
> line.
You can use masked arrays. Masked values don't get plotted. Sample
code (not tested):
import numpy.ma as ma # masked arrays module
...
mdata = ma.masked_array(data)
mdata[mdata <= 0] = ma.masked
plot(mdata)
Goyo
From: Daniel M. <dan...@go...> - 2011年03月11日 18:59:14
Hi Eric,
thank you so much for pointing this out! Didn't know about the
function before, it really helps me a lot!
However, for the current problem it doesn't help. The scaling of the
second axis broken without any margin or padding changes.
As a workaround, I could of course plot the data two times, first in
the first axis, and then in the second axis, and make sure the margins
are equal.
However, this would considerable increase the file size for vector
based formats as I plot *a lot* of data points :)
Either way, thanks a lot for this hint!
2011年3月11日 Eric Firing <ef...@ha...>:
> On 03/10/2011 01:13 AM, Daniel Mader wrote:
>> Maybe I should mention that there are actually two reasons why I don't
>> like this behavior:
>>
>> 1) it's sometimes very hard to read what's going on,
>> 2) there also seems to be a bug when the limits are changed later, see
>> attached results: the upper subplot is default, the lower subplot uses
>> the padding.
>>
>> ##--------------------------
>> def update_ax2(ax1):
>>  '''
>>  Automatically update ylim of ax2 when ylim of ax1 changes.
>>  '''
>>  y1, y2 = ax1.get_ylim()
>>  ## modify the limits
>>  ax2.set_ylim((Tc(y1), Tc(y2)))
>>  ax2.figure.canvas.draw()
>>
>>  Both plots are actually identical but use a different x-axis. In
>> ordert to create a nicely padded plot, I use the following function,
>> which breaks the scaling information AND the calculation of the second
>> axis limits:
>>
>> ##--------------------------
>> def axispaddingAX(ax):
>>  '''
>>  Saubere bzw. schoene Achsenskalierung für MPL-Skripten.
>>  '''
>>  lines = ax.get_lines()
>>  xtemp = []
>>  ytemp = []
>>  for line in lines:
>>   xtemp.append(min(line.get_xdata()))
>>   xtemp.append(max(line.get_xdata()))
>>   ytemp.append(min(line.get_ydata()))
>>   ytemp.append(max(line.get_ydata()))
>>  xmin,xmax = min(xtemp),max(xtemp)
>>  ymin,ymax = min(ytemp),max(ytemp)
>>  span = 0.05
>>  rangex = (xmin-span*(xmax-xmin), xmax+span*(xmax-xmin))
>>  rangey = (ymin-span*(ymax-ymin), ymax+span*(ymax-ymin))
>>  ax.set_xlim(rangex)
>>  ax.set_ylim(rangey)
>
> I don't know if it would help overall, but in place of your padding
> function, have you considered the pylab or pyplot margins() function?
>
> Eric
>
>>
>>
>> Thanks a lot in advance for any hint or comment on this,
>> Daniel
>>
>> 2011年3月10日 Daniel Mader<dan...@go...>:
>>> Hi,
>>>
>>> is it possible to change the default y-axis scaling so that the
>>> ticks/label are not with respect to the large offset?
>>>
>>> For example:
>>>
>>> import scipy
>>> import pylab
>>>
>>> x = scipy.arange(100)
>>> y = scipy.rand(100) + 1000006
>>>
>>> pylab.figure()
>>> pylab.plot(x,y)
>>> pylab.grid()
>>>
>>> pylab.show()
>>>
>>> This gives the y-limits as (0,1) with respect to 1000006. This makes
>>> it very hard to read. I'd like to be able to configure this manually.
>>>
>>> Thanks in advance,
>>> Daniel
On 03/10/2011 01:13 AM, Daniel Mader wrote:
> Maybe I should mention that there are actually two reasons why I don't
> like this behavior:
>
> 1) it's sometimes very hard to read what's going on,
> 2) there also seems to be a bug when the limits are changed later, see
> attached results: the upper subplot is default, the lower subplot uses
> the padding.
>
> ##--------------------------
> def update_ax2(ax1):
> '''
> Automatically update ylim of ax2 when ylim of ax1 changes.
> '''
> y1, y2 = ax1.get_ylim()
> ## modify the limits
> ax2.set_ylim((Tc(y1), Tc(y2)))
> ax2.figure.canvas.draw()
>
> Both plots are actually identical but use a different x-axis. In
> ordert to create a nicely padded plot, I use the following function,
> which breaks the scaling information AND the calculation of the second
> axis limits:
>
> ##--------------------------
> def axispaddingAX(ax):
> '''
> Saubere bzw. schoene Achsenskalierung für MPL-Skripten.
> '''
> lines = ax.get_lines()
> xtemp = []
> ytemp = []
> for line in lines:
> xtemp.append(min(line.get_xdata()))
> xtemp.append(max(line.get_xdata()))
> ytemp.append(min(line.get_ydata()))
> ytemp.append(max(line.get_ydata()))
> xmin,xmax = min(xtemp),max(xtemp)
> ymin,ymax = min(ytemp),max(ytemp)
> span = 0.05
> rangex = (xmin-span*(xmax-xmin), xmax+span*(xmax-xmin))
> rangey = (ymin-span*(ymax-ymin), ymax+span*(ymax-ymin))
> ax.set_xlim(rangex)
> ax.set_ylim(rangey)
I don't know if it would help overall, but in place of your padding 
function, have you considered the pylab or pyplot margins() function?
Eric
>
>
> Thanks a lot in advance for any hint or comment on this,
> Daniel
>
> 2011年3月10日 Daniel Mader<dan...@go...>:
>> Hi,
>>
>> is it possible to change the default y-axis scaling so that the
>> ticks/label are not with respect to the large offset?
>>
>> For example:
>>
>> import scipy
>> import pylab
>>
>> x = scipy.arange(100)
>> y = scipy.rand(100) + 1000006
>>
>> pylab.figure()
>> pylab.plot(x,y)
>> pylab.grid()
>>
>> pylab.show()
>>
>> This gives the y-limits as (0,1) with respect to 1000006. This makes
>> it very hard to read. I'd like to be able to configure this manually.
>>
>> Thanks in advance,
>> Daniel
>>
>>
>>
>> ------------------------------------------------------------------------------
>> Colocation vs. Managed Hosting
>> A question and answer guide to determining the best fit
>> for your organization - today and in the future.
>> http://p.sf.net/sfu/internap-sfd2d
>>
>>
>> _______________________________________________
>> Matplotlib-users mailing list
>> Mat...@li...
>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
From: Thomas R. <tho...@gm...> - 2011年03月11日 17:47:09
Hi Jae-Joon,
I tried inserting:
mpl.rc('ps', usedistiller=None)
after importing matplotlib, and I get:
$ du -sk *.eps
6204	test_1.eps
34104	test_2.eps
using 'ghostscript' I get:
$ du -sk *.eps
34096	test_1.eps
34104	test_2.eps
and using 'xpdf' raises an exception:
 File "/Users/tom/Library/Python/2.6/site-packages/matplotlib/backends/backend_ps.py", line 1091, in _print_figure
 xpdf_distill(tmpfile, isEPSF, ptype=papertype, bbox=bbox)
 File "/Users/tom/Library/Python/2.6/site-packages/matplotlib/backends/backend_ps.py", line 1421, in xpdf_distill
 image.\nHere is the full report generated by pdftops: \n\n' + fh.read())
RuntimeError: pdftops was not able to process your image.
Here is the full report generated by pdftops: 
I don't have a matplotlibrc file, and I am using:
Ghostscript: GPL Ghostscript 9.00 (2010年09月14日)
LaTeX: Version 3.1415926-1.40.10 (TeX Live 2009)
and I'm using the latest head from github for matplotlib.
Cheers,
Tom
On Mar 8, 2011, at 7:31 AM, Jae-Joon Lee wrote:
> With current master at git repo, I cannot reproduce this.
> Both test_1.eps and test_2.eps are ~4M in size.
> 
> Can you check if the file size varies significantly with rc parameters
> ps.usedistiller?
> I'm not sure how text setting can affect the images.
> 
> Regards,
> 
> -JJ
> 
> 
> 
> On Tue, Mar 1, 2011 at 7:23 AM, Thomas Robitaille
> <tho...@gm...> wrote:
>> Hi,
>> 
>> In the following example:
>> 
>> ---
>> 
>> import numpy as np
>> 
>> import matplotlib as mpl
>> mpl.use('Agg')
>> import matplotlib.pyplot as plt
>> 
>> fig = plt.figure()
>> ax = fig.add_subplot(1, 1, 1)
>> ax.imshow(np.random.random((1024, 1024)), interpolation='nearest')
>> fig.savefig('test_1.eps')
>> 
>> mpl.rc('text', usetex=True)
>> 
>> fig = plt.figure()
>> ax = fig.add_subplot(1, 1, 1)
>> ax.imshow(np.random.random((1024, 1024)), interpolation='nearest')
>> fig.savefig('test_2.eps')
>> 
>> ---
>> 
>> the file test_2.eps is almost 6 times larger than test_1.eps, and takes much longer to draw. It looks like in the first case, the image is rendered as a bitmap (the way it should be), whereas in the second case each pixel is drawn individually as a polygon. Is this a bug?
>> 
>> I am using r8988 of matplotlib.
>> 
>> Thanks for any help!
>> 
>> Thomas
>> ------------------------------------------------------------------------------
>> Free Software Download: Index, Search & Analyze Logs and other IT data in
>> Real-Time with Splunk. Collect, index and harness all the fast moving IT data
>> generated by your applications, servers and devices whether physical, virtual
>> or in the cloud. Deliver compliance at lower cost and gain new business
>> insights. http://p.sf.net/sfu/splunk-dev2dev
>> _______________________________________________
>> Matplotlib-users mailing list
>> Mat...@li...
>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>> 
From: Daniel M. <dan...@go...> - 2011年03月11日 09:59:52
Hi again,
unfortunately, the proposed solution breaks a second y-axis. Attached
is a script which demonstrates the problem in the third figure. The
second axis should be half of the first one.
import pylab
import scipy
pylab.close('all')
##------------------------------------------------------------------------------
## matplotlib.pyplot / pylab
x = scipy.arange(100)
y = scipy.rand(100) + 1000006
pylab.figure()
pylab.plot(x,y)
pylab.grid()
#pylab.ticklabel_format(useOffset=1000000, axis='y')
pylab.ticklabel_format(useOffset=False, axis='y')
##------------------------------------------------------------------------------
## matplotlib
fig = pylab.figure(figsize=(8,6))
ax = fig.add_subplot(111)
ax.plot(x,y)
ax.grid()
ax.ticklabel_format(useOffset=1000000, axis='y')
#ax.ticklabel_format(useOffset=False, axis='y')
##------------------------------------------------------------------------------
## matplotlib twinx()
fig = pylab.figure(figsize=(8,6))
ax1 = fig.add_subplot(111)
ax2 = ax1.twinx()
ax1.plot(x,y)
ax1.grid()
## automatically update ylim of ax2 when ylim of ax1 changes:
def update_ax2(ax1):
 y1, y2 = ax1.get_ylim()
 ## modify the limits
 ax2.set_ylim((y1/2., y2/2.))
 ax2.figure.canvas.draw()
ax1.callbacks.connect("ylim_changed", update_ax2)
ax1.ticklabel_format(useOffset=False, axis='y')
##------------------------------------------------------------------------------
pylab.show()
2011年3月10日 Daniel Mader <dan...@go...>:
> Hi Ben,
>
> thanks a lot, this really helpes in the simple example, I'll try to
> find out how to use it in the complex script. It seems 1.0.0 is recent
> enough for this!
>
> Thanks again,
> Daniel
>
> 2011年3月10日 Benjamin Root <ben...@ou...>:
>>
>>
>> On Thu, Mar 10, 2011 at 4:54 AM, Daniel Mader
>> <dan...@go...> wrote:
>>>
>>> Hi,
>>>
>>> is it possible to change the default y-axis scaling so that the
>>> ticks/label are not with respect to the large offset?
>>>
>>> For example:
>>>
>>> import scipy
>>> import pylab
>>>
>>> x = scipy.arange(100)
>>> y = scipy.rand(100) + 1000006
>>>
>>> pylab.figure()
>>> pylab.plot(x,y)
>>> pylab.grid()
>>>
>>> pylab.show()
>>>
>>> This gives the y-limits as (0,1) with respect to 1000006. This makes
>>> it very hard to read. I'd like to be able to configure this manually.
>>>
>>> Thanks in advance,
>>> Daniel
>>>
>>
>> I tried to fix matplotlib to be smarter about choosing the offset value a
>> while back, but I couldn't come up with something that worked well in the
>> general case. You can manually turn it off completely, and have the full
>> value displayed (or even manually set the offset value). If you have a very
>> recent matplotlib:
>>
>> import matplotlib.pyplot as plt
>> import numpy as np
>>
>> x = np.arange(100)
>> y = np.random.rand(100) + 1000006
>>
>> plt.figure()
>> plt.plot(x, y)
>> plt.grid()
>> plt.ticklabel_format(useOffset=1000000, axis='y')
>>
>> plt.show()
>>
>> Or you can turn it off by setting useOffset to False.
>>
>> If you don't have a recent enough matplotlib, you can turn it off completely
>> by doing something like this:
>>
>> import matplotlib.pyplot as plt
>> import numpy as np
>> from matplotlib.ticker import ScalarFormatter
>>
>> x = np.arange(100)
>> y = np.random.rand(100) + 1000006
>>
>> fig = plt.figure()
>> ax = fig.gca()
>> ax.plot(x, y)
>> ax.grid()
>> ax.yaxis.set_major_formatter(ScalarFormatter(useOffset=False))
>>
>> plt.show()
>>
>>
>> I hope this helps!
>> Ben Root
>>
>>
>
-- 
Zugallistr. 11/14
5020 Salzburg
M_at +43 699 10 54 54 53
T_at +43 662 841635
M_de +49 179 2300317
E dan...@go...
From: Jochen D. <joc...@nt...> - 2011年03月11日 07:44:28
Hi!
Changing the alpha-channel of a plotted image doesn't work for me in an 
ipython (pylab) shell.
The example below illustrates the problem (i hope so at least ...)
Running it with %run - everything is fine and the two images look the same.
Runing it line by line without the show, the figure shows up, the images 
are plotted, but the alpha-value of im1 is not set correctly so it's 
fully opaque in the left plot.
Is it just me or is it a bug, and if it's a bug is it a bug in pylab or 
in matplotlib?
Thanks in advance!
Jochen
Code:
import numpy as np
from matplotlib.pyplot import *
aimg = np.array([[0, 1, 1, 0],
 [0, 1, 2, 0],
 [0, 1, 3, 0],
 [0, 1, 4, 0]])
figure()
ax = subplot(121)
im1 = imshow(aimg, alpha = 1, interpolation='nearest')
im1.set_alpha(0.5)
ax = subplot(122)
im2 = imshow(aimg, alpha = 0.5, interpolation='nearest')
show()
From: Daniel H. <dh...@gm...> - 2011年03月11日 02:17:52
If the color of a polygon is set to 'none' (meaning no fill), the alpha set
for that polygon doesn't seem to apply to the boundary of that polygon. To
see this, change the following line in integral_demo.py (in the matplotlib
gallery):
poly = Polygon(verts, facecolor='0.8', edgecolor='k')
to
poly = Polygon(verts, facecolor='k', edgecolor='k',alpha=0.1)
in this case, the alpha is applied to both the fill and the edge. Now
change that same line to
poly = Polygon(verts, facecolor='none', edgecolor='k',alpha=0.1)
And then there is no fill as expected, but the edge is now dark black again
instead of being light due to the alpha of 0.1.
-- 
Daniel Hyams
dh...@gm...
From: Luciano F. <l_...@ya...> - 2011年03月11日 01:43:01
Hi Goyo,
Thanks a lot. tight='True' worked fine in my autoscale_view(). It's doing just 
what I needed.
I have to confess that object-oriented programming seems very counter-intuitive 
to me.
Hopefully it will come more naturally soon.
Along the same lines of my original query, this one I think is more obscure, so 
here it goes:
Same script, just another .csv file with the same format. This time around, the 
plot comes up
with UTC times for the labels on the x-axis. The first one came with the dates. 
Does anybody know how to tell matplotlib to always put dates?
Here is the code again:
from matplotlib.dates import strpdate2num
from matplotlib.ticker import MultipleLocator, FormatStrFormatter
import numpy as np
from pylab import *
datafile = ('t2vst2.csv')
print 'loading', datafile
times, temp1, temp2 = np.loadtxt(
 datafile, delimiter=',',
 converters={0:strpdate2num('%d-%b-%y-%H:%M:%S') },
 skiprows=1, usecols=(0,1,2), unpack=True)
fig = figure()
ax = fig.add_subplot(111)
ax.plot_date(times, temp1, 'r-',linewidth=2.0)
ax.plot_date(times, temp2, 'g-',linewidth=2.0)
ax.autoscale_view(tight='True', scalex=True, scaley=False)
fig.autofmt_xdate()
show()
Thanks again.
________________________________
From: Goyo <goy...@gm...>
To: Luciano Fleischfresser <lf...@ut...>
Cc: Luciano Fleischfresser <l_...@ya...>; 
mat...@li...
Sent: Wed, March 9, 2011 5:59:19 PM
Subject: Re: [Matplotlib-users] Axes formatting
2011年3月9日 Luciano Fleischfresser <l_...@ya...>:
> [...]
> Does anybody know how to make the plot area start right at the
> beginning of data and finish right at the end, so it spans the whole x axis?
I think this should do the trick:
axes.autoscale(axis='x', tight='True')
Goyo

Showing 10 results of 10

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 によって変換されたページ (->オリジナル) /