pyenv-virtualenvで作った環境でmatplotlibとNetworkXが文字化け 前回、Macにpyenv-virtualenvを使ってPython環境を作りましたが、その時いれたmatplotlibとNetworkXで日本語文字が文字化けしている状態になっていました。 どちらも有名なライブラリなので、普通にインストールしていたら特にはまらない箇所だと思うのですが、手元の環境では文字化けします。解消方法を探してみました。 matplotlibで日本語を表示する サンプルコード
matplotlibで日本語を表示しようとすると以下のように文字化けしてしまう。 import matplotlib.pyplot as plt plt.plot(list(range(10)), list(range(10))) plt.title('日本語タイトル') これはmatplotlibで使っているフォントが日本語に対応していないからなので対応しているフォントを使うようにしてやる。 ちなみに今使っているフォントはplt.rcParams['font.family']を出力して確認できる。 フォントの取得 フォントをmatplotlibに追加 フォントをデフォルトとして登録 キャッシュを削除 プロット再確認 参考:一時的にフォントを変えたいだけのとき 特定のスクリプトだけフォントを変えたいとき 特定の図だけフォントを変えたいとき 参考:フォント名を確認する方法 フォントの取得 日
English version available on dev.to はじめに matplotlibで作ったグラフの細かい調整は大変です。何をどういじったらいいのかを調べるのにアホみたいに時間がかかることがあります1。「何を」の部分の名前さえわからないこともあります。解決の糸口を掴んだ後も希望通りの見た目を実現するまでの最後のアレンジに苦労することが多いです2。これらの問題はmatplotlibのグラフがどういう要素で構成されていて、それらに対してどういうことができるかを知ることでいくらか改善されます。私はひたすらStack Overflowの回答を読むことでいろんなつまづきを時間をかけて乗り越えてきましたが、最近になってようやく公式チュートリアルにこの苦労を回避できたはずのヒントが書いてあることに気づきました。初期にざっと目を通したのですが「なるほど、よくわからん」と判断して読み込まな
Sphinx extensions for embedded plots, math and more¶ Sphinx is written in python, and supports the ability to write custom extensions. We’ve written a few for the matplotlib documentation, some of which are part of matplotlib itself in the matplotlib.sphinxext module, some of which are included only in the sphinx doc directory, and there are other extensions written by other groups, eg numpy and i
2016-11-11 「ax.annotate 文字と矢印」を追加,見出しを微調整 2016-11-11 「Locator 目盛り位置」を追加 2016-12-16 「Locator 目盛り位置」をアップデート 2017-02-11 凡例を「枠外に出す」方法を追加
Pandasのグラフ描画機能 この記事ではPandasのPlot機能について扱います。 Pandasはデータの加工・集計のためのツールとしてその有用性が広く知られていますが、同時に優れた可視化機能を備えているということは、意外にあまり知られていません。 この機能は Pandas.DataFrame.plot() もしくは Pandas Plot と呼ばれるものです。 Pandas Plotを使いこなすことが出来るようになれば、 データの読み込み、保持 データの加工 データの集計 データの可視化 というデータ分析の一連のプロセスを全てPandasで完結させることが出来る、つまり分析の「揺りかごから墓場まで」を実現することが出来ます。 Pandasのプロット以外の機能について この記事ではPandasのデータハンドリングなどに関わる機能は説明しません。 そちらにも興味がある方は下記の記事などを
mpld3¶ The mpld3 project brings together Matplotlib, the popular Python-based graphing library, and D3js, the popular JavaScript library for creating interactive data visualizations for the web. The result is a simple API for exporting your matplotlib graphics to HTML code which can be used within the browser, within standard web pages, blogs, or tools such as the IPython notebook. See the Example
Seaborn is a Python data visualization library based on matplotlib. It provides a high-level interface for drawing attractive and informative statistical graphics. For a brief introduction to the ideas behind the library, you can read the introductory notes or the paper. Visit the installation page to see how you can download the package and get started with it. You can browse the example gallery
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く