質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.50%
Jupyter

Jupyter (旧IPython notebook)は、Notebook形式でドキュメント作成し、プログラムの記述・実行、その実行結果を記録するツールです。メモの作成や保存、共有、確認などもブラウザ上で行うことができます。

Matplotlib

MatplotlibはPythonのおよび、NumPy用のグラフ描画ライブラリです。多くの場合、IPythonと連携して使われます。

Python

Pythonは、コードの読みやすさが特徴的なプログラミング言語の1つです。 強い型付け、動的型付けに対応しており、後方互換性がないバージョン2系とバージョン3系が使用されています。 商用製品の開発にも無料で使用でき、OSだけでなく仮想環境にも対応。Unicodeによる文字列操作をサポートしているため、日本語処理も標準で可能です。

Q&A

解決済

1回答

6232閲覧

matplotlibでEPSファイルを出力したいがエラーがでる

sasapink

総合スコア4

Jupyter

Jupyter (旧IPython notebook)は、Notebook形式でドキュメント作成し、プログラムの記述・実行、その実行結果を記録するツールです。メモの作成や保存、共有、確認などもブラウザ上で行うことができます。

Matplotlib

MatplotlibはPythonのおよび、NumPy用のグラフ描画ライブラリです。多くの場合、IPythonと連携して使われます。

Python

Pythonは、コードの読みやすさが特徴的なプログラミング言語の1つです。 強い型付け、動的型付けに対応しており、後方互換性がないバージョン2系とバージョン3系が使用されています。 商用製品の開発にも無料で使用でき、OSだけでなく仮想環境にも対応。Unicodeによる文字列操作をサポートしているため、日本語処理も標準で可能です。

0グッド

0クリップ

投稿2020/03/03 07:42

編集2020/03/04 01:02

前提・実現したいこと

pythonにて,matplotlibを使ってepsファイルを出力したいです.
EPSファイルは出力できているのですが,
TEXにて画像表示を行うと真っ白で表示されません.
また,EPS出力時にエラーをはいています.
エラーを出さず,TEXに表示されるようにしたいです.

発生している問題・エラーメッセージ

The PostScript backend does not support transparency; partially transparent artists will be rendered opaque. The PostScript backend does not support transparency; partially transparent artists will be rendered opaque. The PostScript backend does not support transparency; partially transparent artists will be rendered opaque. The PostScript backend does not support transparency; partially transparent artists will be rendered opaque. The PostScript backend does not currently support the selected font.
RuntimeError Traceback (most recent call last) <ipython-input-52-9309a6af578d> in <module> ---> 32 plt.savefig("./AAA.png",dpi=400,bbox_inches="tight") python\python37\lib\site-packages\matplotlib\pyplot.py in savefig(*args, **kwargs) 720 def savefig(*args, **kwargs): 721 fig = gcf() --> 722 res = fig.savefig(*args, **kwargs) 723 fig.canvas.draw_idle() # need this if 'transparent=True' to reset colors 724 return res python\python37\lib\site-packages\matplotlib\figure.py in savefig(self, fname, transparent, **kwargs) 2178 self.patch.set_visible(frameon) 2179 -> 2180 self.canvas.print_figure(fname, **kwargs) 2181 2182 if frameon: python\python37\lib\site-packages\matplotlib\backend_bases.py in print_figure(self, filename, dpi, facecolor, edgecolor, orientation, format, bbox_inches, **kwargs) 2080 orientation=orientation, 2081 bbox_inches_restore=_bbox_inches_restore, -> 2082 **kwargs) 2083 finally: 2084 if bbox_inches and restore_bbox: python\python37\lib\site-packages\matplotlib\backends\backend_ps.py in print_eps(self, outfile, *args, **kwargs) 840 841 def print_eps(self, outfile, *args, **kwargs): --> 842 return self._print_ps(outfile, 'eps', *args, **kwargs) 843 844 def _print_ps(self, outfile, format, *args, python\python37\lib\site-packages\matplotlib\backends\backend_ps.py in _print_ps(self, outfile, format, papertype, dpi, facecolor, edgecolor, orientation, *args, **kwargs) 869 self._print_figure(outfile, format, dpi, facecolor, edgecolor, 870 orientation, isLandscape, papertype, --> 871 **kwargs) 872 873 def _print_figure( python\python37\lib\site-packages\matplotlib\backends\backend_ps.py in _print_figure(self, outfile, format, dpi, facecolor, edgecolor, orientation, isLandscape, papertype, metadata, dryrun, bbox_inches_restore, **kwargs) 1105 else: 1106 with open(outfile, 'w', encoding='latin-1') as fh: -> 1107 print_figure_impl(fh) 1108 1109 def _print_figure_tex( python\python37\lib\site-packages\matplotlib\backends\backend_ps.py in print_figure_impl(fh) 1044 try: 1045 convert_ttf_to_ps(os.fsencode(font_filename), -> 1046 fh, fonttype, glyph_ids) 1047 except RuntimeError: 1048 _log.warning("The PostScript backend does not " RuntimeError: TrueType font is missing table

