<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Jupyter Notebook | kabusin blog</title>
	<atom:link href="https://blog.kabusin.com/tag/jupyter-notebook/feed/" rel="self" type="application/rss+xml" />
	<link>https://blog.kabusin.com</link>
	<description>投資×個人開発×製造業ITについて情報発信するブログ</description>
	<lastBuildDate>Tue, 18 Aug 2020 14:15:14 +0000</lastBuildDate>
	<language>ja</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=5.8.13</generator>
	<item>
		<title>【Plolty】Jupyter Notebookを使って描画する方法(Windows10)</title>
		<link>https://blog.kabusin.com/plotly-jupyter-try/</link>
					<comments>https://blog.kabusin.com/plotly-jupyter-try/#respond</comments>
		
		<dc:creator><![CDATA[ふみ]]></dc:creator>
		<pubDate>Mon, 17 Aug 2020 12:11:04 +0000</pubDate>
				<category><![CDATA[Plotly]]></category>
		<category><![CDATA[Jupyter Notebook]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Windows10]]></category>
		<guid isPermaLink="false">http://blog.kabusin.com/?p=59</guid>

					<description><![CDATA[<p>Plotlyは、インタラクティブなグラフが作れるデータ可視化のライブラリです。 Plotlyを使ったWebサイト構築経験がある私が初心者に向けて１つずつ使い方を説明していきたいと思います。※作ったサイトはここです。(※銘 [&#8230;]</p>
<p>The post <a href="https://blog.kabusin.com/plotly-jupyter-try/">【Plolty】Jupyter Notebookを使って描画する方法(Windows10)</a> first appeared on <a href="https://blog.kabusin.com">kabusin blog</a>.</p>]]></description>
										<content:encoded><![CDATA[<p>Plotlyは、インタラクティブなグラフが作れるデータ可視化のライブラリです。</p>



<p><strong>Plotlyを使ったWebサイト構築経験</strong>がある私が初心者に向けて１つずつ使い方を説明していきたいと思います。<strong>※作ったサイトは<a rel="noopener" href="https://kabusin.com/" target="_blank">ここ</a>です。</strong>(※銘柄検索したらチャートが出ます）</p>



<p><a href="https://blog.kabusin.com/plolty-python-install/" title="【Plolty】Python環境構築(Windows10)の方法">前回の環境構築</a>の続きです。環境構築できたら実際に動かしてみましょう。</p>




  <div id="toc" class="toc tnt-number toc-center tnt-number border-element"><input type="checkbox" class="toc-checkbox" id="toc-checkbox-2" checked><label class="toc-title" for="toc-checkbox-2">目次</label>
    <div class="toc-content">
    <ol class="toc-list open"><li><a href="#toc1" tabindex="0">Jupyter Notebookの起動</a></li><li><a href="#toc2" tabindex="0">Jupyter NotebookでPython実行環境を作成する</a></li><li><a href="#toc3" tabindex="0">Plotlyのインポートと描画のやり方</a></li><li><a href="#toc4" tabindex="0">まとめ</a></li></ol>
    </div>
  </div>

<h2><span id="toc1">Jupyter Notebookの起動</span></h2>



<p> デスクトップから左下のWindowマーク    <img loading="lazy" width="48" height="41" class="wp-image-62" style="width: 48px;" src="http://blog.kabusin.com/wp-content/uploads/2020/08/image-24.png" alt="">　を押すと以下のように<br>プログラムメニューが表示されます。</p>



<p></p>



<div class="wp-block-image"><figure class="aligncenter size-large is-resized"><img loading="lazy" src="http://blog.kabusin.com/wp-content/uploads/2020/08/image-23.png" alt="" class="wp-image-61" width="251" height="609" srcset="https://blog.kabusin.com/wp-content/uploads/2020/08/image-23.png 275w, https://blog.kabusin.com/wp-content/uploads/2020/08/image-23-124x300.png 124w" sizes="(max-width: 251px) 100vw, 251px" /></figure></div>



<p>この中で、Jupyter Notebook(Anaconda3)をクリックします。これ<img loading="lazy" width="273" height="35" class="wp-image-63" style="width: 150px;" src="http://blog.kabusin.com/wp-content/uploads/2020/08/image-25.png" alt=""></p>



<figure class="wp-block-image size-large"><img loading="lazy" width="979" height="512" src="http://blog.kabusin.com/wp-content/uploads/2020/08/image-26.png" alt="" class="wp-image-64" srcset="https://blog.kabusin.com/wp-content/uploads/2020/08/image-26.png 979w, https://blog.kabusin.com/wp-content/uploads/2020/08/image-26-300x157.png 300w, https://blog.kabusin.com/wp-content/uploads/2020/08/image-26-768x402.png 768w" sizes="(max-width: 979px) 100vw, 979px" /></figure>



<p>すると黒い画面が表示され、以下のようなブラウザが立ち上がります。</p>



<figure class="wp-block-image size-large"><img loading="lazy" width="960" height="703" src="http://blog.kabusin.com/wp-content/uploads/2020/08/image-28.png" alt="" class="wp-image-66" srcset="https://blog.kabusin.com/wp-content/uploads/2020/08/image-28.png 960w, https://blog.kabusin.com/wp-content/uploads/2020/08/image-28-300x220.png 300w, https://blog.kabusin.com/wp-content/uploads/2020/08/image-28-768x562.png 768w" sizes="(max-width: 960px) 100vw, 960px" /></figure>



<h2><span id="toc2">Jupyter NotebookでPython実行環境を作成する</span></h2>



<figure class="wp-block-image size-large"><img loading="lazy" width="976" height="655" src="http://blog.kabusin.com/wp-content/uploads/2020/08/image-30.png" alt="" class="wp-image-68" srcset="https://blog.kabusin.com/wp-content/uploads/2020/08/image-30.png 976w, https://blog.kabusin.com/wp-content/uploads/2020/08/image-30-300x201.png 300w, https://blog.kabusin.com/wp-content/uploads/2020/08/image-30-768x515.png 768w" sizes="(max-width: 976px) 100vw, 976px" /></figure>



<p>赤丸の部分であるNewのボタンをクリックします。</p>



<figure class="wp-block-image size-large"><img loading="lazy" width="309" height="218" src="http://blog.kabusin.com/wp-content/uploads/2020/08/image-31.png" alt="" class="wp-image-69" srcset="https://blog.kabusin.com/wp-content/uploads/2020/08/image-31.png 309w, https://blog.kabusin.com/wp-content/uploads/2020/08/image-31-300x212.png 300w" sizes="(max-width: 309px) 100vw, 309px" /></figure>



<p>Python 3を選びます。</p>



<figure class="wp-block-image size-large"><img loading="lazy" width="960" height="703" src="http://blog.kabusin.com/wp-content/uploads/2020/08/image-32.png" alt="" class="wp-image-70" srcset="https://blog.kabusin.com/wp-content/uploads/2020/08/image-32.png 960w, https://blog.kabusin.com/wp-content/uploads/2020/08/image-32-300x220.png 300w, https://blog.kabusin.com/wp-content/uploads/2020/08/image-32-768x562.png 768w" sizes="(max-width: 960px) 100vw, 960px" /></figure>



<p>こんな画面が表示されます。これでPythonでの実行環境が整いました。簡単ですね。</p>



<figure class="wp-block-image size-large"><img loading="lazy" width="960" height="703" src="http://blog.kabusin.com/wp-content/uploads/2020/08/image-33.png" alt="" class="wp-image-71" srcset="https://blog.kabusin.com/wp-content/uploads/2020/08/image-33.png 960w, https://blog.kabusin.com/wp-content/uploads/2020/08/image-33-300x220.png 300w, https://blog.kabusin.com/wp-content/uploads/2020/08/image-33-768x562.png 768w" sizes="(max-width: 960px) 100vw, 960px" /></figure>



<p>試しに実行してみましょう。上記図のようにprint(&#8216;test&#8217;)と入力します。<br>その後に Ctrlを押しながらEnteryキーを入力します。すると。。。</p>



<figure class="wp-block-image size-large"><img loading="lazy" width="960" height="715" src="http://blog.kabusin.com/wp-content/uploads/2020/08/image-34.png" alt="" class="wp-image-72" srcset="https://blog.kabusin.com/wp-content/uploads/2020/08/image-34.png 960w, https://blog.kabusin.com/wp-content/uploads/2020/08/image-34-300x223.png 300w, https://blog.kabusin.com/wp-content/uploads/2020/08/image-34-768x572.png 768w" sizes="(max-width: 960px) 100vw, 960px" /></figure>



<p>こんな感じでPythonでPrint文を使うことができました。<br>（※Print文=文字列の出力)</p>



<h2><span id="toc3">Plotlyのインポートと描画のやり方</span></h2>



<p>ではようやくPlotlyです。<br>Plotlyサイトにある基本的なチャートとして棒グラフを表示してみます。</p>



<p>以下のコードをコピペして実行(Ctrl+Enter)してみてください。</p>



<div class="hcb_wrap"><pre class="prism undefined-numbers lang-python" data-lang="Python"><code>import plotly.express as px
data_canada = px.data.gapminder().query(&quot;country == &#39;Canada&#39;&quot;)
fig = px.bar(data_canada, x=&#39;year&#39;, y=&#39;pop&#39;)
fig.show()</code></pre></div>



<figure class="wp-block-image size-large"><img loading="lazy" width="886" height="795" src="http://blog.kabusin.com/wp-content/uploads/2020/08/image-35.png" alt="" class="wp-image-74" srcset="https://blog.kabusin.com/wp-content/uploads/2020/08/image-35.png 886w, https://blog.kabusin.com/wp-content/uploads/2020/08/image-35-300x269.png 300w, https://blog.kabusin.com/wp-content/uploads/2020/08/image-35-768x689.png 768w" sizes="(max-width: 886px) 100vw, 886px" /></figure>



<p>こんな感じで棒グラフが描画できます。</p>



<p>コードの意味を１つずつ説明すると</p>



<p>①Plotly のインポート</p>



<div class="hcb_wrap"><pre class="prism undefined-numbers lang-python" data-lang="Python"><code>import plotly.express as px</code></pre></div>



<p>②plotly.express内にあるデータセットgapminderから条件(国がカナダ)を抽出して<br>データセット</p>



<div class="hcb_wrap"><pre class="prism undefined-numbers lang-python" data-lang="Python"><code>data_canada = px.data.gapminder().query(&quot;country == &#39;Canada&#39;&quot;)</code></pre></div>



<p>③Plotly棒グラフに②のデータをセットして、横軸(x)をyear、縦軸(y)をpopとした</p>



<div class="hcb_wrap"><pre class="prism undefined-numbers lang-python" data-lang="Python"><code>fig = px.bar(data_canada, x=&#39;year&#39;, y=&#39;pop&#39;)</code></pre></div>



<p>④描画実行</p>



<div class="hcb_wrap"><pre class="prism undefined-numbers lang-python" data-lang="Python"><code>fig.show()</code></pre></div>



<p>のイメージになります。</p>



<h2><span id="toc4">まとめ</span></h2>



<p>今回は、Jupyter Notebookを使ってPloltyで描画してみました。今回は一番簡単な棒グラフを表示しました。Plotlyにはいろいろなチャートパターンが用意されているので次回からは各チャートパターンについて１つずつ説明していきたいと思います。</p><p>The post <a href="https://blog.kabusin.com/plotly-jupyter-try/">【Plolty】Jupyter Notebookを使って描画する方法(Windows10)</a> first appeared on <a href="https://blog.kabusin.com">kabusin blog</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://blog.kabusin.com/plotly-jupyter-try/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
