Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #102375 > unrolled thread
| Started by | Paulo da Silva <p_s_d_a_s_i_l_v_a_ns@netcabo.pt> |
|---|---|
| First post | 2016-02-01 00:46 +0000 |
| Last post | 2016-02-01 19:22 +0000 |
| Articles | 7 — 4 participants |
Back to article view | Back to comp.lang.python
ts.plot() pandas: No plot! Paulo da Silva <p_s_d_a_s_i_l_v_a_ns@netcabo.pt> - 2016-02-01 00:46 +0000
Re: ts.plot() pandas: No plot! Chris Angelico <rosuav@gmail.com> - 2016-02-01 12:15 +1100
Re: ts.plot() pandas: No plot! Paulo da Silva <p_s_d_a_s_i_l_v_a_ns@netcabo.pt> - 2016-02-01 01:30 +0000
Re: ts.plot() pandas: No plot! Mark Lawrence <breamoreboy@yahoo.co.uk> - 2016-02-01 01:43 +0000
Re: ts.plot() pandas: No plot! Paulo da Silva <p_s_d_a_s_i_l_v_a_ns@netcabo.pt> - 2016-02-01 02:08 +0000
Re: ts.plot() pandas: No plot! Jason Swails <jason.swails@gmail.com> - 2016-02-01 09:18 -0500
Re: ts.plot() pandas: No plot! Paulo da Silva <p_s_d_a_s_i_l_v_a_ns@netcabo.pt> - 2016-02-01 19:22 +0000
| From | Paulo da Silva <p_s_d_a_s_i_l_v_a_ns@netcabo.pt> |
|---|---|
| Date | 2016-02-01 00:46 +0000 |
| Subject | ts.plot() pandas: No plot! |
| Message-ID | <n8m9sb$6ss$1@gioia.aioe.org> |
Hi!
I am learning pandas and following the tutorial I tried the following:
ts = pd.Series(np.random.randn(1000), index=pd.date_range('1/1/2000',
periods=1000))
ts = ts.cumsum()
ts.plot()
No plot is produced!
Only the following output:
<matplotlib.axes.AxesSubplot object at 0x7f33019b6630>
Any clue on what is happening?
I'm using kubuntu and python3.
Thanks.
Paulo
[toc] | [next] | [standalone]
| From | Chris Angelico <rosuav@gmail.com> |
|---|---|
| Date | 2016-02-01 12:15 +1100 |
| Message-ID | <mailman.178.1454289336.2338.python-list@python.org> |
| In reply to | #102375 |
On Mon, Feb 1, 2016 at 11:46 AM, Paulo da Silva
<p_s_d_a_s_i_l_v_a_ns@netcabo.pt> wrote:
> I am learning pandas and following the tutorial I tried the following:
> ts = pd.Series(np.random.randn(1000), index=pd.date_range('1/1/2000',
> periods=1000))
> ts = ts.cumsum()
> ts.plot()
>
> No plot is produced!
> Only the following output:
> <matplotlib.axes.AxesSubplot object at 0x7f33019b6630>
>
> Any clue on what is happening?
>
> I'm using kubuntu and python3.
>
Hmm. Normally I would expect matplotlib to pop up a graph there. Are
you running this from a terminal, or from some sort of GUI? It might
make a difference to how it brings up the graph. Interestingly, I'm
not able to run your example on my system:
>>> pd.__version__
'0.17.1'
>>> pd.date_range('1/1/2000', periods=1000)
ValueError: Error parsing datetime string "1/1/2000" at position 1
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.6/site-packages/pandas/tseries/index.py",
line 1923, in date_range
closed=closed, **kwargs)
File "/usr/local/lib/python3.6/site-packages/pandas/util/decorators.py",
line 89, in wrapper
return func(*args, **kwargs)
File "/usr/local/lib/python3.6/site-packages/pandas/tseries/index.py",
line 237, in __new__
ambiguous=ambiguous)
File "/usr/local/lib/python3.6/site-packages/pandas/tseries/index.py",
line 379, in _generate
start = Timestamp(start)
File "pandas/tslib.pyx", line 299, in pandas.tslib.Timestamp.__new__
(pandas/tslib.c:8973)
File "pandas/tslib.pyx", line 1163, in
pandas.tslib.convert_to_tsobject (pandas/tslib.c:22522)
File "pandas/tslib.pyx", line 1271, in
pandas.tslib.convert_str_to_tsobject (pandas/tslib.c:24121)
File "pandas/src/datetime.pxd", line 141, in datetime._string_to_dts
(pandas/tslib.c:80505)
SystemError: <class 'str'> returned a result with an error set
So it's possible you've run into something that's changed between
versions. Your original example works on my 2.7, although it doesn't
pop up a graph. So now I'm a bit lost. :)
ChrisA
[toc] | [prev] | [next] | [standalone]
| From | Paulo da Silva <p_s_d_a_s_i_l_v_a_ns@netcabo.pt> |
|---|---|
| Date | 2016-02-01 01:30 +0000 |
| Message-ID | <n8mcfv$9d7$1@gioia.aioe.org> |
| In reply to | #102376 |
Às 01:15 de 01-02-2016, Chris Angelico escreveu: > On Mon, Feb 1, 2016 at 11:46 AM, Paulo da Silva > <p_s_d_a_s_i_l_v_a_ns@netcabo.pt> wrote: ... > > Hmm. Normally I would expect matplotlib to pop up a graph there. Are > you running this from a terminal, or from some sort of GUI? It might > make a difference to how it brings up the graph. Interestingly, I'm > not able to run your example on my system: > I'm running it from "konsole", the kde terminal. The example is from here http://pandas.pydata.org/pandas-docs/stable/10min.html#plotting
[toc] | [prev] | [next] | [standalone]
| From | Mark Lawrence <breamoreboy@yahoo.co.uk> |
|---|---|
| Date | 2016-02-01 01:43 +0000 |
| Message-ID | <mailman.179.1454291031.2338.python-list@python.org> |
| In reply to | #102375 |
On 01/02/2016 00:46, Paulo da Silva wrote:
> Hi!
>
> I am learning pandas and following the tutorial I tried the following:
> ts = pd.Series(np.random.randn(1000), index=pd.date_range('1/1/2000',
> periods=1000))
> ts = ts.cumsum()
> ts.plot()
>
> No plot is produced!
> Only the following output:
> <matplotlib.axes.AxesSubplot object at 0x7f33019b6630>
>
> Any clue on what is happening?
>
> I'm using kubuntu and python3.
>
> Thanks.
> Paulo
>
Is it as simple as adding a call to ts.show() ?
--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.
Mark Lawrence
[toc] | [prev] | [next] | [standalone]
| From | Paulo da Silva <p_s_d_a_s_i_l_v_a_ns@netcabo.pt> |
|---|---|
| Date | 2016-02-01 02:08 +0000 |
| Message-ID | <n8mem0$ba2$1@gioia.aioe.org> |
| In reply to | #102378 |
Às 01:43 de 01-02-2016, Mark Lawrence escreveu: > On 01/02/2016 00:46, Paulo da Silva wrote: ... >> > > Is it as simple as adding a call to ts.show() ? > Thanks for the clue! Not so simple however. Needed to do import matplotlib.pyplot as plt plt.show() Thank you :-) Paulo
[toc] | [prev] | [next] | [standalone]
| From | Jason Swails <jason.swails@gmail.com> |
|---|---|
| Date | 2016-02-01 09:18 -0500 |
| Message-ID | <mailman.3.1454336323.3032.python-list@python.org> |
| In reply to | #102380 |
On Sun, Jan 31, 2016 at 9:08 PM, Paulo da Silva < p_s_d_a_s_i_l_v_a_ns@netcabo.pt> wrote: > Às 01:43 de 01-02-2016, Mark Lawrence escreveu: > > On 01/02/2016 00:46, Paulo da Silva wrote: > ... > > >> > > > > Is it as simple as adding a call to ts.show() ? > > > Thanks for the clue! > Not so simple however. > Needed to do > import matplotlib.pyplot as plt > plt.show() > What you saw ts.plot() return was the matplotlib artists (the things that will be drawn on whatever "canvas" is provided -- either saved to an image or drawn to a GUI widget). So whenever you see this kind of return value, you know you need to call the matplotlib.pyplot.show function in order to generate a canvas widget (with whatever backend you choose) and draw it. If you want to do this kind of interactive plotting (reminiscent, I've heard, of Matlab), I would highly recommend checking out IPython. You can use IPython's notebook or qtconsole and embed plots from matplotlib directly in the viewer. For example, try this: ipython qtconsole This opens up a window, then use the magic command "%matplotlib inline" to have all plots sent directly to the ipython console you are typing commands in. I've found that kind of workflow quite convenient for directly interacting with data. HTH, Jason
[toc] | [prev] | [next] | [standalone]
| From | Paulo da Silva <p_s_d_a_s_i_l_v_a_ns@netcabo.pt> |
|---|---|
| Date | 2016-02-01 19:22 +0000 |
| Message-ID | <n8ob8v$15ov$1@gioia.aioe.org> |
| In reply to | #102388 |
Às 14:18 de 01-02-2016, Jason Swails escreveu: > On Sun, Jan 31, 2016 at 9:08 PM, Paulo da Silva < > p_s_d_a_s_i_l_v_a_ns@netcabo.pt> wrote: > >> Às 01:43 de 01-02-2016, Mark Lawrence escreveu: >>> On 01/02/2016 00:46, Paulo da Silva wrote: ... > > What you saw ts.plot() return was the matplotlib artists (the things that > will be drawn on whatever "canvas" is provided -- either saved to an image > or drawn to a GUI widget). So whenever you see this kind of return value, > you know you need to call the matplotlib.pyplot.show function in order to > generate a canvas widget (with whatever backend you choose) and draw it. > > If you want to do this kind of interactive plotting (reminiscent, I've > heard, of Matlab), I would highly recommend checking out IPython. You can > use IPython's notebook or qtconsole and embed plots from matplotlib > directly in the viewer. For example, try this: > > ipython qtconsole > > This opens up a window, then use the magic command "%matplotlib inline" to > have all plots sent directly to the ipython console you are typing commands > in. I've found that kind of workflow quite convenient for directly > interacting with data. Thank you Jason. This can be very usefull.
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web