Re: Plot not showing up in Jupyter.
William Shipman <[email protected]> Tue, 23 Feb 2016 20:52:40 +0200
| Newsgroups | gmane.comp.python.ipython.user |
|---|---|
| Message-ID | <CAOUkfAyswdcsbdM+jkz0e3Eqbb6HeqyYhcrDoGotJ807O8PgzQ@mail.gmail.com> |
--===============0877311892044505837== Content-Type: multipart/alternative; boundary=001a113a99d02ca8f3052c7474ae --001a113a99d02ca8f3052c7474ae Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable You need to add %matplotlib inline before you want to draw your plots, e.g. at the start of your notebook. Alternatively call plt.show() but that will open separate figure windows rather than showing the figures in the notebook. On 23 February 2016 at 20:30, <[email protected]> wrote: > Hello, > I=E2=80=99m new to Jupyter and am also learning python and pandas for dat= a > analysis. > The version of the notebook server is *4.0.6* and is running on: > Python 2.7.10 |Anaconda 2.4.0 (64-bit)| (default, Oct 21 2015, 19:35:23) > [MSC v.1500 64 bit (AMD64)] > > I'm working on a Win/7 64bit pro system. > > Currently I=E2=80=99m watching Alfred Essa=E2=80=99s video series and am = having an issue > with Jupyter in regards to one of the lessons. ( > https://www.youtube.com/watch?v=3DrNmn8bLFgdg) > <https://www.youtube.com/watch?v=3DrNmn8bLFgdg> > I=E2=80=99m not sure how much of the code I need to submit, but basically= I=E2=80=99ve > created a subset of salary data, from which I extract the top 10 payees. = I=E2=80=99ve > imported pandas as pd and matplotlib.pyplot as plt into the notebook. > Everything is working fine and I=E2=80=99ve been able to verify my data. = My last > bit of code is: > > *#create a data set of the top 10 paid players* > top10 =3D yr2010.Salary.sort_values(ascending =3DFalse).head(10) > > This creates a series object of the data and then I tried to plot it and > that=E2=80=99s where the problem lies. > Here=E2=80=99s my code to plot: > > #plot highest paid > plt.figure() > top10.plot(label=3D'Salaries') > plt.xticks(rotation=3D'vertical') > plt.legend() > > and the output is this: > <matplotlib.legend.Legend at 0xbff72e8> > > No plot image. > > Note: I have copied all of my code and run it successfully, producing > the plotted image in both IDLE and the Spyder IDE. > > The video series is a few years old and I=E2=80=99m wondering if there is= a > difference between Jupyter and IP[y]: Notebook versions that may require = a > code change in order for the plot to show up. The videos show the Mr. > Essa using > IP[y]: Notebook. > > Thanks and I look forward to any assistance. > Ana > > _______________________________________________ > IPython-User mailing list > [email protected] > https://mail.scipy.org/mailman/listinfo/ipython-user > > --001a113a99d02ca8f3052c7474ae Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable <div dir=3D"ltr"><div class=3D"gmail_default" style=3D"color:rgb(0,0,0)">Yo= u need to add <br><pre style=3D"" class=3D""><code><span class=3D"">%</span= ><span class=3D"">matplotlib inline</span></code><br><br><span style=3D"fon= t-family:arial,helvetica,sans-serif">before you want to draw your plots, e.= g. at the start of your notebook. Alternatively call <span style=3D"font-fa= mily:monospace,monospace">plt.show()</span> but that will open separate fig= ure windows rather than showing the figures in the notebook.</span></pre></= div></div><div class=3D"gmail_extra"><br><div class=3D"gmail_quote">On 23 F= ebruary 2016 at 20:30, <span dir=3D"ltr"><<a href=3D"mailto:starigazey@= aol.com" target=3D"_blank">[email protected]</a>></span> wrote:<br><blo= ckquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #c= cc solid;padding-left:1ex"><font color=3D"black" face=3D"arial" size=3D"2"> <div class=3D"MsoNormal"><font face=3D"Arial, Helvetica, sans-serif">Hello,= </font></div> <font face=3D"Arial, Helvetica, sans-serif"> </font> <div class=3D"MsoNormal"><font face=3D"Arial, Helvetica, sans-serif">I=E2= =80=99m new to Jupyter and am also learning python and pandas for data analysis.</font></div> <font face=3D"Arial, Helvetica, sans-serif"> </font> <div class=3D"MsoNormal" style=3D"margin-bottom:0in;margin-bottom:.0001pt">= <font face=3D"Arial, Helvetica, sans-serif"><span>The version of the notebook server is <b>4.0.6</b> and is running on:</span></f= ont></div> <font face=3D"Arial, Helvetica, sans-serif"> </font> <div class=3D"MsoNormal" style=3D"margin-bottom:0in;margin-bottom:.0001pt;l= ine-height:normal"><font face=3D"Arial, Helvetica, sans-serif"><span>Python 2.7.10 |Anaconda 2.4.0 (64-bit)| (default, Oct 21 2015, 19:35:23) [MSC v.15= 00 64 bit (AMD64)]</span></font></div> <div class=3D"MsoNormal" style=3D"margin-bottom:0in;margin-bottom:.0001pt;l= ine-height:normal"><font face=3D"Arial, Helvetica, sans-serif"><br> <span></span></font></div> <div class=3D"MsoNormal" style=3D"margin-bottom:0in;margin-bottom:.0001pt;l= ine-height:normal"><font face=3D"Arial, Helvetica, sans-serif"><span><font = size=3D"2">I'm working on a Win/7 64bit pro system.</font><br> </span></font></div> <font face=3D"Arial, Helvetica, sans-serif"> </font> <div class=3D"MsoNormal" style=3D"margin-bottom:0in;margin-bottom:.0001pt">= <font face=3D"Arial, Helvetica, sans-serif">=C2=A0</font></div> <font face=3D"Arial, Helvetica, sans-serif"> </font> <div class=3D"MsoNormal"><font face=3D"Arial, Helvetica, sans-serif">Curren= tly I=E2=80=99m watching Alfred Essa=E2=80=99s video series and am having an issue with Jupyter in regards to one of the lessons.<font size=3D= "2">=C2=A0 (</font><a href=3D"https://www.youtube.com/watch?v=3DrNmn8bLFgdg= " target=3D"_blank">https://www.youtube.com/watch?v=3DrNmn8bLFgdg<font size= =3D"2">)</font></a></font></div> <font face=3D"Arial, Helvetica, sans-serif"> </font> <div class=3D"MsoNormal"><font face=3D"Arial, Helvetica, sans-serif">I=E2= =80=99m not sure how much of the code I need to submit, but basically I=E2=80=99ve created a subset of salary data, from which I extrac= t the top 10 payees.<span>=C2=A0 </span>I=E2=80=99ve imported pandas as pd and matplotlib.pyplot as plt<font size=3D"2"> into the notebook</font>. Everyth= ing is working fine and I=E2=80=99ve been able to verify my data. My last bit of code is:</font></div> <div class=3D"MsoNormal"><br> </div> <div class=3D"MsoNormal" style=3D"margin-bottom:0in;margin-bottom:.0001pt">= <font face=3D"Courier New, Courier, mono"><i>#create a data set of the top = 10 paid players</i></font></div> <font face=3D"Courier New, Courier, mono"> </font> <div class=3D"MsoNormal" style=3D"margin-bottom:0in;margin-bottom:.0001pt">= <font face=3D"Courier New, Courier, mono">top10 =3D yr2010.Salary.sort_values(ascending =3DFalse).head(10)</font></div> <div class=3D"MsoNormal" style=3D"margin-bottom:0in;margin-bottom:.0001pt">= =C2=A0</div> <div class=3D"MsoNormal" style=3D"margin-bottom:0in;margin-bottom:.0001pt">= This creates a series object of the data and then I tried to plot it and that=E2=80=99s = where the problem lies.</div> <div class=3D"MsoNormal" style=3D"margin-bottom:0in;margin-bottom:.0001pt">= Here=E2=80=99s my code to plot:</div> <div class=3D"MsoNormal" style=3D"margin-bottom:0in;margin-bottom:.0001pt">= <br> </div> <div class=3D"MsoNormal" style=3D"margin-bottom:0in;margin-bottom:.0001pt">= <font face=3D"Courier New, Courier, mono">#plot highest paid</font></div> <font face=3D"Courier New, Courier, mono"> </font> <div class=3D"MsoNormal" style=3D"margin-bottom:0in;margin-bottom:.0001pt">= <font face=3D"Courier New, Courier, mono">plt.figure()</font></div> <font face=3D"Courier New, Courier, mono"> </font> <div class=3D"MsoNormal" style=3D"margin-bottom:0in;margin-bottom:.0001pt">= <font face=3D"Courier New, Courier, mono">top10.plot(label=3D'Salaries&= #39;)</font></div> <font face=3D"Courier New, Courier, mono"> </font> <div class=3D"MsoNormal" style=3D"margin-bottom:0in;margin-bottom:.0001pt">= <font face=3D"Courier New, Courier, mono">plt.xticks(rotation=3D'vertic= al')</font></div> <font face=3D"Courier New, Courier, mono"> </font> <div class=3D"MsoNormal" style=3D"margin-bottom:0in;margin-bottom:.0001pt">= <font face=3D"Courier New, Courier, mono">plt.legend()</font></div> <font face=3D"Courier New, Courier, mono"> </font> <div class=3D"MsoNormal" style=3D"margin-bottom:0in;margin-bottom:.0001pt">= <font face=3D"Courier New, Courier, mono">=C2=A0</font></div> <div class=3D"MsoNormal" style=3D"margin-bottom:0in;margin-bottom:.0001pt">= and the output is this:</div> <div class=3D"MsoNormal" style=3D"margin-bottom:0in;margin-bottom:.0001pt;l= ine-height:normal"><span style=3D"font-size:10.0pt;font-family:"Courie= r New""><matplotlib.legend.Legend at 0xbff72e8></span></div> <div class=3D"MsoNormal" style=3D"margin-bottom:0in;margin-bottom:.0001pt;l= ine-height:normal"><span style=3D"font-size:10.0pt;font-family:"Courie= r New"">=C2=A0</span></div> <div class=3D"MsoNormal" style=3D"margin-bottom:0in;margin-bottom:.0001pt;l= ine-height:normal"><font face=3D"Arial, Helvetica, sans-serif"><span style= =3D"font-size:10pt">No plot image.</span></font></div> <font face=3D"Arial, Helvetica, sans-serif"> </font> <div class=3D"MsoNormal" style=3D"margin-bottom:0in;margin-bottom:.0001pt">= <font face=3D"Arial, Helvetica, sans-serif">=C2=A0</font></div> <font face=3D"Arial, Helvetica, sans-serif"> </font> <div class=3D"MsoNormal" style=3D"margin-bottom:0in;margin-bottom:.0001pt">= <font face=3D"Arial, Helvetica, sans-serif">Note:<span>=C2=A0 </span>I have= copied all of my code and run it successfully, producing the plotted image in both IDLE and the Spyder IDE.<= /font></div> <font face=3D"Arial, Helvetica, sans-serif"> </font> <div class=3D"MsoNormal" style=3D"margin-bottom:0in;margin-bottom:.0001pt">= <font face=3D"Arial, Helvetica, sans-serif">=C2=A0</font></div> <font face=3D"Arial, Helvetica, sans-serif"> </font> <div class=3D"MsoNormal" style=3D"margin-bottom:0in;margin-bottom:.0001pt">= <font face=3D"Arial, Helvetica, sans-serif">The video series is a few years old and I=E2=80=99m wondering if there is a differenc= e between Jupyter and IP[y]: Notebook versions that may require a code change in orde= r for the plot to show up.<font size=3D"2"> The videos show the Mr. Essa usin= g </font></font><br> <font face=3D"Arial, Helvetica, sans-serif">IP[y]: Notebook<font size=3D"2"= >.</font></font></div> <font face=3D"Arial, Helvetica, sans-serif"> </font> <div class=3D"MsoNormal" style=3D"margin-bottom:0in;margin-bottom:.0001pt">= <font face=3D"Arial, Helvetica, sans-serif">=C2=A0</font></div> <font face=3D"Arial, Helvetica, sans-serif"> </font> <div class=3D"MsoNormal" style=3D"margin-bottom:0in;margin-bottom:.0001pt">= <font face=3D"Arial, Helvetica, sans-serif">Thanks and I look forward to any assistance.</font></div> <font face=3D"Arial, Helvetica, sans-serif"> </font> <div class=3D"MsoNormal" style=3D"margin-bottom:0in;margin-bottom:.0001pt">= <font face=3D"Arial, Helvetica, sans-serif">Ana</font></div> </font><br>_______________________________________________<br> IPython-User mailing list<br> <a href=3D"mailto:[email protected]">[email protected]</a><br> <a href=3D"https://mail.scipy.org/mailman/listinfo/ipython-user" rel=3D"nor= eferrer" target=3D"_blank">https://mail.scipy.org/mailman/listinfo/ipython-= user</a><br> <br></blockquote></div><br></div> --001a113a99d02ca8f3052c7474ae-- --===============0877311892044505837== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ IPython-User mailing list [email protected] https://mail.scipy.org/mailman/listinfo/ipython-user --===============0877311892044505837==--