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
(1)
3
(4)
4
(4)
5
(9)
6
(5)
7
(12)
8
(5)
9
(27)
10
(10)
11
(4)
12
13
(6)
14
(12)
15
(16)
16
(13)
17
(9)
18
(1)
19
(2)
20
(4)
21
(9)
22
(5)
23
(2)
24
(6)
25
26
(1)
27
(9)
28
(7)
29
(2)
30
(9)


Showing 4 results of 4

From: calmar c. <ma...@ca...> - 2011年06月11日 08:35:57
On Fri, Jun 10, 2011 at 10:50:21PM -0500, Benjamin Root wrote:
Hi Ben and Scott and all,
> Admittedly, these following examples are for dates (and might even need to
> be updated...)
> [2]http://matplotlib.sourceforge.net/examples/api/date_demo.html
> [3]http://matplotlib.sourceforge.net/examples/api/date_index_formatter.html
> 
> There are others as well.
I see, thanks (all your examples here are pretty helpful for
understanding matplotlib somebit better - even so I'm using the
Formatter-Function now).
marco
-- 
 (o_ It rocks: LINUX + Command-Line-Interface
 //\ GPG: 0x59D90F4D
 V_/_ http://www.calmar.ws
From: Daniel M. <dan...@go...> - 2011年06月11日 08:34:48
Hi Karthik,
I cannot find any problem with your code. You are mixing modules a little
too much to my taste but it's not a technical problem.
Loading and saving the data works flawless here. Attached is an infile and a
modified script, please try this.
2011年6月11日 Karthikraja Velmurugan <vel...@gm...>
> *Hi Daniel, *
> * *
> *I used the code but there is small issue. I forgot to mention that my
> values are signed and unsigned decimal values. *
> *My values look like this
> *
> 0.0023 -0.0456 0.0419 0.094 -0.0004 0.0236 -0.0237 -0.0043 -0.0718
> 0.0095 0.0592 -0.0417 0.0023 0.0386 -0.0023 -0.0236 -0.1045 0.098
> -0.0006 0.0516 0.0463 -0.0035 -0.0442 0.1371 0.022 -0.0222 0.256 0.4903
> 0.0662 -0.0763 0.0064 0.1404
>
> *After running the code the "pylab.savetxt" saves the same data something
> like this*
>
>
> 8.205965840870644800e-01;8.034591567160346300e-01;5.493847743502982000e-01;2.581157685701491700e-01;6.409997826977161800e-01;3.719908502347885100e-01
>
I assume you are confused about the many decimals. Whenever floats are
processed by Python they are real floats, see here:
http://docs.python.org/release/2.5.2/tut/node16.html
To me, it looks as if you have truncated the lines, but otherwise there is
nothing wrong...
*When I tried to extract data and print them they look like this (totally
> different from the actual values!)*
>
> [ 0.18353712 0.30468928 0.16164556 ..., 0.98860032 0.49681098
> 0.77393306]
>
Yes, these are different numbers. But I assume you are comparing different
rows or columns?!
> *When I tried not using the "pylab.savetxt" function it gives an error
> like below:*
>
> ValueError: invalid literal for float():
> 0.0023,-0.0456,0.0419,0.094,0.0224,0.0365
>
This error message tells you that you are trying to save non-numeric data to
a file with that command.
Eg. this will cause the same error: scipy.savetxt('asdfasdf.dat',
'asdfasdf')
It is *VERY* hard to tell what you are doing since you don't provide exact
pieces of code.
> *Is there a specific way to handle signed decimal number? If so please
> suggest some changes.* And also I did try using the "array[]" to access
> individual comulns but I get an error saying the numpy.ndarray object not
> callable.
>
I must ask again? Have you played with the examples that I provided? You are
using the function in a wrong way (again, I can't tell for sure since you
don't provide code):
In order to acces the first row from a data array, you simply use data[0],
the first column is data.T[0].
*import matplotlib.pyplot as plt
> import pylab
> import scipy
> import numpy
> datafile1 = 'vet1.csv'
> data = pylab.rand(98760,6)
> pylab.savetxt(datafile1, data, delimiter=';')
> a1 = pylab.loadtxt(datafile1, comments='#', delimiter=';').T
> print 'loading', datafile1
> v1 = [0,1]
> v2 = [-2,2]*
> *plt.close('all')
> plt.figure()*
> *plt.ylim(v2)
> for i in range(2):
> plt.plot(a1[i])*
> *plt.show()*
>
> -Karthik
>
Please do provide all steps that cause problems, not just the results. It is
impossible to help you with assumptions and guesses :)
Best regards,
Daniel
From: Karthikraja V. <vel...@gm...> - 2011年06月11日 08:00:15
*Hi Daniel, *
* *
*I used the code but there is small issue. I forgot to mention that my
values are signed and unsigned decimal values. *
*My values look like this
*
 0.0023 -0.0456 0.0419 0.094 -0.0004 0.0236 -0.0237 -0.0043 -0.0718 0.0095
0.0592 -0.0417 0.0023 0.0386 -0.0023 -0.0236 -0.1045 0.098 -0.0006 0.0516
0.0463 -0.0035 -0.0442 0.1371 0.022 -0.0222 0.256 0.4903 0.0662 -0.0763
0.0064 0.1404
*After running the code the "pylab.savetxt" saves the same data something
like this*
8.205965840870644800e-01;8.034591567160346300e-01;5.493847743502982000e-01;2.581157685701491700e-01;6.409997826977161800e-01;3.719908502347885100e-01
*When I tried to extract data and print them they look like this (totally
different from the actual values!)*
[ 0.18353712 0.30468928 0.16164556 ..., 0.98860032 0.49681098
 0.77393306]
*When I tried not using the "pylab.savetxt" function it gives an error like
below:*
ValueError: invalid literal for float():
0.0023,-0.0456,0.0419,0.094,0.0224,0.0365
*Is there a specific way to handle signed decimal number? If so please
suggest some changes.* And also I did try using the "array[]" to access
individual comulns but I get an error saying the numpy.ndarray object not
callable.
*import matplotlib.pyplot as plt
import pylab
import scipy
import numpy
datafile1 = 'vet1.csv'
data = pylab.rand(98760,6)
pylab.savetxt(datafile1, data, delimiter=';')
a1 = pylab.loadtxt(datafile1, comments='#', delimiter=';').T
print 'loading', datafile1
v1 = [0,1]
v2 = [-2,2]*
*plt.close('all')
plt.figure()*
*plt.ylim(v2)
for i in range(2):
 plt.plot(a1[i])*
*plt.show()*
 -Karthik
From: Benjamin R. <ben...@ou...> - 2011年06月11日 03:50:47
On Fri, Jun 10, 2011 at 12:50 PM, calmar c. <ma...@ca...> wrote:
> On Fri, Jun 10, 2011 at 11:10:02AM -0500, Benjamin Root wrote:
> >
> > Why not just use an array of datetime.timedelta objects?� I believe
> > matplotlib already supports this, does automatic formatting and even
> > allows you to easily modify how the formatting is done.
>
> I was not able to figure out how it would support them
> (datetime.timedelta objects). datetime.datetime objects only as
> far as I saw.
>
>
That's right, I forgot about that. Usually, my data would have a starting
point anyway, and I just use timedeltas after that point.
> So I would have to create some artificial datetime + add the
> timedeltas (seconds) to it and providing that to the plot I guess,
> right?
>
>
You might be able to get away with using a datetime.time object and add
timedeltas. The formatting should be what you would like to see.
> So far the solution to just show i.e. 70sec as 00:01:20 via some
> little function is almost more sympathetic to me (so far at least).
>
>
Whatever works best for you, that's more important. Note that matplotlib
has some special treatment of date, time and datetime objects to do extra
things for you. It might be a bit tricky at first, but it becomes easier to
use later.
Admittedly, these following examples are for dates (and might even need to
be updated...)
http://matplotlib.sourceforge.net/examples/api/date_demo.html
http://matplotlib.sourceforge.net/examples/api/date_index_formatter.html
There are others as well.
Note that probably half that code can probably be removed for v1.0.x. When
I did my graphs a few months ago, I don't recall needing to specify any
formatters. Maybe I should dig up my code and update those examples.
Cheers,
Ben Root

Showing 4 results of 4

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