該当のソースコード

fig,axes = plt.subplots(1,2, sharex="all", sharey="all") colorlist = ["g","m","g","m"] markers=["o","v","o","v"] labels=["1","2","1","2"] line=["solid","dashed"] tmp=["","","",""] j = 0 for data in zip(mean_datas_N,std_datas_N,min_datas_N,max_datas_N): tmp[j] = axes[1].plot([1,2,3,4],data[0],color=colorlist[j],label=labels[j],marker=markers[j],linestyle = line[j]) j = j+1 tmp[2] = axes[0].plot([1,2,3,4],[0.8,0.8,0.8,0.8],color=colorlist[2],label=labels[2],marker=markers[2],linestyle=line[0]) tmp[3] = axes[0].plot([1,2,3,4],mean_datas_AA2,color=colorlist[3],label=labels[3],marker=markers[3],linestyle=line[1]) axes[0].set_xlabel(u"k", fontname="MS Gothic")##x軸の目盛指定 axes[1].set_xlabel(u"k", fontname="MS Gothic")##x軸の目盛指定 axes[0].set_ylabel(u"a", fontname="MS Gothic")##y軸の目盛指定 axes[0].set_title(u"A", fontname="MS Gothic") axes[1].set_title(u"N", fontname="MS Gothic") ticks = axes[0].set_xticks([1,2,3,4]) plt.ylim(0.7,1.0) l=axes[0].set_xticklabels([1,3,5,10])#x軸の目盛の表記指定,rotation傾 plt.subplots_adjust(wspace=0.05,right=0.85) axes[0].legend(loc="upper left", prop={"family":"MS Gothic","size":"14"})#,title=u"加工") plt.savefig("./AAA.eps",dpi=400,bbox_inches="tight")

試したこと

plt.savefig("./AAA.png",dpi=400,bbox_inches="tight")
見たく,PNG形式にすれば出力できました.

plt.savefig("./AAA.eps")
にしてもエラーがでます.

補足情報(FW/ツールのバージョンなど)

Jupyterを使って実行しています.

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

tiitoi

2020/03/03 07:45

現象が再現するグラフ生成のコードも追記できますか?
sasapink

2020/03/03 07:58

追記いたしました,よろしくお願いいたします.
tiitoi

2020/03/03 08:23

記載いただいたコードが一部でコピペして実行できないので、実行して確認できないです。 png での出力に成功したのであれば、以下のようなサービスを使って、EPS形式にあとから変換する方法ではダメでしょうか? https://onlineconvertfree.com/ja/convert-format/png-to-eps/
sasapink

2020/03/03 08:41

確認いただきありがとうございました. PNGからEPSに変換する考え,思いつきませんでした. 変換したところ,無事TEXに張り付けることができました. ありがとうございます.
guest

回答1

0

自己解決

EPS出力は断念し,PNGファイルをEPSファイルに変換して対処できました.

投稿2020/03/04 01:03

sasapink

総合スコア4

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.50%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問